use of org.apache.synapse.core.axis2.ProxyService in project wso2-synapse by wso2.
the class ProxyDebugUtil method registerProxySequenceMediationFlowSkip.
/**
* Registers/Un-registers a skip, point where mediator disables from medation flow
*
* @param synCfg Synapse configuration
* @param seqType Synapse sequence type
* @param proxyKey name of the Proxy Service
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerProxySequenceMediationFlowSkip(SynapseConfiguration synCfg, String seqType, String proxyKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(seqType.toUpperCase());
SequenceMediationFlowPoint skipPoint = new SequenceMediationFlowPoint();
skipPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
skipPoint.setKey(proxyKey);
skipPoint.setMediatorPosition(position);
skipPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
skipPoint.setSynapseSequenceType(synapseSequenceType);
Mediator seqMediator = null;
ProxyService proxy = null;
proxy = synCfg.getProxyService(proxyKey);
if (proxy != null) {
if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
seqMediator = proxy.getTargetInLineInSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
seqMediator = proxy.getTargetInLineOutSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
seqMediator = proxy.getTargetInLineFaultSequence();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Non existing Proxy for key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_NOT_FOUND).toString());
return;
}
if (seqMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
if (current_mediator != null) {
skipPoint.setMediatorReference(current_mediator);
if (registerMode) {
if (!((AbstractMediator) current_mediator).isSkipEnabled()) {
((AbstractMediator) current_mediator).setSkipEnabled(true);
((AbstractMediator) current_mediator).registerMediationFlowPoint(skipPoint);
if (log.isDebugEnabled()) {
log.debug("Registered skip at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Already skip enabled at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_ENABLED).toString());
}
} else {
if (((AbstractMediator) current_mediator).isSkipEnabled()) {
((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
((AbstractMediator) current_mediator).setSkipEnabled(false);
if (log.isDebugEnabled()) {
log.debug("Unregistered skip at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Already skip disabled at mediator position " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_SKIP_DISABLED).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing mediator position at " + logMediatorPosition(skipPoint) + " for Proxy key " + skipPoint.getKey() + " Sequence " + skipPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register skip. Non existing sequence " + skipPoint.getSynapseSequenceType().toString() + " for Proxy key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister skip. Non existing sequence " + skipPoint.getSynapseSequenceType().toString() + " for Proxy key " + skipPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.core.axis2.ProxyService in project wso2-synapse by wso2.
the class ProxyDebugUtil method registerProxySequenceMediationFlowBreakPoint.
/**
* Registers/Un-registers a breakpoint, point where mediation flow get suspended
*
* @param synCfg Synapse configuration
* @param sequenceType Synapse sequence type
* @param proxyKey name of the Proxy Service
* @param position array of integers that uniquely specifies a point in mediation route
* @param registerMode specify whether register or un register
*/
public static void registerProxySequenceMediationFlowBreakPoint(SynapseConfiguration synCfg, String sequenceType, String proxyKey, int[] position, boolean registerMode) {
SynapseSequenceType synapseSequenceType = SynapseSequenceType.valueOf(sequenceType.toUpperCase());
SequenceMediationFlowPoint breakPoint = new SequenceMediationFlowPoint();
breakPoint.setSynapseMediationComponent(SynapseMediationComponent.SEQUENCE);
breakPoint.setKey(proxyKey);
breakPoint.setMediatorPosition(position);
breakPoint.setSequenceBaseType(SynapseDebugCommandConstants.DEBUG_COMMAND_MEDIATION_COMPONENT_SEQUENCE_PROXY);
breakPoint.setSynapseSequenceType(synapseSequenceType);
Mediator seqMediator = null;
ProxyService proxy = null;
proxy = synCfg.getProxyService(proxyKey);
if (proxy != null) {
if (synapseSequenceType.equals(SynapseSequenceType.PROXY_INSEQ)) {
seqMediator = proxy.getTargetInLineInSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_OUTSEQ)) {
seqMediator = proxy.getTargetInLineOutSequence();
} else if (synapseSequenceType.equals(SynapseSequenceType.PROXY_FAULTSEQ)) {
seqMediator = proxy.getTargetInLineFaultSequence();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Non existing Proxy for the key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_PROXY_NOT_FOUND).toString());
return;
}
if (seqMediator != null) {
Mediator current_mediator = null;
current_mediator = MediatorTreeTraverseUtil.getMediatorReference(synCfg, seqMediator, position);
if (current_mediator != null) {
breakPoint.setMediatorReference(current_mediator);
if (registerMode) {
if (!((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).setBreakPoint(true);
((AbstractMediator) current_mediator).registerMediationFlowPoint(breakPoint);
if (log.isDebugEnabled()) {
log.debug("Registered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Already breakpoint enabled at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_ENABLED).toString());
}
} else {
if (((AbstractMediator) current_mediator).isBreakPoint()) {
((AbstractMediator) current_mediator).unregisterMediationFlowPoint();
((AbstractMediator) current_mediator).setBreakPoint(false);
if (log.isDebugEnabled()) {
log.debug("Unregistered breakpoint at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(true, null).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Already breakpoint disabled at mediator position " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_ALREADY_BREAKPOINT_DISABLED).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing mediator position at " + logMediatorPosition(breakPoint) + " for Proxy key " + breakPoint.getKey() + " Sequence " + breakPoint.getSynapseSequenceType().toString());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_MEDIATOR_POSITION).toString());
}
}
} else {
if (registerMode) {
if (log.isDebugEnabled()) {
log.debug("Failed register breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Proxy key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
} else {
if (log.isDebugEnabled()) {
log.debug("Failed unregister breakpoint. Non existing sequence " + breakPoint.getSynapseSequenceType().toString() + " for Proxy key " + breakPoint.getKey());
}
debugManager.advertiseCommandResponse(debugManager.createDebugCommandResponse(false, SynapseDebugCommandConstants.DEBUG_COMMAND_RESPONSE_NON_EXISTING_SEQUENCE).toString());
}
}
}
use of org.apache.synapse.core.axis2.ProxyService in project wso2-synapse by wso2.
the class ContinuationStackManager method pushRootFaultHandlerForSequence.
/**
* Find the correct root fault handler for named sequences.
*
* If the message is initiated from a proxy, we need to assign the proxy fault sequence.
* If the message is initiated from a API Resource, we need to assign the resource fault sequence.
*
* @param synCtx message context
*/
private static void pushRootFaultHandlerForSequence(MessageContext synCtx) {
// For Proxy services
String proxyName = (String) synCtx.getProperty(SynapseConstants.PROXY_SERVICE);
if (proxyName != null && !"".equals(proxyName)) {
ProxyService proxyService = synCtx.getConfiguration().getProxyService(proxyName);
if (proxyService != null) {
proxyService.registerFaultHandler(synCtx);
} else {
handleException("Proxy service : " + proxyName + " not found");
}
return;
}
// For APIs
String apiName = (String) synCtx.getProperty(RESTConstants.SYNAPSE_REST_API);
if (apiName != null && !"".equals(apiName)) {
API api = synCtx.getEnvironment().getSynapseConfiguration().getAPI(apiName);
if (api != null) {
String resourceName = (String) synCtx.getProperty(RESTConstants.SYNAPSE_RESOURCE);
Resource resource = api.getResource(resourceName);
if (resource != null) {
resource.registerFaultHandler(synCtx);
} else {
handleException("Resource : " + resourceName + " not found");
}
} else {
handleException("REST API : " + apiName + " not found");
}
return;
}
// For main sequence/MessageInjector etc, push the default fault handler
synCtx.pushFaultHandler(new MediatorFaultHandler(synCtx.getFaultSequence()));
}
use of org.apache.synapse.core.axis2.ProxyService in project wso2-synapse by wso2.
the class ProxyServiceFactory method createProxy.
public static ProxyService createProxy(OMElement elem, Properties properties) {
ProxyService proxy = null;
OMAttribute name = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name == null) {
handleException("The 'name' attribute is required for a Proxy service definition");
} else {
proxy = new ProxyService(name.getAttributeValue());
}
OMAttribute trans = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "transports"));
if (trans != null) {
String transports = trans.getAttributeValue();
if (transports == null || ProxyService.ALL_TRANSPORTS.equals(transports)) {
// default to all transports using service name as destination
} else {
StringTokenizer st = new StringTokenizer(transports, " ,");
ArrayList<String> transportList = new ArrayList<String>();
while (st.hasMoreTokens()) {
String token = st.nextToken();
if (token.length() != 0) {
transportList.add(token);
}
}
proxy.setTransports(transportList);
}
}
OMAttribute pinnedServers = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "pinnedServers"));
if (pinnedServers != null) {
String pinnedServersValue = pinnedServers.getAttributeValue();
if (pinnedServersValue == null) {
// default to all servers
} else {
StringTokenizer st = new StringTokenizer(pinnedServersValue, " ,");
List<String> pinnedServersList = new ArrayList<String>();
while (st.hasMoreTokens()) {
String token = st.nextToken();
if (token.length() != 0) {
pinnedServersList.add(token);
}
}
proxy.setPinnedServers(pinnedServersList);
}
}
OMAttribute startOnLoad = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "startOnLoad"));
if (startOnLoad != null) {
proxy.setStartOnLoad(Boolean.valueOf(startOnLoad.getAttributeValue()));
} else {
proxy.setStartOnLoad(true);
}
OMAttribute serviceGroup = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "serviceGroup"));
if (serviceGroup != null) {
proxy.setServiceGroup(serviceGroup.getAttributeValue());
}
// setting the description of the proxy service
OMElement descriptionElement = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "description"));
if (descriptionElement != null) {
proxy.setDescription(descriptionElement.getText().trim());
}
// read definition of the target of this proxy service. The target could be an 'endpoint'
// or a named sequence. If none of these are specified, the messages would be mediated
// by the Synapse main mediator
OMElement target = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "target"));
if (target != null) {
boolean isTargetOk = false;
SequenceMediatorFactory mediatorFactory = new SequenceMediatorFactory();
OMAttribute inSequence = target.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "inSequence"));
if (inSequence != null) {
proxy.setTargetInSequence(inSequence.getAttributeValue());
isTargetOk = true;
} else {
OMElement inSequenceElement = target.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "inSequence"));
if (inSequenceElement != null) {
SequenceMediator inSequenceMediator = mediatorFactory.createAnonymousSequence(inSequenceElement, properties);
inSequenceMediator.setSequenceType(SequenceType.PROXY_INSEQ);
proxy.setTargetInLineInSequence(inSequenceMediator);
isTargetOk = true;
}
}
OMAttribute outSequence = target.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "outSequence"));
if (outSequence != null) {
proxy.setTargetOutSequence(outSequence.getAttributeValue());
} else {
OMElement outSequenceElement = target.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "outSequence"));
if (outSequenceElement != null) {
SequenceMediator outSequenceMediator = mediatorFactory.createAnonymousSequence(outSequenceElement, properties);
outSequenceMediator.setSequenceType(SequenceType.PROXY_OUTSEQ);
proxy.setTargetInLineOutSequence(outSequenceMediator);
}
}
OMAttribute faultSequence = target.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "faultSequence"));
if (faultSequence != null) {
proxy.setTargetFaultSequence(faultSequence.getAttributeValue());
} else {
OMElement faultSequenceElement = target.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "faultSequence"));
if (faultSequenceElement != null) {
SequenceMediator faultSequenceMediator = mediatorFactory.createAnonymousSequence(faultSequenceElement, properties);
faultSequenceMediator.setSequenceType(SequenceType.PROXY_FAULTSEQ);
proxy.setTargetInLineFaultSequence(faultSequenceMediator);
}
}
OMAttribute tgtEndpt = target.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "endpoint"));
if (tgtEndpt != null) {
proxy.setTargetEndpoint(tgtEndpt.getAttributeValue());
isTargetOk = true;
} else {
OMElement endpointElement = target.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "endpoint"));
if (endpointElement != null) {
proxy.setTargetInLineEndpoint(EndpointFactory.getEndpointFromElement(endpointElement, true, properties));
isTargetOk = true;
}
}
if (!isTargetOk) {
handleException("Target of the proxy service must declare " + "either an inSequence or endpoint or both");
}
} else {
handleException("Target is required for a Proxy service definition");
}
// read the WSDL, Schemas and Policies and set to the proxy service
OMElement wsdl = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "publishWSDL"));
if (wsdl != null) {
OMAttribute wsdlEndpoint = wsdl.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "endpoint"));
OMAttribute wsdlKey = wsdl.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
OMAttribute preservePolicy = wsdl.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "preservePolicy"));
if (preservePolicy != null) {
proxy.setPreservePolicy(preservePolicy.getAttributeValue());
}
if (wsdlEndpoint != null) {
proxy.setPublishWSDLEndpoint(wsdlEndpoint.getAttributeValue());
} else if (wsdlKey != null) {
proxy.setWSDLKey(wsdlKey.getAttributeValue());
} else {
OMAttribute wsdlURI = wsdl.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "uri"));
if (wsdlURI != null) {
try {
proxy.setWsdlURI(new URI(wsdlURI.getAttributeValue()));
} catch (URISyntaxException e) {
String msg = "Error creating uri for proxy service wsdl";
log.error(msg);
handleException(msg, e);
}
} else {
OMElement wsdl11 = wsdl.getFirstChildWithName(new QName(WSDLConstants.WSDL1_1_NAMESPACE, "definitions"));
if (wsdl11 != null) {
proxy.setInLineWSDL(wsdl11);
} else {
OMElement wsdl20 = wsdl.getFirstChildWithName(new QName(WSDL2Constants.WSDL_NAMESPACE, "description"));
if (wsdl20 != null) {
proxy.setInLineWSDL(wsdl20);
}
}
}
}
proxy.setResourceMap(ResourceMapFactory.createResourceMap(wsdl));
}
Iterator policies = elem.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "policy"));
while (policies.hasNext()) {
Object o = policies.next();
if (o instanceof OMElement) {
OMElement policy = (OMElement) o;
OMAttribute key = policy.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));
OMAttribute type = policy.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "type"));
OMAttribute operationName = policy.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "operationName"));
OMAttribute operationNS = policy.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "operationNamespace"));
if (key != null) {
PolicyInfo pi = new PolicyInfo(key.getAttributeValue());
if (type != null && type.getAttributeValue() != null) {
if ("in".equals(type.getAttributeValue())) {
pi.setType(PolicyInfo.MESSAGE_TYPE_IN);
} else if ("out".equals(type.getAttributeValue())) {
pi.setType(PolicyInfo.MESSAGE_TYPE_OUT);
} else {
handleException("Undefined policy type for the policy with key : " + key.getAttributeValue());
}
}
if (operationName != null && operationName.getAttributeValue() != null) {
if (operationNS != null && operationNS.getAttributeValue() != null) {
pi.setOperation(new QName(operationNS.getAttributeValue(), operationName.getAttributeValue()));
} else {
pi.setOperation(new QName(operationName.getAttributeValue()));
}
}
proxy.addPolicyInfo(pi);
} else {
handleException("Policy element does not specify the policy key");
}
} else {
handleException("Invalid 'policy' element found under element 'policies'");
}
}
String nameString = proxy.getName();
if (nameString == null || "".equals(nameString)) {
nameString = SynapseConstants.ANONYMOUS_PROXYSERVICE;
}
AspectConfiguration aspectConfiguration = new AspectConfiguration(nameString);
proxy.configure(aspectConfiguration);
OMAttribute statistics = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.STATISTICS_ATTRIB_NAME));
if (statistics != null) {
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if (XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
aspectConfiguration.enableStatistics();
}
}
}
OMAttribute tracing = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.TRACE_ATTRIB_NAME));
if (tracing != null) {
String tracingValue = tracing.getAttributeValue();
if (tracingValue != null) {
if (XMLConfigConstants.TRACE_ENABLE.equals(tracingValue)) {
aspectConfiguration.enableTracing();
}
}
}
Iterator props = elem.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "parameter"));
while (props.hasNext()) {
Object o = props.next();
if (o instanceof OMElement) {
OMElement prop = (OMElement) o;
OMAttribute pname = prop.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
OMElement propertyValue = prop.getFirstElement();
if (pname != null) {
if (propertyValue != null) {
proxy.addParameter(pname.getAttributeValue(), propertyValue);
} else {
proxy.addParameter(pname.getAttributeValue(), prop.getText().trim());
}
} else {
handleException("Invalid property specified for proxy service : " + name);
}
} else {
handleException("Invalid property specified for proxy service : " + name);
}
}
if (elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "enableAddressing")) != null) {
proxy.setWsAddrEnabled(true);
}
if (elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "enableSec")) != null) {
proxy.setWsSecEnabled(true);
}
return proxy;
}
use of org.apache.synapse.core.axis2.ProxyService in project wso2-synapse by wso2.
the class MultiXMLConfigurationSerializerTest method testSerializeSynapseXML3.
/**
* Test serializeSynapseXML method with proxyServices added for SynapseConfiguration and
* assert synapse.xml is created.
*/
@Test
public void testSerializeSynapseXML3() throws Exception {
MultiXMLConfigurationSerializer serializer = new MultiXMLConfigurationSerializer(TEST_DIRECTORY_NAME);
SynapseConfiguration configuration = new SynapseConfiguration();
configuration.setTaskManager(new QuartzTaskManager());
ProxyService proxyService = new ProxyService("testProxyService");
configuration.addProxyService(proxyService.getName(), proxyService);
serializer.serializeSynapseXML(configuration);
Assert.assertTrue("Error in serializing Synapse configuration.", new File(TEST_DIRECTORY_NAME + File.separator + SYNAPSE_XML).exists());
removeTestFolder(TEST_DIRECTORY_NAME);
}
Aggregations