@Override public EndpointDefinition createEndpointDefinition(OMElement elem) { DefinitionFactory fac = getEndpointDefinitionFactory(); EndpointDefinition endpointDefinition; if (fac == null) { fac = new EndpointDefinitionFactory(); endpointDefinition = fac.createDefinition(elem); } else{ endpointDefinition = fac.createDefinition(elem); } extractSpecificEndpointProperties(endpointDefinition, elem); return endpointDefinition; }
/** * Core method which is exposed for the external use, and this will find the proper * {@link EndpointFactory} and create the endpoint which is of the format {@link Endpoint}. * * @param elem XML from which the endpoint will be built * @param isAnonymous whether this is an anonymous endpoint or not * @param properties bag of properties to pass in any information to the factory * @return created endpoint */ public static Endpoint getEndpointFromElement(OMElement elem, boolean isAnonymous, Properties properties) { return getEndpointFactory(elem).createEndpointWithName(elem, isAnonymous, properties); }
/** * Creates an EndpointDefinition instance using the XML fragment specification. Configuration * for EndpointDefinition always resides inside a configuration of an AddressEndpoint. This * factory extracts the details related to the EPR provided for address endpoint. * * @param elem XML configuration element * @return EndpointDefinition object containing the endpoint details. */ public EndpointDefinition createEndpointDefinition(OMElement elem) { DefinitionFactory fac = getEndpointDefinitionFactory(); EndpointDefinition endpointDefinition; if (fac == null) { fac = new EndpointDefinitionFactory(); endpointDefinition = fac.createDefinition(elem); } else{ endpointDefinition = fac.createDefinition(elem); } extractSpecificEndpointProperties(endpointDefinition, elem); return endpointDefinition; }
public void testAddressEndpointScenarioOne() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" />" + "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,true,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
public void testClassEndpointScenarioOne() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<class name=\"org.apache.synapse.config.xml.endpoints.CustomClassEndpoint\"/>" + "</endpoint>"; OMElement inputElement = createOMElement(inputXML); ClassEndpoint endpoint = (ClassEndpoint) ClassEndpointFactory.getEndpointFromElement(inputElement, true, null); OMElement serializedOut = ClassEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut, inputElement)); }
public void test() throws Exception { String inputXml = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<recipientlist>" + "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<http uri-template=\"URI Template\" method=\"GET\" />" + "</endpoint>" + "</recipientlist>" + "</endpoint>"; OMElement inputElement = createOMElement(inputXml); RecipientListEndpoint endpoint = (RecipientListEndpoint) RecipientListEndpointFactory .getEndpointFromElement(inputElement, true, null); OMElement serializedResponse = RecipientListEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue("Endpoint not serialized!", compare(serializedResponse, inputElement)); } }
@Test public void test() throws Exception { String inputXml = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<default format=\"soap11\" />" + "</endpoint>"; OMElement inputElement = createOMElement(inputXml); DefaultEndpoint endpoint = (DefaultEndpoint) DefaultEndpointFactory .getEndpointFromElement(inputElement, true, null); OMElement serializedResponse = DefaultEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue("Endpoint not serialized!", compare(serializedResponse, inputElement)); } }
public void test() throws Exception { String inputXml = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<http uri-template=\"URI Template\" method=\"GET\" />" + "</endpoint>"; OMElement inputElement = AXIOMUtil.stringToOM(inputXml); HTTPEndpoint endpoint = (HTTPEndpoint) HTTPEndpointFactory.getEndpointFromElement(inputElement, true, null); OMElement serializedResponse = HTTPEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue("Endpoint not serialized!", compare(serializedResponse, inputElement)); } }
public OMElement serializeEndpointDefinition(EndpointDefinition endpointDefinition) { EndpointDefinitionSerializer serializer = new EndpointDefinitionSerializer(); OMElement element = fac.createOMElement("default", SynapseConstants.SYNAPSE_OMNAMESPACE); serializer.serializeEndpointDefinition(endpointDefinition, element); serializeSpecificEndpointProperties(endpointDefinition, element); return element; } }
/** * Core method which is exposed for the external use, and this will find the proper * {@link EndpointFactory} and create the endpoint which is of the format {@link Endpoint}.However * definition for this endpoint will be built using a custom Endpoint Defn factory. * * @param elem XML from which the endpoint will be built * @param factory custom definition factory which this endpoint will be used to build * @param isAnonymous whether this is an anonymous endpoint or not * @param properties bag of properties to pass in any information to the factory * @return created endpoint */ public static Endpoint getEndpointFromElement(OMElement elem,DefinitionFactory factory, boolean isAnonymous, Properties properties) { EndpointFactory fac = getEndpointFactory(elem); fac.setEndpointDefinitionFactory(factory); return fac.createEndpointWithName(elem, isAnonymous, properties); }
@Override public OMElement serializeEndpointDefinition(EndpointDefinition endpointDefinition) { OMElement element = fac.createOMElement("http", SynapseConstants.SYNAPSE_OMNAMESPACE); EndpointDefinitionSerializer serializer = new EndpointDefinitionSerializer(); serializer.serializeEndpointDefinition(endpointDefinition, element); serializeSpecificEndpointProperties(endpointDefinition, element); return element; } }
/** * Creates the {@link Endpoint} object from the provided {@link OMNode} * * @param om XML node from which the endpoint will be built * @param properties bag of properties to pass in any information to the factory * @return created endpoint as an {@link Object} */ public Object getObjectFromOMNode(OMNode om, Properties properties) { if (om instanceof OMElement) { return createEndpointWithName((OMElement) om, false, properties); } else { handleException("Invalid XML configuration for an Endpoint. OMElement expected"); } return null; }
public void testAddressEndpointScenarioTwo() throws Exception { String inputXML = "<endpoint name=\"testEndpoint\" onError=\"foo\" xmlns=" + "\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>"+ "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,false,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
public void testClassEndpointScenarioTwo() throws Exception { String inputXML = "<endpoint name=\"testEndpoint\" xmlns=" + "\"http://ws.apache.org/ns/synapse\">" + "<class name=\"org.apache.synapse.config.xml.endpoints.CustomClassEndpoint\"/>" + "</endpoint>"; OMElement inputElement = createOMElement(inputXML); ClassEndpoint endpoint = (ClassEndpoint) ClassEndpointFactory.getEndpointFromElement( inputElement,false,null); OMElement serializedOut = ClassEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
/** * Creates an EndpointDefinition instance using the XML fragment specification. Configuration * for EndpointDefinition always resides inside a configuration of an AddressEndpoint. This * factory extracts the details related to the EPR provided for address endpoint. * * @param elem XML configuration element * @return EndpointDefinition object containing the endpoint details. */ public EndpointDefinition createEndpointDefinition(OMElement elem) { DefinitionFactory fac = getEndpointDefinitionFactory(); EndpointDefinition endpointDefinition; if (fac == null) { fac = new EndpointDefinitionFactory(); endpointDefinition = fac.createDefinition(elem); } else{ endpointDefinition = fac.createDefinition(elem); } extractSpecificEndpointProperties(endpointDefinition, elem); return endpointDefinition; }
public OMElement serializeEndpointDefinition(EndpointDefinition endpointDefinition) { EndpointDefinitionSerializer serializer = new EndpointDefinitionSerializer(); OMElement element = fac.createOMElement("default", SynapseConstants.SYNAPSE_OMNAMESPACE); serializer.serializeEndpointDefinition(endpointDefinition, element); serializeSpecificEndpointProperties(endpointDefinition, element); return element; } }
/** * Core method which is exposed for the external use, and this will find the proper * {@link EndpointFactory} and create the endpoint which is of the format {@link Endpoint}. * * @param elem XML from which the endpoint will be built * @param isAnonymous whether this is an anonymous endpoint or not * @param properties bag of properties to pass in any information to the factory * @return created endpoint */ public static Endpoint getEndpointFromElement(OMElement elem, boolean isAnonymous, Properties properties) { return getEndpointFactory(elem).createEndpointWithName(elem, isAnonymous, properties); }
/** * Creates the {@link Endpoint} object from the provided {@link OMNode} * * @param om XML node from which the endpoint will be built * @param properties bag of properties to pass in any information to the factory * @return created endpoint as an {@link Object} */ public Object getObjectFromOMNode(OMNode om, Properties properties) { if (om instanceof OMElement) { return createEndpointWithName((OMElement) om, false, properties); } else { handleException("Invalid XML configuration for an Endpoint. OMElement expected"); } return null; }
public void testAddressEndpointScenarioFour() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>"+ "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement, true, null); //assertNotNull(endpoint.getName()); // make sure we generate names for anonymous endpoints OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); // the generated name should not show up in the serialization assertTrue(compare(serializedOut,inputElement)); }
public void testClassEndpointScenarioThree() throws Exception { String inputXML = "<endpoint name=\"testEndpoint\" xmlns=" + "\"http://ws.apache.org/ns/synapse\">" + "<class name=\"org.apache.synapse.config.xml.endpoints.CustomClassEndpoint\">" + "<parameter xmlns=" + "\"\" name=\"foo\">XYZ</parameter>" + "</class>" + "</endpoint>"; OMElement inputElement = createOMElement(inputXML); ClassEndpoint endpoint = (ClassEndpoint) ClassEndpointFactory.getEndpointFromElement( inputElement,false,null); OMElement serializedOut = ClassEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }