Author: asankha
Date: Mon Nov 20 23:13:55 2006
New Revision: 477536
URL: http://svn.apache.org/viewvc?view=rev&rev=477536
Log:
Committing for ruwan
Added:
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_104.xml
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SendMediatorFactory.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseModule.java
incubator/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_1.wsdl
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_101.xml
incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
Mon Nov 20 23:13:55 2006
@@ -51,6 +51,9 @@
*/
String CORRELATE = "correlate/";
+ /** An string name which holds the out sequence property in the
MessageContext */
+ String OUT_SEQUENCE = "outSequence";
+
/** A key with this name on the message context set to Boolean.TRUE,
indicates that this is a response */
String ISRESPONSE_PROPERTY = "synapse.isresponse";
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
Mon Nov 20 23:13:55 2006
@@ -25,8 +25,8 @@
import org.apache.synapse.Mediator;
import org.apache.synapse.core.axis2.ProxyService;
import org.apache.synapse.registry.Registry;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import javax.xml.stream.XMLStreamReader;
@@ -71,7 +71,7 @@
private Object mainMediator = null;
/** Hold reference to the Axis2 ConfigurationContext */
- private ConfigurationContext configContext = null;
+ private AxisConfiguration axisConfig = null;
/** Save the path to the configuration file loaded, to save it later */
private String pathToConfigFile = null;
@@ -349,8 +349,8 @@
handleException("Invalid proxyService for name : " + name + " from
registry");
} else {
try {
-
getConfigurationContext().getAxisConfiguration().getService(name).setActive(false);
-
getConfigurationContext().getAxisConfiguration().removeService(name);
+
getAxisConfiguration().getAxisConfiguration().getService(name).setActive(false);
+
getAxisConfiguration().getAxisConfiguration().removeService(name);
proxyServices.remove(name);
} catch (AxisFault axisFault) {
handleException(axisFault.getMessage());
@@ -434,19 +434,19 @@
}
/**
- * Set the Axis2 ConfigurationContext to the SynapseConfiguration
- * @param configContext
+ * Set the Axis2 AxisConfiguration to the SynapseConfiguration
+ * @param axisConfig
*/
- public void setConfigurationContext(ConfigurationContext configContext) {
- this.configContext = configContext;
+ public void setAxisConfiguration(AxisConfiguration axisConfig) {
+ this.axisConfig = axisConfig;
}
/**
- * Get the Axis2 ConfigurationContext for the SynapseConfiguration
- * @return ConfigurationContext of the Axis2
+ * Get the Axis2 AxisConfiguration for the SynapseConfiguration
+ * @return AxisConfiguration of the Axis2
*/
- public ConfigurationContext getConfigurationContext() {
- return configContext;
+ public AxisConfiguration getAxisConfiguration() {
+ return axisConfig;
}
private void handleException(String msg) {
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointFactory.java
Mon Nov 20 23:13:55 2006
@@ -53,21 +53,34 @@
private EndpointFactory() {}
- public static Endpoint createEndpoint(OMElement elem) {
+ public static Endpoint createEndpoint(OMElement elem, boolean
anonymousEndpoint) {
+
OMAttribute name = elem.getAttribute(new
QName(Constants.NULL_NAMESPACE, "name"));
- if (name == null) {
- handleException("The 'name' attribute is required for a named
endpoint definition");
- } else {
+ OMAttribute address = elem.getAttribute(new
QName(Constants.NULL_NAMESPACE, "address"));
Endpoint endpoint = new Endpoint();
- endpoint.setName(name.getAttributeValue());
-
- OMAttribute address = elem.getAttribute(new
QName(Constants.NULL_NAMESPACE, "address"));
- if (address != null) {
+ if(!anonymousEndpoint) {
+ if (name == null) {
+ handleException("The 'name' attribute is required for a
named endpoint definition");
+ } else {
+ endpoint.setName(name.getAttributeValue());
+ }
+ if (address != null) {
endpoint.setAddress(address.getAttributeValue());
+ } else {
+ // right now an address is *required*
+ handleException("The 'address' attribute is required for
an endpoint");
+ }
} else {
- // right now an address is *required*
- handleException("The 'address' attribute is required for an
endpoint");
+ OMAttribute reference = elem.getAttribute(new
QName(Constants.NULL_NAMESPACE, "ref"));
+ if(reference != null) {
+ endpoint.setRef(reference.getAttributeValue());
+ } else if (address != null) {
+ endpoint.setAddress(address.getAttributeValue());
+ } else {
+ handleException("One of the 'address' or 'ref' attributes
are required in an " +
+ "anonymous endpoint");
+ }
}
OMElement wsAddr = elem.getFirstChildWithName(
@@ -97,8 +110,7 @@
}
return endpoint;
- }
- return null;
+// }
}
private static void handleException(String msg) {
@@ -113,7 +125,7 @@
public Object getObjectFromOMNode(OMNode om) {
if (om instanceof OMElement) {
- return createEndpoint((OMElement) om);
+ return createEndpoint((OMElement) om, false);
} else {
handleException("Invalid XML configuration for an Endpoint.
OMElement expected");
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceFactory.java
Mon Nov 20 23:13:55 2006
@@ -77,7 +77,8 @@
}
}
- OMAttribute startOnLoad = elem.getAttribute(new
QName(Constants.NULL_NAMESPACE, "startOnLoad"));
+ OMAttribute startOnLoad = elem.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, "startOnLoad"));
if(startOnLoad != null) {
proxy.setStartOnLoad(Boolean.valueOf(startOnLoad.getAttributeValue()).booleanValue());
} else {
@@ -87,13 +88,21 @@
// 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(Constants.SYNAPSE_NAMESPACE, "target"));
+ OMElement target = elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "target"));
if (target != null) {
- OMAttribute sequence = target.getAttribute(new
QName(Constants.NULL_NAMESPACE, "sequence"));
- if (sequence != null) {
- proxy.setTargetSequence(sequence.getAttributeValue());
+ OMAttribute inSequence = target.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, "inSequence"));
+ if (inSequence != null) {
+ proxy.setTargetInSequence(inSequence.getAttributeValue());
}
- OMAttribute tgtEndpt = target.getAttribute(new
QName(Constants.NULL_NAMESPACE, "endpoint"));
+ OMAttribute outSequence = target.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, "outSequence"));
+ if (outSequence != null) {
+ proxy.setTargetOutSequence(outSequence.getAttributeValue());
+ }
+ OMAttribute tgtEndpt = target.getAttribute(
+ new QName(Constants.NULL_NAMESPACE, "endpoint"));
if (tgtEndpt != null) {
proxy.setTargetEndpoint(tgtEndpt.getAttributeValue());
}
@@ -110,8 +119,10 @@
}
}
- //OMElement schema = elem.getFirstChildWithName(new
QName(Constants.SYNAPSE_NAMESPACE, "schema"));
- Iterator policies = elem.getChildrenWithName(new
QName(Constants.SYNAPSE_NAMESPACE, "policy"));
+// OMElement schema = elem.getFirstChildWithName(
+// new QName(Constants.SYNAPSE_NAMESPACE, "schema"));
+ Iterator policies = elem.getChildrenWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "policy"));
while (policies.hasNext()) {
Object o = policies.next();
if (o instanceof OMElement) {
@@ -127,7 +138,8 @@
}
}
- Iterator props = elem.getChildrenWithName(new
QName(Constants.SYNAPSE_NAMESPACE, "property"));
+ Iterator props = elem.getChildrenWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "property"));
while (props.hasNext()) {
Object o = props.next();
if (o instanceof OMElement) {
@@ -144,14 +156,15 @@
}
}
- if (elem.getFirstChildWithName(new QName(Constants.SYNAPSE_NAMESPACE,
"enableRM")) != null) {
+ if (elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "enableRM")) != null) {
proxy.setWsRMEnabled(true);
}
- if (elem.getFirstChildWithName(new QName(Constants.SYNAPSE_NAMESPACE,
"enableSec")) != null) {
+ if (elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "enableSec")) != null) {
proxy.setWsSecEnabled(true);
}
-
return proxy;
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/ProxyServiceSerializer.java
Mon Nov 20 23:13:55 2006
@@ -87,10 +87,14 @@
target.addAttribute(fac.createOMAttribute(
"endpoint", nullNS, service.getTargetEndpoint()));
proxy.addChild(target);
- } else if (service.getTargetSequence() != null) {
+ } else if (service.getTargetInSequence() != null ||
service.getTargetOutSequence() != null) {
OMElement target = fac.createOMElement("target", synNS);
- target.addAttribute(fac.createOMAttribute(
- "sequence", nullNS, service.getTargetSequence()));
+ if (service.getTargetInSequence() != null) {
+ target.addAttribute(fac.createOMAttribute("inSequence",
nullNS, service.getTargetInSequence()));
+ }
+ if (service.getTargetOutSequence() != null) {
+ target.addAttribute(fac.createOMAttribute("outSequence",
nullNS, service.getTargetOutSequence()));
+ }
proxy.addChild(target);
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SendMediatorFactory.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SendMediatorFactory.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SendMediatorFactory.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SendMediatorFactory.java
Mon Nov 20 23:13:55 2006
@@ -83,9 +83,6 @@
private static final QName SEND_Q = new QName(Constants.SYNAPSE_NAMESPACE,
"send");
- private static final QName ATT_REF_Q = new QName(Constants.NULL_NAMESPACE,
"ref");
- private static final QName ATT_ADDRESS_Q = new
QName(Constants.NULL_NAMESPACE, "address");
-
public Mediator createMediator(OMElement elem) {
SendMediator sm = new SendMediator();
@@ -94,23 +91,7 @@
while (iter.hasNext()) {
OMElement endptElem = (OMElement) iter.next();
- OMAttribute ref = endptElem.getAttribute(ATT_REF_Q);
- OMAttribute address = endptElem.getAttribute(ATT_ADDRESS_Q);
-
- Endpoint endpt = new Endpoint();
- if (ref != null) {
- endpt.setRef(ref.getAttributeValue());
- } else if (address != null) {
-
- endpt.setAddress(address.getAttributeValue());
-
- } else {
- String msg = "An endpoint used within a send mediator
definition must contain a " +
- "'ref' (reference) or 'address' (absolute URL) attribute";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
+ Endpoint endpt = EndpointFactory.createEndpoint(endptElem, true);
sm.addEndpoint(endpt);
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
Mon Nov 20 23:13:55 2006
@@ -214,7 +214,7 @@
dp.setMapper(EndpointFactory.getInstance());
config.addNamedEndpoint(name.getAttributeValue(), dp);
} else {
- Endpoint endpoint = EndpointFactory.createEndpoint(ele);
+ Endpoint endpoint = EndpointFactory.createEndpoint(ele, false);
// add this endpoint to the configuration
config.addNamedEndpoint(endpoint.getName(), endpoint);
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2Sender.java
Mon Nov 20 23:13:55 2006
@@ -103,6 +103,12 @@
}
}
+ // sets the out sequence if present to the out MC to mediate
the response
+ if(synapseInMessageContext.getProperty(Constants.OUT_SEQUENCE)
!= null) {
+
synapseOutMessageContext.setProperty(Constants.OUT_SEQUENCE,
+
synapseInMessageContext.getProperty(Constants.OUT_SEQUENCE));
+ }
+
// send the response message through the synapse mediation flow
synapseInMessageContext.getEnvironment().
injectMessage(synapseOutMessageContext);
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
Mon Nov 20 23:13:55 2006
@@ -24,6 +24,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.Constants;
+import org.apache.synapse.Mediator;
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.core.SynapseEnvironment;
@@ -41,7 +43,8 @@
public Axis2SynapseEnvironment() {}
- public Axis2SynapseEnvironment(ConfigurationContext cfgCtx,
SynapseConfiguration synapseConfig) {
+ public Axis2SynapseEnvironment(ConfigurationContext cfgCtx,
+ SynapseConfiguration synapseConfig) {
this.cfgCtx = cfgCtx;
this.synapseConfig = synapseConfig;
threadFactory = cfgCtx.getThreadPool();
@@ -54,7 +57,24 @@
synCtx.getConfiguration().getMainMediator().mediate(synCtx);
}
});*/
- synCtx.getConfiguration().getMainMediator().mediate(synCtx);
+
+ // if the outSequence property is present use that for the message
mediation
+ // if not use the main mediator to mediate the outgoing message
+ if (synCtx.getProperty(Constants.OUT_SEQUENCE) != null) {
+ Mediator mediator = synCtx.getConfiguration().getNamedSequence(
+ (String)synCtx.getProperty(Constants.OUT_SEQUENCE));
+ // check weather the sequence specified with the property
outSequence is availabel
+ if(mediator != null) {
+ log.debug("Using the outSequence " +
synCtx.getProperty(Constants.OUT_SEQUENCE)
+ + " for the out message mediation");
+ mediator.mediate(synCtx);
+ } else {
+ log.error("Sequence named " +
synCtx.getProperty(Constants.OUT_SEQUENCE)
+ + " doesn't exists in synapse");
+ }
+ } else {
+ synCtx.getConfiguration().getMainMediator().mediate(synCtx);
+ }
}
public void send(MessageContext synCtx) {
@@ -65,7 +85,8 @@
}
public MessageContext createMessageContext() {
- org.apache.axis2.context.MessageContext axis2MC = new
org.apache.axis2.context.MessageContext();
+ org.apache.axis2.context.MessageContext axis2MC
+ = new org.apache.axis2.context.MessageContext();
MessageContext mc = new Axis2MessageContext(axis2MC, synapseConfig,
this);
return mc;
}
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
Mon Nov 20 23:13:55 2006
@@ -24,7 +24,6 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.*;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.jms.JMSConstants;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,7 +38,6 @@
import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
import java.util.*;
/**
@@ -65,8 +63,10 @@
private ArrayList transports;
/** The target endpoint, if assigned */
private String targetEndpoint = null;
- /** The target sequence, if assigned */
- private String targetSequence = null;
+ /** The target inSequence, if assigned */
+ private String targetInSequence = null;
+ /** The target outSequence, if assigned */
+ private String targetOutSequence = null;
// if a target endpoint or sequence is not specified,
// the default Synapse main mediator will be used
/** A list properties */
@@ -98,7 +98,8 @@
try {
InputStream wsdlInputStream =
Util.getInputStream(synCfg.getProperty(wsdlKey));
// detect version of the WSDL 1.1 or 2.0
- OMNamespace documentElementNS = new
StAXOMBuilder(wsdlInputStream).getDocumentElement().getNamespace();
+ OMNamespace documentElementNS = new StAXOMBuilder(
+ wsdlInputStream).getDocumentElement().getNamespace();
wsdlInputStream =
Util.getInputStream(synCfg.getProperty(wsdlKey));
@@ -118,7 +119,8 @@
}
if (wsdlToAxisServiceBuilder == null) {
- throw new SynapseException("Could not get the WSDL to
Axis Service Builder");
+ throw new SynapseException(
+ "Could not get the WSDL to Axis Service
Builder");
}
proxyService = wsdlToAxisServiceBuilder.populateService();
proxyService.setWsdlFound(true);
@@ -130,9 +132,11 @@
} catch (XMLStreamException e) {
handleException("Error reading WSDL defined by registry key :
" + wsdlKey, e);
} catch (AxisFault af) {
- handleException("Error building service from WSDL defined by
registry key : " + wsdlKey, af);
+ handleException("Error building service from WSDL defined by
registry key : "
+ + wsdlKey, af);
} catch (IOException ioe) {
- handleException("Error reading WSDL from WSDL defined by
registry key : " + wsdlKey, ioe);
+ handleException("Error reading WSDL from WSDL defined by
registry key : "
+ + wsdlKey, ioe);
}
} else {
// this is for POX... create a dummy service and an operation for
which
@@ -207,8 +211,13 @@
msgRcvr.setName(name);
if (targetEndpoint != null) {
msgRcvr.setTargetEndpoint(targetEndpoint);
- } else if (targetSequence != null) {
- msgRcvr.setTargetSequence(targetSequence);
+ } else {
+ if (targetInSequence != null) {
+ msgRcvr.setTargetInSequence(targetInSequence);
+ }
+ if (targetOutSequence != null) {
+ msgRcvr.setTargetOutSequence(targetOutSequence);
+ }
}
iter = proxyService.getOperations();
@@ -227,7 +236,8 @@
// should RM be engaged on this service?
if (wsRMEnabled) {
try {
-
proxyService.engageModule(axisCfg.getModule(Constants.SANDESHA2_MODULE_NAME),
axisCfg);
+ proxyService.engageModule(axisCfg.getModule(
+ Constants.SANDESHA2_MODULE_NAME), axisCfg);
} catch (AxisFault axisFault) {
handleException("Error loading WS RM module on proxy service :
" + name, axisFault);
}
@@ -236,22 +246,24 @@
// should Security be engaged on this service?
if (wsSecEnabled) {
try {
-
proxyService.engageModule(axisCfg.getModule(Constants.RAMPART_MODULE_NAME),
axisCfg);
+ proxyService.engageModule(axisCfg.getModule(
+ Constants.RAMPART_MODULE_NAME), axisCfg);
} catch (AxisFault axisFault) {
- handleException("Error loading WS Sec module on proxy service
: " + name, axisFault);
+ handleException("Error loading WS Sec module on proxy service
: "
+ + name, axisFault);
}
}
return proxyService;
}
public void start(SynapseConfiguration synCfg) {
- AxisConfiguration axisConfig =
synCfg.getConfigurationContext().getAxisConfiguration();
+ AxisConfiguration axisConfig = synCfg.getAxisConfiguration();
axisConfig.getServiceForActivation(this.getName()).setActive(true);
this.setRunning(true);
}
public void stop(SynapseConfiguration synCfg) {
- AxisConfiguration axisConfig =
synCfg.getConfigurationContext().getAxisConfiguration();
+ AxisConfiguration axisConfig =
synCfg.getAxisConfiguration().getAxisConfiguration();
try {
axisConfig.getService(this.getName()).setActive(false);
this.setRunning(false);
@@ -300,12 +312,20 @@
this.targetEndpoint = targetEndpoint;
}
- public String getTargetSequence() {
- return targetSequence;
+ public String getTargetInSequence() {
+ return targetInSequence;
+ }
+
+ public void setTargetInSequence(String targetInSequence) {
+ this.targetInSequence = targetInSequence;
+ }
+
+ public String getTargetOutSequence() {
+ return targetOutSequence;
}
- public void setTargetSequence(String targetSequence) {
- this.targetSequence = targetSequence;
+ public void setTargetOutSequence(String targetOutSequence) {
+ this.targetOutSequence = targetOutSequence;
}
public String getWSDLKey() {
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
Mon Nov 20 23:13:55 2006
@@ -46,11 +46,17 @@
*/
private String targetEndpoint = null;
/**
- * A target sequence name specifies to Synapse to use the given named
sequence for
- * message mediation. If a target endpoint or sequence is not specified,
the default
- * main mediator would be used for mediation.
+ * A target inSequence name specifies to Synapse to use the given named
sequence for
+ * message mediation for incoming messages. If a target endpoint or
inSequence is not
+ * specified, the default main mediator would be used for incoming message
mediation.
*/
- private String targetSequence = null;
+ private String targetInSequence = null;
+ /**
+ * A target outSequence name specifies to Synapse to use the given named
sequence for
+ * message mediation for outgoing messages. If a target endpoint or
outSequence is not
+ * specified, the default main mediator would be used for outgoing message
mediation.
+ */
+ private String targetOutSequence = null;
public void receive(org.apache.axis2.context.MessageContext mc) throws
AxisFault {
@@ -68,7 +74,8 @@
Endpoint endpoint =
synCtx.getConfiguration().getNamedEndpoint(targetEndpoint);
if (endpoint == null) {
// what else can/should we do instead of just logging the
message as an error?
- log.error("The endpoint named '" + targetEndpoint + "' is not
defined. Dropping current message");
+ log.error("The endpoint named '" + targetEndpoint
+ + "' is not defined. Dropping current message");
} else {
synCtx.setTo(new EndpointReference(endpoint.getAddress()));
log.debug("Forwarding message directly to the endpoint named :
" + targetEndpoint);
@@ -85,45 +92,61 @@
axisOutMsgContext.setServerSide(true);
axisOutMsgContext.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_OUT,
-
axisInMsgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_OUT));
+ axisInMsgContext.getProperty(
+
org.apache.axis2.context.MessageContext.TRANSPORT_OUT));
axisOutMsgContext.setTransportIn(axisInMsgContext.getTransportIn());
- // TODO this may be really strange but true.. unless you call
the below, sometimes it
- // results in an unbound URI exception for no credible reason
- needs more investigation
- // seems like a woodstox issue. Use hack for now
+ // TODO this may be really strange but true.. unless you call
the below, sometimes
+ // it results in an unbound URI exception for no credible
reason - needs more
+ // investigation seems like a woodstox issue. Use hack for now
axisOutMsgContext.getEnvelope().build();
log.debug("Reply Body : \n" + axisOutMsgContext.getEnvelope());
AxisEngine ae = new
AxisEngine(axisOutMsgContext.getConfigurationContext());
try {
-
axisOutMsgContext.setProperty(org.apache.synapse.Constants.ISRESPONSE_PROPERTY,
Boolean.TRUE);
-
mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
Constants.VALUE_TRUE);
+ axisOutMsgContext.setProperty(
+ org.apache.synapse.Constants.ISRESPONSE_PROPERTY,
Boolean.TRUE);
+ mc.getOperationContext().setProperty(
+ Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
// check for addressing is alredy engaged for this message.
// if engage we should use the address enable Configuraion
context.
ae.send(axisOutMsgContext);
} catch (AxisFault e) {
- log.error("Axis fault encountered while forwarding message
to endpoint : " + targetEndpoint, e);
+ log.error("Axis fault encountered while forwarding message
to endpoint : "
+ + targetEndpoint, e);
}
}
- // if a named sequence is specified, use it for message mediation
- } else if (targetSequence != null) {
- Mediator mediator =
synCtx.getConfiguration().getNamedSequence(targetSequence);
- if (mediator == null) {
- // what else can/should we do instead of just logging the
message as an error?
- log.error("The mediator named '" + targetSequence + "' is not
defined. Dropping current message");
- } else {
- log.debug("Using sequence named : " + targetSequence + " for
message mediation");
- mediator.mediate(synCtx);
+ } else {
+
+ // if a named outSequence os specified set it as a property to the
MessageContext
+ if (targetOutSequence != null) {
+ log.debug("OutSequence " + targetOutSequence
+ + " for the proxy set to the MessageContext");
+ synCtx.setProperty(org.apache.synapse.Constants.OUT_SEQUENCE,
targetOutSequence);
}
- // else default to the Synapse main mediator
- } else {
- log.debug("Using default 'main' mediator for message mediation");
- synCtx.getEnvironment().injectMessage(synCtx);
+ // if a named inSequence is specified, use it for message mediation
+ if (targetInSequence != null) {
+ Mediator mediator =
synCtx.getConfiguration().getNamedSequence(targetInSequence);
+ if (mediator == null) {
+ // what else can/should we do instead of just logging the
message as an error?
+ log.error("The mediator named '" + targetInSequence
+ + "' is not defined. Dropping current message");
+ } else {
+ log.debug("Using sequence named : " + targetInSequence
+ + " for message mediation");
+ mediator.mediate(synCtx);
+ }
+
+ // else default to the Synapse main mediator
+ } else {
+ log.debug("Using default 'main' mediator for message
mediation");
+ synCtx.getEnvironment().injectMessage(synCtx);
+ }
}
// Response handling mechanism for 200/202 and 5XX
@@ -149,11 +172,19 @@
}
/**
- * Specify a named target sequence to be used for message mediation
- * @param targetSequence the name of the target sequence to be used
+ * Specify a named target sequence to be used for message mediation for
incoming messages
+ * @param targetInSequence the name of the target sequence to be used for
incoming messages
+ */
+ public void setTargetInSequence(String targetInSequence) {
+ this.targetInSequence = targetInSequence;
+ }
+
+ /**
+ * Specify a named target sequence to be used for message mediation for
outgoing messages
+ * @param targetOutSequence the name of the target sequence to be used for
outgoing messages
*/
- public void setTargetSequence(String targetSequence) {
- this.targetSequence = targetSequence;
+ public void setTargetOutSequence(String targetOutSequence) {
+ this.targetOutSequence = targetOutSequence;
}
/**
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseModule.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseModule.java?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseModule.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseModule.java
Mon Nov 20 23:13:55 2006
@@ -114,7 +114,7 @@
}
// Set the Axis2 ConfigurationContext to the SynapseConfiguration
- synapseConfiguration.setConfigurationContext(cfgCtx);
+
synapseConfiguration.setAxisConfiguration(cfgCtx.getAxisConfiguration());
// set the Synapse configuration and environment into the Axis2
configuration
Parameter synapseCtxParam = new Parameter(Constants.SYNAPSE_CONFIG,
null);
Modified:
incubator/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_1.wsdl
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_1.wsdl?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
---
incubator/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_1.wsdl
(original)
+++
incubator/synapse/trunk/java/repository/conf/sample/resources/proxy/sample_proxy_1.wsdl
Mon Nov 20 23:13:55 2006
@@ -1,3 +1,22 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
<wsdl:definitions xmlns:axis2="http://services.samples"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
Modified:
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_101.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_101.xml?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_101.xml
(original)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_101.xml
Mon Nov 20 23:13:55 2006
@@ -36,7 +36,7 @@
<proxies>
<proxy name="StockQuoteProxy1">
<wsdl key="proxy_wsdl"/>
- <target sequence="proxy_1"/>
+ <target inSequence="proxy_1"/>
</proxy>
<proxy name="StockQuoteProxy2">
Added:
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_104.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_104.xml?view=auto&rev=477536
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_104.xml
(added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_104.xml
Mon Nov 20 23:13:55 2006
@@ -0,0 +1,49 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- using custom sequences for incoming and outgoing message mediation
with proxy services -->
+ <definitions>
+ <set-property name="proxy_wsdl"
src="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
+
+ <sequence name="proxy_in">
+ <send>
+ <endpoint
address="http://localhost:9000/axis2/services/SimpleStockQuoteService"/>
+ </send>
+ </sequence>
+
+ <sequence name="proxy_out">
+ <send/>
+ </sequence>
+
+ </definitions>
+
+ <proxies>
+ <proxy name="StockQuoteProxy">
+ <wsdl key="proxy_wsdl"/>
+ <target inSequence="proxy_in" outSequence="proxy_out"/>
+ </proxy>
+ </proxies>
+
+ <rules>
+ <send/>
+ </rules>
+
+</synapse>
\ No newline at end of file
Modified: incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=477536&r1=477535&r2=477536
==============================================================================
--- incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
(original)
+++ incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html Mon
Nov 20 23:13:55 2006
@@ -604,6 +604,29 @@
href="sample_103_2.txt">sample_103_2.txt</a></p>
<pre></pre>
+<h2>Sample 104:</h2>
+
+<p><strong>Objective: Using an explicit out sequence in proxy service level
+to mediate proxy response</strong></p>
+
+<p><strong>Pre-Requisites:</strong><br>
+Start the Synapse configuration numbered 104: i.e. synapse -sample 104 <br>
+Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
+above)</p>
+
+<p>This configuration creates a proxy service with the name StockQuoteProxy.
This proxy service
+specifies both inSequence and the outSequence for that service. This will add
a proxy level out
+sequence to be used for the response message mediation of that particular
proxy service. You could
+leave the whole target element not specified or one of the sequences of in and
out unspecified,
+so that the corresponding message will be mediated using main mediator.</p>
+
+<p>You could send a stock quote request to this proxy services and receive the
reply generated
+by the actual service hosted on the Axis2 instance. Use the -Durl=<EPR>
property when
+executing the client as per example 100, to request on this proxy service.</p>
+
+<p>You can observe the synapse log to see the response message mediation using
the specified
+outSequence, unlike using MainMediator in the sample 100 case.</p>
+
<h2>Sample 110:</h2>
<p><strong>Objective: Introduction to switching transports with proxy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]