use of org.apache.synapse.endpoints.DefaultEndpoint in project wso2-synapse by wso2.
the class CallMediator method handleBlockingCall.
/**
* Send request in blocking manner
*
* @param synInCtx message context
* @return continue the mediation flow or not
*/
private boolean handleBlockingCall(MessageContext synInCtx) {
SynapseLog synLog = getLog(synInCtx);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Start : Call mediator - Blocking Call");
if (synLog.isTraceTraceEnabled()) {
synLog.traceTrace("Message : " + synInCtx.getEnvelope());
}
}
MessageContext resultMsgCtx = null;
// set initClientOption with blockingMsgsender
blockingMsgSender.setInitClientOptions(initClientOptions);
// blocking sender.
if (endpoint == null) {
endpoint = new DefaultEndpoint();
EndpointDefinition endpointDefinition = new EndpointDefinition();
((DefaultEndpoint) endpoint).setDefinition(endpointDefinition);
isWrappingEndpointCreated = true;
}
try {
if ("true".equals(synInCtx.getProperty(SynapseConstants.OUT_ONLY))) {
blockingMsgSender.send(endpoint, synInCtx);
} else {
resultMsgCtx = blockingMsgSender.send(endpoint, synInCtx);
if ("true".equals(resultMsgCtx.getProperty(SynapseConstants.BLOCKING_SENDER_ERROR))) {
handleFault(synInCtx, (Exception) resultMsgCtx.getProperty(SynapseConstants.ERROR_EXCEPTION));
}
}
} catch (Exception ex) {
handleFault(synInCtx, ex);
}
if (resultMsgCtx != null) {
if (synLog.isTraceTraceEnabled()) {
synLog.traceTrace("Response payload received : " + resultMsgCtx.getEnvelope());
}
try {
synInCtx.setEnvelope(resultMsgCtx.getEnvelope());
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("End : Call mediator - Blocking Call");
}
return true;
} catch (Exception e) {
handleFault(synInCtx, e);
}
} else {
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Service returned a null response");
}
}
return true;
}
use of org.apache.synapse.endpoints.DefaultEndpoint in project wso2-synapse by wso2.
the class StatisticSynapseConfigurationObserverTest method testEndpointAdded.
/**
* Test EndpointAdded by hash generation.
*/
@Test
public void testEndpointAdded() {
DefaultEndpoint endpoint = new DefaultEndpoint();
observer.endpointAdded(endpoint);
Assert.assertNotNull("New hash must be set by the method", endpoint.getDefinition().getAspectConfiguration().getHashCode());
}
use of org.apache.synapse.endpoints.DefaultEndpoint in project wso2-synapse by wso2.
the class DefaultEndpointSerializer method serializeEndpoint.
protected OMElement serializeEndpoint(Endpoint endpoint) {
if (!(endpoint instanceof DefaultEndpoint)) {
handleException("Invalid endpoint type.");
}
fac = OMAbstractFactory.getOMFactory();
OMElement endpointElement = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE);
DefaultEndpoint defaultEndpoint = (DefaultEndpoint) endpoint;
serializeCommonAttributes(defaultEndpoint, endpointElement);
EndpointDefinition epAddress = defaultEndpoint.getDefinition();
OMElement defaultElement = serializeEndpointDefinition(epAddress);
endpointElement.addChild(defaultElement);
// serialize the properties
serializeProperties(defaultEndpoint, endpointElement);
return endpointElement;
}
use of org.apache.synapse.endpoints.DefaultEndpoint in project wso2-synapse by wso2.
the class DefaultEndpointFactory method createEndpoint.
protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties) {
DefaultEndpoint defaultEndpoint = new DefaultEndpoint();
OMAttribute name = epConfig.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name != null) {
defaultEndpoint.setName(name.getAttributeValue());
}
OMElement defaultElement = epConfig.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "default"));
if (defaultElement != null) {
EndpointDefinition endpoint = createEndpointDefinition(defaultElement);
defaultEndpoint.setDefinition(endpoint);
processAuditStatus(endpoint, defaultEndpoint.getName(), defaultElement);
}
processProperties(defaultEndpoint, epConfig);
return defaultEndpoint;
}
use of org.apache.synapse.endpoints.DefaultEndpoint in project wso2-synapse by wso2.
the class CalloutMediator method init.
public void init(SynapseEnvironment synEnv) {
try {
configCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientRepository != null ? clientRepository : DEFAULT_CLIENT_REPO, axis2xml != null ? axis2xml : DEFAULT_AXIS2_XML);
if (serviceURL != null) {
serviceURL = changeEndPointReference(serviceURL);
}
blockingMsgSender = new BlockingMsgSender();
blockingMsgSender.setConfigurationContext(configCtx);
blockingMsgSender.init();
EndpointDefinition endpointDefinition = null;
if (serviceURL != null) {
// If Service URL is specified, it is given the highest priority
endpoint = new AddressEndpoint();
endpointDefinition = new EndpointDefinition();
endpointDefinition.setAddress(serviceURL);
((AddressEndpoint) endpoint).setDefinition(endpointDefinition);
isWrappingEndpointCreated = true;
} else if (endpoint == null && endpointKey == null) {
// Use a default endpoint in this case - i.e. the To header
endpoint = new DefaultEndpoint();
endpointDefinition = new EndpointDefinition();
((DefaultEndpoint) endpoint).setDefinition(endpointDefinition);
isWrappingEndpointCreated = true;
}
if (endpointDefinition != null && isSecurityOn()) {
endpointDefinition.setSecurityOn(true);
if (wsSecPolicyKey != null) {
endpointDefinition.setWsSecPolicyKey(wsSecPolicyKey);
} else {
if (inboundWsSecPolicyKey != null) {
endpointDefinition.setInboundWsSecPolicyKey(inboundWsSecPolicyKey);
}
if (outboundWsSecPolicyKey != null) {
endpointDefinition.setOutboundWsSecPolicyKey(outboundWsSecPolicyKey);
}
}
}
} catch (AxisFault e) {
String msg = "Error initializing callout mediator : " + e.getMessage();
log.error(msg, e);
throw new SynapseException(msg, e);
}
}
Aggregations