Author: indika
Date: Wed Mar 11 10:30:17 2009
New Revision: 752419
URL: http://svn.apache.org/viewvc?rev=752419&view=rev
Log:
A minor refactoring as no functionally changes
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java?rev=752419&r1=752418&r2=752419&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
Wed Mar 11 10:30:17 2009
@@ -122,52 +122,28 @@
}
}
- // if this is a response to a proxy service
- if (synCtx.getProperty(SynapseConstants.PROXY_SERVICE) != null) {
-
- if (synCtx.getConfiguration().getProxyService((String)
synCtx.getProperty(
- SynapseConstants.PROXY_SERVICE)).getTargetOutSequence() !=
null) {
+ // if this is not a response to a proxy service
+ String proxyName = (String)
synCtx.getProperty(SynapseConstants.PROXY_SERVICE);
+ if (proxyName == null || "".equals(proxyName)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using Main Sequence for injected message");
+ }
+ return synCtx.getMainSequence().mediate(synCtx);
+ }
- String sequenceName =
synCtx.getConfiguration().getProxyService((String) synCtx.
-
getProperty(SynapseConstants.PROXY_SERVICE)).getTargetOutSequence();
- Mediator outSequence = synCtx.getSequence(sequenceName);
-
- if (outSequence != null) {
- if (log.isDebugEnabled()) {
- log.debug("Using the sequence named " + sequenceName
- + " for the outgoing message mediation of the
proxy service "
- +
synCtx.getProperty(SynapseConstants.PROXY_SERVICE));
- }
- outSequence.mediate(synCtx);
- } else {
- log.error("Unable to find the out-sequence " +
- "specified by the name " + sequenceName);
- throw new SynapseException("Unable to find the " +
- "out-sequence specified by the name " +
sequenceName);
- }
+ ProxyService proxyService =
synCtx.getConfiguration().getProxyService(proxyName);
+ if (proxyService != null) {
- } else if (synCtx.getConfiguration().getProxyService((String)
synCtx.getProperty(
-
SynapseConstants.PROXY_SERVICE)).getTargetInLineOutSequence() != null) {
- if (log.isDebugEnabled()) {
- log.debug("Using the anonymous out-sequence specified in
the proxy service "
- +
synCtx.getProperty(SynapseConstants.PROXY_SERVICE)
- + " for outgoing message mediation");
- }
- synCtx.getConfiguration().getProxyService((String)
synCtx.getProperty(
-
SynapseConstants.PROXY_SERVICE)).getTargetInLineOutSequence().mediate(synCtx);
+ Mediator outSequence = getProxyOutSequence(synCtx, proxyService);
+ if (outSequence != null) {
+ outSequence.mediate(synCtx);
} else {
if (log.isDebugEnabled()) {
- log.debug("Proxy service " +
synCtx.getProperty(SynapseConstants.PROXY_SERVICE)
+ log.debug(proxyService
+ " does not specifies an out-sequence - sending
the response back");
}
Axis2Sender.sendBack(synCtx);
}
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Using Main Sequence for injected message");
- }
- return synCtx.getMainSequence().mediate(synCtx);
}
return true;
}
@@ -353,4 +329,43 @@
throw new SynapseException(message, e);
}
+ /**
+ * Helper method to determine out sequence of the proxy service
+ *
+ * @param synCtx Current Message
+ * @param proxyService Proxy Service
+ * @return Out Sequence of the given proxy service, if there are any,
otherwise null
+ */
+ private Mediator getProxyOutSequence(MessageContext synCtx, ProxyService
proxyService) {
+ //TODO is it meaningful to move this method into proxy service or
+ //TODO a class that Strategically detects out sequence ?
+ String sequenceName = proxyService.getTargetOutSequence();
+ if (sequenceName != null && !"".equals(sequenceName)) {
+ Mediator outSequence = synCtx.getSequence(sequenceName);
+ if (outSequence != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the sequence named " + sequenceName
+ + " for the outgoing message mediation of the
proxy service "
+ + proxyService);
+ }
+ return outSequence;
+ } else {
+ log.error("Unable to find the out-sequence " +
+ "specified by the name " + sequenceName);
+ throw new SynapseException("Unable to find the " +
+ "out-sequence specified by the name " + sequenceName);
+ }
+ } else {
+ Mediator outSequence = proxyService.getTargetInLineOutSequence();
+ if (outSequence != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the anonymous out-sequence specified in
the proxy service "
+ + proxyService
+ + " for outgoing message mediation");
+ }
+ return outSequence;
+ }
+ }
+ return null;
+ }
}
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java?rev=752419&r1=752418&r2=752419&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
Wed Mar 11 10:30:17 2009
@@ -935,4 +935,11 @@
public void addPolicyInfo(PolicyInfo pi) {
this.policies.add(pi);
}
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("[ Proxy Service [ Name : ").append(name).append(" ] ]");
+ return sb.toString();
+ }
}