OMAttribute format = elem.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "format"));
OMAttribute optimize = elem.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "optimize"));
EndpointDefinition endpoint = new EndpointDefinition();
OMAttribute statistics = elem.getAttribute(
new QName(org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE,
org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_ATTRIB_NAME));
if (statistics != null) {
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if (org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_ENABLE.equals(
statisticsValue)) {
endpoint.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_ON);
} else if (org.apache.synapse.config.xml.XMLConfigConstants.STATISTICS_DISABLE.equals(
statisticsValue)) {
endpoint.setStatisticsState(org.apache.synapse.SynapseConstants.STATISTICS_OFF);
}
}
}
if (address != null) {
endpoint.setAddress(address.getAttributeValue());
// } else {
// handleException("One of the 'address' or 'ref' attributes are required in an "
// + "anonymous endpoint");
}
if (format != null)
{
String forceValue = format.getAttributeValue().trim().toLowerCase();
if (SynapseConstants.FORMAT_POX.equals(forceValue)) {
endpoint.setForcePOX(true);
endpoint.setFormat(SynapseConstants.FORMAT_POX);
} else if (SynapseConstants.FORMAT_GET.equals(forceValue)) {
endpoint.setForceGET(true);
endpoint.setFormat(SynapseConstants.FORMAT_GET);
} else if (SynapseConstants.FORMAT_SOAP11.equals(forceValue)) {
endpoint.setForceSOAP11(true);
endpoint.setFormat(SynapseConstants.FORMAT_SOAP11);
} else if (SynapseConstants.FORMAT_SOAP12.equals(forceValue)) {
endpoint.setForceSOAP12(true);
endpoint.setFormat(SynapseConstants.FORMAT_SOAP12);
} else {
handleException("unknown value -\""+forceValue+"\". Attribute 'format' accepts only 'pox', 'get', 'soap11', 'soap12'");
}
}
if (optimize != null && optimize.getAttributeValue().length() > 0) {
String method = optimize.getAttributeValue().trim();
if ("mtom".equalsIgnoreCase(method)) {
endpoint.setUseMTOM(true);
} else if ("swa".equalsIgnoreCase(method)) {
endpoint.setUseSwa(true);
}
}
OMElement wsAddr = elem.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "enableAddressing"));
if (wsAddr != null) {
endpoint.setAddressingOn(true);
String useSepList = wsAddr.getAttributeValue(new QName(
"separateListener"));
if (useSepList != null) {
if (useSepList.trim().toLowerCase().startsWith("tr")
|| useSepList.trim().startsWith("1")) {
endpoint.setUseSeparateListener(true);
}
}
}
OMElement wsSec = elem.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "enableSec"));
if (wsSec != null) {
endpoint.setSecurityOn(true);
OMAttribute policy = wsSec.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "policy"));
if (policy != null) {
endpoint.setWsSecPolicyKey(policy.getAttributeValue());
}
}
OMElement wsRm = elem.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "enableRM"));
if (wsRm != null) {
endpoint.setReliableMessagingOn(true);
OMAttribute policy = wsRm.getAttribute(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.NULL_NAMESPACE, "policy"));
if (policy != null) {
endpoint.setWsRMPolicyKey(policy.getAttributeValue());
}
}
// set the timeout configuration
OMElement timeout = elem.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "timeout"));
if (timeout != null) {
OMElement duration = timeout.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "duration"));
if (duration != null) {
String d = duration.getText();
if (d != null) {
try {
long timeoutSeconds = new Long(d.trim()).longValue();
endpoint.setTimeoutDuration(timeoutSeconds * 1000);
} catch (NumberFormatException e) {
handleException(
"The timeout seconds should be specified as a valid number :: "
+ e.getMessage(), e);
}
}
}
OMElement action = timeout.getFirstChildWithName(new QName(
org.apache.synapse.config.xml.XMLConfigConstants.SYNAPSE_NAMESPACE, "action"));
if (action != null) {
String a = action.getText();
if (a != null) {
if ((a.trim()).equalsIgnoreCase("discard")) {
endpoint.setTimeoutAction(SynapseConstants.DISCARD);
// set timeout duration to 30 seconds, if it is not set explicitly
if (endpoint.getTimeoutDuration() == 0) {
endpoint.setTimeoutDuration(30000);
}
} else if ((a.trim()).equalsIgnoreCase("fault")) {
endpoint.setTimeoutAction(SynapseConstants.DISCARD_AND_FAULT);
// set timeout duration to 30 seconds, if it is not set explicitly
if (endpoint.getTimeoutDuration() == 0) {
endpoint.setTimeoutDuration(30000);
}
}
}
}
}