org.apache.synapse.config.xml.endpoints
Class EndpointFactory

java.lang.Object
  extended by org.apache.synapse.config.xml.endpoints.EndpointFactory
All Implemented Interfaces:
XMLToObjectMapper
Direct Known Subclasses:
DefaultEndpointFactory, DynamicLoadbalanceEndpointFactory, FailoverEndpointFactory, IndirectEndpointFactory, LoadbalanceEndpointFactory, RecipientListEndpointFactory, ResolvingEndpointFactory, SALoadbalanceEndpointFactory, TemplateEndpointFactory

public abstract class EndpointFactory
extends Object
implements XMLToObjectMapper

All endpoint factories should extend from this abstract class. Use EndpointFactory to obtain the correct endpoint for particular endpoint configuration. As endpoints can be nested inside each other, EndpointFactory implementations may call other EndpointFactory implementations recursively to obtain the required endpoint hierarchy.

This also serves as the XMLToObjectMapper implementation for specific endpoint implementations. If the endpoint type is not known use XMLToEndpointMapper as the generic XMLToObjectMapper for all endpoints.


Field Summary
static QName ON_FAULT_Q
           
 
Constructor Summary
protected EndpointFactory()
           
 
Method Summary
protected abstract  Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties)
          Creates the Endpoint implementation for the given XML endpoint configuration.
protected  void extractSpecificEndpointProperties(EndpointDefinition definition, OMElement elem)
           
 DefinitionFactory getEndpointDefinitionFactory()
          return current factory for building this endpoint definition
static Endpoint getEndpointFromElement(OMElement elem, boolean isAnonymous, Properties properties)
          Core method which is exposed for the external use, and this will find the proper EndpointFactory and create the endpoint which is of the format Endpoint.
static Endpoint getEndpointFromElement(OMElement elem, DefinitionFactory factory, boolean isAnonymous, Properties properties)
          Core method which is exposed for the external use, and this will find the proper EndpointFactory and create the endpoint which is of the format Endpoint.However definition for this endpoint will be built using a custom Endpoint Defn factory.
protected  ArrayList<Endpoint> getEndpoints(OMElement listEndpointElement, Endpoint parent, Properties properties)
          Helper method to construct children endpoints
 Object getObjectFromOMNode(OMNode om, Properties properties)
          Creates the Endpoint object from the provided OMNode
protected static void handleException(String msg)
           
protected static void handleException(String msg, Exception e)
           
protected  void processProperties(PropertyInclude endpoint, OMElement endpointElement)
          Helper method to extract endpoint properties.
 void setEndpointDefinitionFactory(DefinitionFactory factory)
          provide a custom Endpoint definition factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ON_FAULT_Q

public static final QName ON_FAULT_Q
Constructor Detail

EndpointFactory

protected EndpointFactory()
Method Detail

getEndpointFromElement

public static Endpoint getEndpointFromElement(OMElement elem,
                                              boolean isAnonymous,
                                              Properties properties)
Core method which is exposed for the external use, and this will find the proper EndpointFactory and create the endpoint which is of the format Endpoint.

Parameters:
elem - XML from which the endpoint will be built
isAnonymous - whether this is an anonymous endpoint or not
properties - bag of properties to pass in any information to the factory
Returns:
created endpoint

getEndpointFromElement

public static Endpoint getEndpointFromElement(OMElement elem,
                                              DefinitionFactory factory,
                                              boolean isAnonymous,
                                              Properties properties)
Core method which is exposed for the external use, and this will find the proper EndpointFactory and create the endpoint which is of the format Endpoint.However definition for this endpoint will be built using a custom Endpoint Defn factory.

Parameters:
elem - XML from which the endpoint will be built
factory - custom definition factory which this endpoint will be used to build
isAnonymous - whether this is an anonymous endpoint or not
properties - bag of properties to pass in any information to the factory
Returns:
created endpoint

getObjectFromOMNode

public Object getObjectFromOMNode(OMNode om,
                                  Properties properties)
Creates the Endpoint object from the provided OMNode

Specified by:
getObjectFromOMNode in interface XMLToObjectMapper
Parameters:
om - XML node from which the endpoint will be built
properties - bag of properties to pass in any information to the factory
Returns:
created endpoint as an Object

createEndpoint

protected abstract Endpoint createEndpoint(OMElement epConfig,
                                           boolean anonymousEndpoint,
                                           Properties properties)
Creates the Endpoint implementation for the given XML endpoint configuration. If the endpoint configuration is an inline one, it should be an anonymous endpoint. If it is defined as an immediate child element of the definitions tag it should have a name, which is used as the key in local registry.

Parameters:
epConfig - OMElement containing the endpoint configuration.
anonymousEndpoint - false if the endpoint has a name. true otherwise.
properties - bag of properties to pass in any information to the factory
Returns:
Endpoint implementation for the given configuration.

extractSpecificEndpointProperties

protected void extractSpecificEndpointProperties(EndpointDefinition definition,
                                                 OMElement elem)

getEndpoints

protected ArrayList<Endpoint> getEndpoints(OMElement listEndpointElement,
                                           Endpoint parent,
                                           Properties properties)
Helper method to construct children endpoints

Parameters:
listEndpointElement - OMElement representing the children endpoints
parent - Parent endpoint
properties - bag of properties to pass in any information to the factory
Returns:
List of children endpoints

setEndpointDefinitionFactory

public void setEndpointDefinitionFactory(DefinitionFactory factory)
provide a custom Endpoint definition factory

Parameters:
factory -

getEndpointDefinitionFactory

public DefinitionFactory getEndpointDefinitionFactory()
return current factory for building this endpoint definition

Returns:

processProperties

protected void processProperties(PropertyInclude endpoint,
                                 OMElement endpointElement)
Helper method to extract endpoint properties.

Parameters:
endpoint - actual endpoint to set the properties
endpointElement - actual endpoint element

handleException

protected static void handleException(String msg)

handleException

protected static void handleException(String msg,
                                      Exception e)


Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.