use of org.apache.synapse.endpoints.Endpoint in project wso2-synapse by wso2.
the class CallMediatorSerializer method serializeSpecificMediator.
public OMElement serializeSpecificMediator(Mediator m) {
if (!(m instanceof CallMediator)) {
handleException("Unsupported mediator passed in for serialization : " + m.getType());
}
CallMediator mediator = (CallMediator) m;
OMElement call = fac.createOMElement("call", synNS);
saveTracingState(call, mediator);
Endpoint activeEndpoint = mediator.getEndpoint();
if (activeEndpoint != null) {
call.addChild(EndpointSerializer.getElementFromEndpoint(activeEndpoint));
}
if (mediator.isBlocking()) {
call.addAttribute(fac.createOMAttribute("blocking", nullNS, "true"));
if (!mediator.getInitClientOptions()) {
call.addAttribute(fac.createOMAttribute("initAxis2ClientOptions", nullNS, "false"));
}
if (mediator.getClientRepository() != null) {
call.addAttribute(fac.createOMAttribute("repository", nullNS, mediator.getClientRepository()));
}
if (mediator.getAxis2xml() != null) {
call.addAttribute(fac.createOMAttribute("axis2xml", nullNS, mediator.getAxis2xml()));
}
}
return call;
}
use of org.apache.synapse.endpoints.Endpoint in project wso2-synapse by wso2.
the class CalloutMediatorFactory method createSpecificMediator.
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
CalloutMediator callout = new CalloutMediator();
processAuditStatus(callout, elem);
OMAttribute attServiceURL = elem.getAttribute(ATT_URL);
OMAttribute attEndpoint = elem.getAttribute(ATT_ENDPOINT);
OMAttribute attAction = elem.getAttribute(ATT_ACTION);
OMAttribute attUseServerConfig = elem.getAttribute(ATT_USESERVERCONFIG);
OMAttribute initAxis2ClientOptions = elem.getAttribute(ATT_INIT_AXI2_CLIENT_OPTIONS);
OMElement configElt = elem.getFirstChildWithName(Q_CONFIG);
OMElement epElement = elem.getFirstChildWithName(Q_ENDPOINT);
OMElement sourceElt = elem.getFirstChildWithName(Q_SOURCE);
OMElement targetElt = elem.getFirstChildWithName(Q_TARGET);
OMElement wsSec = elem.getFirstChildWithName(Q_SEC);
if (attServiceURL != null) {
callout.setServiceURL(attServiceURL.getAttributeValue());
} else if (attEndpoint != null) {
callout.setEndpointKey(attEndpoint.getAttributeValue());
}
if (epElement != null) {
Endpoint endpoint = EndpointFactory.getEndpointFromElement(epElement, true, properties);
if (endpoint != null) {
callout.setEndpoint(endpoint);
}
}
if (attAction != null) {
callout.setAction(attAction.getAttributeValue());
}
if (attUseServerConfig != null) {
callout.setUseServerConfig(attUseServerConfig.getAttributeValue());
}
if (initAxis2ClientOptions != null) {
if ("true".equals(initAxis2ClientOptions.getAttributeValue().toLowerCase())) {
callout.setInitClientOptions(true);
} else if ("false".equals(initAxis2ClientOptions.getAttributeValue().toLowerCase())) {
callout.setInitClientOptions(false);
} else {
handleException("The 'initAxis2ClientOptions' attribute only accepts a boolean value.");
}
}
if (configElt != null) {
OMAttribute axis2xmlAttr = configElt.getAttribute(ATT_AXIS2XML);
OMAttribute repoAttr = configElt.getAttribute(ATT_REPOSITORY);
if (axis2xmlAttr != null && axis2xmlAttr.getAttributeValue() != null) {
File axis2xml = new File(axis2xmlAttr.getAttributeValue());
if (axis2xml.exists() && axis2xml.isFile()) {
callout.setAxis2xml(axis2xmlAttr.getAttributeValue());
} else {
handleException("Invalid axis2.xml path: " + axis2xmlAttr.getAttributeValue());
}
}
if (repoAttr != null && repoAttr.getAttributeValue() != null) {
File repo = new File(repoAttr.getAttributeValue());
if (repo.exists() && repo.isDirectory()) {
callout.setClientRepository(repoAttr.getAttributeValue());
} else {
handleException("Invalid repository path: " + repoAttr.getAttributeValue());
}
}
}
if (sourceElt != null) {
OMAttribute sourceType = sourceElt.getAttribute(ATT_SOURCE_TYPE);
if (sourceType != null && sourceType.getAttributeValue().equals("envelope")) {
callout.setUseEnvelopeAsSource(true);
} else if (sourceElt.getAttribute(ATT_XPATH) != null) {
try {
callout.setRequestXPath(SynapseXPathFactory.getSynapseXPath(sourceElt, ATT_XPATH));
} catch (JaxenException e) {
handleException("Invalid source XPath : " + sourceElt.getAttributeValue(ATT_XPATH));
}
} else if (sourceElt.getAttribute(ATT_KEY) != null) {
callout.setRequestKey(sourceElt.getAttributeValue(ATT_KEY));
} else {
handleException("A 'xpath' or 'key' attribute " + "is required for the Callout 'source'");
}
} else {
callout.setUseEnvelopeAsSource(true);
}
if (targetElt != null) {
if (targetElt.getAttribute(ATT_XPATH) != null) {
try {
callout.setTargetXPath(SynapseXPathFactory.getSynapseXPath(targetElt, ATT_XPATH));
} catch (JaxenException e) {
handleException("Invalid target XPath : " + targetElt.getAttributeValue(ATT_XPATH));
}
} else if (targetElt.getAttribute(ATT_KEY) != null) {
callout.setTargetKey(targetElt.getAttributeValue(ATT_KEY));
} else {
handleException("A 'xpath' or 'key' attribute " + "is required for the Callout 'target'");
}
}
if (wsSec != null) {
callout.setSecurityOn(true);
OMAttribute policyKey = wsSec.getAttribute(ATT_POLICY);
OMAttribute outboundPolicyKey = wsSec.getAttribute(ATT_OUTBOUND_SEC_POLICY);
OMAttribute inboundPolicyKey = wsSec.getAttribute(ATT_INBOUND_SEC_POLICY);
if (policyKey != null) {
callout.setWsSecPolicyKey(policyKey.getAttributeValue());
} else if (outboundPolicyKey != null || inboundPolicyKey != null) {
if (outboundPolicyKey != null) {
callout.setOutboundWsSecPolicyKey(outboundPolicyKey.getAttributeValue());
}
if (inboundPolicyKey != null) {
callout.setInboundWsSecPolicyKey(inboundPolicyKey.getAttributeValue());
}
} else {
callout.setSecurityOn(false);
handleException("A policy key is required to enable security");
}
}
return callout;
}
use of org.apache.synapse.endpoints.Endpoint in project wso2-synapse by wso2.
the class CloneMediator method destroy.
public void destroy() {
for (Target target : targets) {
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.destroy();
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) synapseEnv.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
synapseEnv.removeUnavailableArtifactRef(target.getSequenceRef());
}
}
Endpoint endpoint = target.getEndpoint();
if (endpoint != null) {
endpoint.destroy();
}
}
}
use of org.apache.synapse.endpoints.Endpoint in project wso2-synapse by wso2.
the class IterateMediator method init.
public void init(SynapseEnvironment se) {
synapseEnv = se;
if (target != null) {
Endpoint endpoint = target.getEndpoint();
if (endpoint != null) {
endpoint.init(se);
}
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.init(se);
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) se.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
se.addUnavailableArtifactRef(target.getSequenceRef());
}
}
}
}
use of org.apache.synapse.endpoints.Endpoint in project wso2-synapse by wso2.
the class IterateMediator method destroy.
public void destroy() {
if (target != null) {
Endpoint endpoint = target.getEndpoint();
if (endpoint != null && endpoint.isInitialized()) {
endpoint.destroy();
}
ManagedLifecycle seq = target.getSequence();
if (seq != null) {
seq.destroy();
} else if (target.getSequenceRef() != null) {
SequenceMediator targetSequence = (SequenceMediator) synapseEnv.getSynapseConfiguration().getSequence(target.getSequenceRef());
if (targetSequence == null || targetSequence.isDynamic()) {
synapseEnv.removeUnavailableArtifactRef(target.getSequenceRef());
}
}
}
}
Aggregations