protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint,
Properties properties) {
// create the endpoint, manager and the algorithms
SALoadbalanceEndpoint loadbalanceEndpoint = new SALoadbalanceEndpoint();
// get the session for this endpoint
OMElement sessionElement = epConfig.
getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "session"));
if (sessionElement != null) {
OMElement sessionTimeout = sessionElement.getFirstChildWithName(
new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sessionTimeout"));
if (sessionTimeout != null) {
try {
loadbalanceEndpoint.setSessionTimeout(Long.parseLong(
sessionTimeout.getText().trim()));
} catch (NumberFormatException nfe) {
handleException("Invalid session timeout value : " + sessionTimeout.getText());
}
}
String type = sessionElement.getAttributeValue(new QName("type"));
if (type.equalsIgnoreCase("soap")) {
Dispatcher soapDispatcher = new SoapSessionDispatcher();
loadbalanceEndpoint.setDispatcher(soapDispatcher);
} else if (type.equalsIgnoreCase("http")) {
Dispatcher httpDispatcher = new HttpSessionDispatcher();
loadbalanceEndpoint.setDispatcher(httpDispatcher);
} else if (type.equalsIgnoreCase("simpleClientSession")) {
Dispatcher csDispatcher = new SimpleClientSessionDispatcher();
loadbalanceEndpoint.setDispatcher(csDispatcher);
}
} else {
handleException("Session affinity endpoints should " +
"have a session element in the configuration.");
}
// set endpoint name
OMAttribute name = epConfig.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name != null) {
loadbalanceEndpoint.setName(name.getAttributeValue());
}
OMElement loadbalanceElement;
loadbalanceElement = epConfig.getFirstChildWithName
(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "loadbalance"));
if(loadbalanceElement != null) {
// set endpoints
List<Endpoint> endpoints = getEndpoints(loadbalanceElement,
loadbalanceEndpoint, properties);
loadbalanceEndpoint.setChildren(endpoints);
// set load balance algorithm
LoadbalanceAlgorithm algorithm = LoadbalanceAlgorithmFactory.
createLoadbalanceAlgorithm(loadbalanceElement, endpoints);
loadbalanceEndpoint.setAlgorithm(algorithm);
// process the parameters
processProperties(loadbalanceEndpoint, epConfig);
return loadbalanceEndpoint;