You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2008/06/09 12:43:22 UTC
svn commit: r664672 [2/7] - in /synapse/trunk/java: ./ modules/core/
modules/core/src/main/java/org/apache/synapse/
modules/core/src/main/java/org/apache/synapse/config/
modules/core/src/main/java/org/apache/synapse/config/xml/
modules/core/src/main/ja...
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseStartUpServlet.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseStartUpServlet.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseStartUpServlet.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseStartUpServlet.java Mon Jun 9 03:43:19 2008
@@ -29,8 +29,7 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
/**
* When Synapse is deployed on a WAR container, this is the init servlet that kicks off the
@@ -40,105 +39,84 @@
public class SynapseStartUpServlet extends HttpServlet {
private static Log log = LogFactory.getLog(SynapseStartUpServlet.class);
+ private static final String ALREADY_INITED = "synapseAlreadyInited";
public void init() throws ServletException {
- super.init();
- }
-
- public void init(ServletConfig servletConfig) throws ServletException {
- ServerManager serverManager = ServerManager.getInstance();
- ServletContext servletContext = servletConfig.getServletContext();
- if ("true".equals(servletContext.getAttribute("hasAlreadyInit"))) {
+ ServletConfig servletConfig = getServletConfig();
+ ServletContext servletContext = servletConfig.getServletContext();
+ if (Boolean.TRUE.equals(servletContext.getAttribute(ALREADY_INITED))) {
return;
}
- String synapseHome = resolveSynapseHome(servletConfig);
- //Setting the all required system properties
- if (synapseHome != null) {
- if (synapseHome.endsWith(File.separator)) {
- synapseHome = synapseHome.substring(0, synapseHome.lastIndexOf(File.separator));
- }
- System.setProperty(SynapseConstants.SYNAPSE_HOME, synapseHome);
- //setting axis2 repository location
- String axis2Repo = System.getProperty(org.apache.axis2.Constants.AXIS2_REPO);
- if (axis2Repo == null) {
- ServerManager.getInstance().setAxis2Repolocation(synapseHome + "/WEB-INF" +
- File.separator + "repository");
- System.setProperty(org.apache.axis2.Constants.AXIS2_REPO,
- synapseHome + "/WEB-INF" +
- File.separator + "repository");
- }
- //setting axis2 configuration location
- String axis2Xml = System.getProperty(org.apache.axis2.Constants.AXIS2_CONF);
- if (axis2Xml == null) {
- System.setProperty(org.apache.axis2.Constants.AXIS2_CONF,
- synapseHome + File.separator
- + "WEB-INF/conf"
- + File.separator + org.apache.axis2.Constants.AXIS2_CONF);
- }
- //setting synapse configuration location
- String synapseXml = System.getProperty(org.apache.synapse.SynapseConstants.SYNAPSE_XML);
- if (synapseXml == null) {
- System.setProperty(org.apache.synapse.SynapseConstants.SYNAPSE_XML,
- synapseHome + File.separator
- + "WEB-INF/conf"
- + File.separator + org.apache.synapse.SynapseConstants.SYNAPSE_XML);
+ ServerManager serverManager = ServerManager.getInstance();
+ String synHome = loadParameter(servletConfig, SynapseConstants.SYNAPSE_HOME, false);
+
+ if (synHome == null) {
+ log.info("synapse.home not set; using web application root as default value");
+ String webinfPath = servletContext.getRealPath("WEB-INF");
+ if (webinfPath == null || !webinfPath.endsWith("WEB-INF")) {
+ handleException("Unable to determine web application root directory");
+ } else {
+ synHome = webinfPath.substring(0, webinfPath.length()-7);
+ log.info("Setting synapse.home to : " + synHome);
}
- } else {
- log.fatal("Can not resolve synapse home : startup failed");
- return;
}
+ serverManager.setSynapseHome(synHome);
+
+ serverManager.setSynapseXMLPath(loadParameter(servletConfig, SynapseConstants.SYNAPSE_XML, true));
+ String resolveRoot = loadParameter(servletConfig, SynapseConstants.RESOLVE_ROOT, false);
+ if (resolveRoot != null) {
+ serverManager.setResolveRoot(resolveRoot);
+ }
+ serverManager.setAxis2Repolocation(loadParameter(servletConfig, org.apache.axis2.Constants.AXIS2_REPO, true));
+ serverManager.setAxis2Xml(loadParameter(servletConfig, org.apache.axis2.Constants.AXIS2_CONF, true));
+ serverManager.setServerName(loadParameter(servletConfig, SynapseConstants.SERVER_NAME, false));
+
serverManager.start();
- servletContext.setAttribute("hasAlreadyInit", "true");
+ servletContext.setAttribute(ALREADY_INITED, Boolean.TRUE);
}
protected void doGet(HttpServletRequest request,
- HttpServletResponse response) throws ServletException,
- IOException {
+ HttpServletResponse response) throws ServletException, IOException {
}
protected void doPost(HttpServletRequest request,
- HttpServletResponse response) throws ServletException,
- IOException {
+ HttpServletResponse response) throws ServletException, IOException {
}
public void destroy() {
try {
ServerManager serverManager = ServerManager.getInstance();
- serverManager.stop(); // will stop all started listeners
- } catch (Exception ignored) {
+ serverManager.stop();
+ getServletContext().removeAttribute(ALREADY_INITED);
+ } catch (Exception e) {
+ log.error("Error stopping the Synapse listener manager", e);
}
}
- private String resolveSynapseHome(ServletConfig servletConfig) {
- // If synapse.home has provided as init-param,the it will take as synapse home
- String synapseHomeAsParam = servletConfig.getInitParameter(SynapseConstants.SYNAPSE_HOME);
- if (synapseHomeAsParam != null) {
- if (synapseHomeAsParam.endsWith(File.separator)) {
- return synapseHomeAsParam.substring(0,
- synapseHomeAsParam.lastIndexOf(File.separator));
+ private String loadParameter(ServletConfig servletConfig, String name, boolean required)
+ throws ServletException {
+
+ if (System.getProperty(name) == null) {
+
+ String value = servletConfig.getInitParameter(name);
+ log.debug("Init parameter '" + name + "' : " + value);
+
+ if ((value == null || value.trim().length() == 0) && required) {
+ handleException("A valid system property or init parameter '" + name + "' is required");
} else {
- return synapseHomeAsParam;
- }
- }
- //if synapse.home has set as a system property , then use it
- String synapseHome = System.getProperty(SynapseConstants.SYNAPSE_HOME);
- //Setting the all required system properties
- if (synapseHome == null || "".equals(synapseHome)) {
- ServletContext servletContext = servletConfig.getServletContext();
- //if synapse.home stil can not find ,then resolve it using real path of the WEB-INF
- String webinfPath = servletContext.getRealPath("WEB-INF");
- if (webinfPath != null) {
- synapseHome = webinfPath.substring(0, webinfPath.lastIndexOf("WEB-INF"));
- if (synapseHome != null) {
- if (synapseHome.endsWith(File.separator)) {
- synapseHome = synapseHome.substring(0,
- synapseHome.lastIndexOf(File.separator));
- }
- }
+ return value;
}
+ } else {
+ return System.getProperty(name);
}
- return synapseHome;
+ return null;
+ }
+
+ private void handleException(String message) throws ServletException {
+ log.error(message);
+ log(message);
+ throw new ServletException(message);
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/TimeoutHandler.java Mon Jun 9 03:43:19 2008
@@ -24,6 +24,7 @@
import org.apache.synapse.FaultHandler;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
+import org.apache.synapse.ServerManager;
import java.util.Iterator;
import java.util.Map;
@@ -59,10 +60,7 @@
public TimeoutHandler(Map callbacks) {
this.callbackStore = callbacks;
- try {
- globalTimeout = Long.parseLong(
- System.getProperty(SynapseConstants.GLOBAL_TIMEOUT_INTERVAL));
- } catch (Exception ignore) {}
+ globalTimeout = ServerManager.getInstance().getGlobalTimeoutInterval();
log.info("This engine will expire all callbacks after : " + (globalTimeout /1000) +
" seconds, irrespective of the timeout action, after the specified or optional timeout");
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AddressEndpoint.java Mon Jun 9 03:43:19 2008
@@ -21,67 +21,24 @@
import org.apache.axis2.clustering.ClusterManager;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.synapse.FaultHandler;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.endpoints.utils.EndpointDefinition;
import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
-import java.util.Stack;
-
/**
* This class represents an actual endpoint to send the message. It is responsible for sending the
* message, performing retries if a failure occurred and informing the parent endpoint if a failure
* couldn't be recovered.
*/
-public class AddressEndpoint extends FaultHandler implements Endpoint {
-
- private static final Log log = LogFactory.getLog(AddressEndpoint.class);
- private static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
-
- /**
- * Name of the endpoint. Used for named endpoints which can be referred using the key attribute
- * of indirect endpoints.
- */
- private String name = null;
-
- /**
- * Stores the endpoint details for this endpoint. Details include EPR, WS-Addressing
- * information, WS-Security information, etc.
- */
- private EndpointDefinition endpoint = null;
-
- /**
- * Parent endpoint of this endpoint if this used inside another endpoint. Possible parents are
- * LoadbalanceEndpoint, SALoadbalanceEndpoint and FailoverEndpoint objects.
- */
- private Endpoint parentEndpoint = null;
+public class AddressEndpoint extends DefaultEndpoint {
/**
* The endpoint context , place holder for keep any runtime states related to the endpoint
*/
private final EndpointContext endpointContext = new EndpointContext();
-
- public EndpointDefinition getEndpoint() {
- return endpoint;
- }
-
- public void setEndpoint(EndpointDefinition endpoint) {
- this.endpoint = endpoint;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name.trim();
- }
-
/**
* Checks if the endpoint is active (failed or not). If endpoint is in failed state and
* suspendOnFailDuration has elapsed, it will be set to active.
@@ -98,10 +55,16 @@
if (System.currentTimeMillis() > recoverOn) {
active = true;
endpointContext.setActive(true);
- endpointContext.setRecoverOn(0);
+ endpointContext.setRecoverOn(0);
}
}
+
+ if (log.isDebugEnabled()) {
+ log.debug("AddressEndpoint with name '" + getName() + "' is in "
+ + (active ? "active" : "inactive") + " state");
+ }
+
return active;
}
@@ -118,6 +81,7 @@
// this method simultaneously.
if (!active) {
+ EndpointDefinition endpoint = getEndpoint();
if (endpoint.getSuspendOnFailDuration() != -1) {
// Calculating a new value by adding suspendOnFailDuration to current time.
// as the endpoint is set as failed
@@ -171,9 +135,7 @@
if (endPointName == null) {
if (traceOrDebugOn && isClusteringEnable) {
- log.warn("In a clustering environment , the endpoint name should be specified" +
- "even for anonymous endpoints. Otherwise , the clustering would not be " +
- "functioned correctly if there are more than one anonymous endpoints. ");
+ log.warn(SALoadbalanceEndpoint.WARN_MESSAGE);
}
endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
@@ -187,6 +149,7 @@
}
}
+ EndpointDefinition endpoint = getEndpoint();
// Setting Required property to collect the End Point statistics
boolean statisticsEnable
= (SynapseConstants.STATISTICS_ON == endpoint.getStatisticsState());
@@ -232,66 +195,11 @@
synCtx.getEnvironment().send(endpoint, synCtx);
}
- public void onChildEndpointFail(Endpoint endpoint, MessageContext synMessageContext) {
- // nothing to do as this is a leaf level endpoint
- }
-
- public void setParentEndpoint(Endpoint parentEndpoint) {
- this.parentEndpoint = parentEndpoint;
- }
-
public void onFault(MessageContext synCtx) {
// perform retries here
// if this endpoint has actually failed, inform the parent.
setActive(false, synCtx);
-
- if (parentEndpoint != null) {
- parentEndpoint.onChildEndpointFail(this, synCtx);
- } else {
- Stack faultStack = synCtx.getFaultStack();
- if (!faultStack.isEmpty()) {
- ((FaultHandler) faultStack.pop()).handleFault(synCtx);
- }
- }
- }
-
- /**
- * Should this mediator perform tracing? True if its explicitly asked to
- * trace, or its parent has been asked to trace and it does not reject it
- *
- * @param msgCtx the current message
- * @return true if tracing should be performed
- */
- protected boolean isTraceOn(MessageContext msgCtx) {
- return
- (endpoint.getTraceState() == SynapseConstants.TRACING_ON) ||
- (endpoint.getTraceState() == SynapseConstants.TRACING_UNSET &&
- msgCtx.getTracingState() == SynapseConstants.TRACING_ON);
- }
-
- /**
- * Is tracing or debug logging on?
- *
- * @param isTraceOn is tracing known to be on?
- * @return true, if either tracing or debug logging is on
- */
- protected boolean isTraceOrDebugOn(boolean isTraceOn) {
- return isTraceOn || log.isDebugEnabled();
- }
-
- /**
- * Perform Trace and Debug logging of a message @INFO (trace) and DEBUG (log)
- *
- * @param traceOn is runtime trace on for this message?
- * @param msg the message to log/trace
- */
- protected void traceOrDebug(boolean traceOn, String msg) {
- if (traceOn) {
- trace.info(msg);
- }
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
+ super.onFault(synCtx);
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/DefaultEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/DefaultEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/DefaultEndpoint.java Mon Jun 9 03:43:19 2008
@@ -19,14 +19,11 @@
package org.apache.synapse.endpoints;
-import org.apache.axis2.clustering.ClusterManager;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.FaultHandler;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
-import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.endpoints.utils.EndpointDefinition;
import org.apache.synapse.statistics.impl.EndPointStatisticsStack;
@@ -40,8 +37,9 @@
*/
public class DefaultEndpoint extends FaultHandler implements Endpoint {
- private static final Log log = LogFactory.getLog(DefaultEndpoint.class);
- private static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
+ protected Log log;
+
+ protected static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
/**
* Name of the endpoint. Used for named endpoints which can be referred using the key attribute
@@ -61,11 +59,9 @@
*/
private Endpoint parentEndpoint = null;
- /**
- * The endpoint context , place holder for keep any runtime states related to the endpoint
- */
- private final EndpointContext endpointContext = new EndpointContext();
-
+ public DefaultEndpoint() {
+ log = LogFactory.getLog(this.getClass());
+ }
public EndpointDefinition getEndpoint() {
return endpoint;
@@ -88,7 +84,7 @@
* processed
*
* @param synMessageContext not being used
- * @return true
+ * @return true
*/
public boolean isActive(MessageContext synMessageContext) {
return true;
@@ -98,7 +94,7 @@
* since this is a virtual representation of an endpoint and the epr changes from message
* to message setting active state doesn't have a meaning
*
- * @param active not being used
+ * @param active not being used
* @param synMessageContext not being used
*/
public synchronized void setActive(boolean active, MessageContext synMessageContext) {
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/EndpointContext.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/EndpointContext.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/EndpointContext.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/EndpointContext.java Mon Jun 9 03:43:19 2008
@@ -26,10 +26,10 @@
import org.apache.synapse.SynapseException;
/**
- * Keeps the states of the endpoint.This hides where those states are kept .For a cluster environment
- * ,all states are kept in the axis2 configuration context in order to replicate those states so that
- * other synapse instance in the same cluster can see those changes . This class can be evolved to
- * keep any run time states related to the endpoint .For a non-clustered environment ,
+ * Keeps the states of the endpoint.This hides where those states are kept .For a cluster
+ * environment,all states are kept in the axis2 configuration context in order to replicate those
+ * states so that other synapse instance in the same cluster can see those changes . This class can
+ * be evolved to keep any run time states related to the endpoint .For a non-clustered environment,
* all data are kept locally.
* <p/>
* This class provide the abstraction need to separate the dynamic data from the static data and
@@ -41,7 +41,7 @@
private static final Log log = LogFactory.getLog(EndpointContext.class);
/* The static constant only for construct key prefix for each property in endpoint context
- *as it is need when those property state going to replicate in a cluster env. */
+ * as it is need when those property state going to replicate in a cluster env. */
private static final String ACTIVE = "active";
private static final String RECOVER_ON = "recover_on";
private static final String UNDERSCORE_STRING = "_";
@@ -53,13 +53,14 @@
/* Time to recover a failed endpoint.*/
private long recoverOn = Long.MAX_VALUE;
- /*The axis configuration context- this will hold the all callers states
+ /* The axis configuration context- this will hold the all callers states
* when doing throttling in a clustered environment. */
private ConfigurationContext configCtx;
- /*The key for 'active' attribute and this is used when this attribute value being replicated */
+ /* The key for 'active' attribute and this is used when this attribute value being replicated */
private String activePropertyKey;
- /*The key for 'recoverOn' attribute and this is used when this attribute value being replicated */
+ /* The key for 'recoverOn' attribute and this is used when this attribute value being
+ * replicated */
private String recoverOnPropertyKey;
/* Is this env. support clustering*/
@@ -232,13 +233,17 @@
try {
if (log.isDebugEnabled()) {
- log.debug("Going to replicate the property with key : " + key +
+ log.debug("Start replicating the property with key : " + key +
" value : " + value);
}
configCtx.setProperty(key, value);
Replicator.replicate(configCtx, new String[]{key});
+ if (log.isDebugEnabled()) {
+ log.debug("Completed replication of the property with key : " + key);
+ }
+
} catch (ClusteringFault clusteringFault) {
handleException("Error during the replicating states ", clusteringFault);
}
@@ -251,7 +256,6 @@
* @param msg The error message
*/
protected void handleException(String msg) {
-
log.error(msg);
throw new SynapseException(msg);
}
@@ -263,8 +267,7 @@
* @param e The exception
*/
protected void handleException(String msg, Exception e) {
-
log.error(msg, e);
throw new SynapseException(msg, e);
}
-}
+}
\ No newline at end of file
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java Mon Jun 9 03:43:19 2008
@@ -175,6 +175,10 @@
}
}
}
+
+ if (log.isDebugEnabled()) {
+ log.debug("Endpoint '" + name + "' is in state ' " + active + " '");
+ }
return active;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/IndirectEndpoint.java Mon Jun 9 03:43:19 2008
@@ -19,15 +19,12 @@
package org.apache.synapse.endpoints;
-import org.apache.axis2.clustering.ClusterManager;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.FaultHandler;
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.SynapseException;
-import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.endpoints.utils.EndpointDefinition;
/**
@@ -38,7 +35,7 @@
* As this is also an instance of endpoint, this can be used any place, where a normal endpoint is
* used.
*/
-public class IndirectEndpoint implements Endpoint {
+public class IndirectEndpoint extends FaultHandler implements Endpoint {
private static final Log trace = LogFactory.getLog(SynapseConstants.TRACE_LOGGER);
private static final Log log = LogFactory.getLog(IndirectEndpoint.class);
@@ -47,12 +44,6 @@
private String key = null;
private Endpoint parentEndpoint = null;
- /**
- * This should have a reference to the current message context as it gets the referred endpoint
- * from it.
- */
- private final EndpointContext endpointContext = new EndpointContext();
-
public void send(MessageContext synMessageContext) {
// get the actual endpoint and send
@@ -61,43 +52,11 @@
handleException("Reference to non-existent endpoint for key : " + key);
}
- boolean isClusteringEnable = false;
- // get Axis2 MessageContext and ConfigurationContext
- org.apache.axis2.context.MessageContext axisMC =
- ((Axis2MessageContext) synMessageContext).getAxis2MessageContext();
- ConfigurationContext cc = axisMC.getConfigurationContext();
-
- //The check for clustering environment
-
- ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
- if (clusterManager != null &&
- clusterManager.getContextManager() != null) {
- isClusteringEnable = true;
- }
-
- String endPointName = this.getName();
- if (endPointName == null) {
-
- if (log.isDebugEnabled() && isClusteringEnable) {
- log.warn("In a clustering environment , the endpoint name should be specified" +
- "even for anonymous endpoints. Otherwise , the clustering would not be " +
- "functioned correctly if there are more than one anonymous endpoints. ");
- }
- endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
- }
-
- if (isClusteringEnable) {
- // if this is a cluster environment , then set configuration context to endpoint context
- if (endpointContext.getConfigurationContext() == null) {
- endpointContext.setConfigurationContext(cc);
- endpointContext.setContextID(endPointName);
- }
- }
-
assert endpoint != null;
if (endpoint.isActive(synMessageContext)) {
+ // register this as the immediate fault handler for this message.
+ synMessageContext.pushFaultHandler(this);
endpoint.send(synMessageContext);
-
} else {
// if this is a child of some other endpoint, inform parent about the failure.
// if not, inform to the next fault handler.
@@ -217,4 +176,17 @@
synCtx.getTracingState() == SynapseConstants.TRACING_ON));
}
+ public void onFault(MessageContext synMessageContext) {
+ // At this point,child endpoint is in inactive state
+ // if this is a child of some other endpoint, inform parent about the failure.
+ // if not, inform to the next fault handler.
+ if (parentEndpoint != null) {
+ parentEndpoint.onChildEndpointFail(this, synMessageContext);
+ } else {
+ Object o = synMessageContext.getFaultStack().pop();
+ if (o != null) {
+ ((FaultHandler) o).handleFault(synMessageContext);
+ }
+ }
+ }
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java Mon Jun 9 03:43:19 2008
@@ -107,7 +107,7 @@
String endPointName = this.getName();
if (endPointName == null) {
- if (log.isDebugEnabled() && isClusteringEnable) {
+ if (isClusteringEnable) {
log.warn("In a clustering environment , the endpoint name should be specified" +
"even for anonymous endpoints. Otherwise , the clustering would not be " +
"functioned correctly if there are more than one anonymous endpoints. ");
@@ -198,6 +198,10 @@
}
}
+ if (log.isDebugEnabled()) {
+ log.debug("Endpoint '" + name + "' is in state ' " + active + " '");
+ }
+
return active;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java Mon Jun 9 03:43:19 2008
@@ -34,7 +34,6 @@
import org.apache.synapse.endpoints.dispatch.DispatcherContext;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -62,11 +61,11 @@
private static final String FIRST_MESSAGE_IN_SESSION = "first_message_in_session";
public static final String ENDPOINT_LIST = "endpointList";
+ public static final String ROOT_ENDPOINT = "rootendpoint";
public static final String ENDPOINT_NAME_LIST = "endpointNameList";
- private static final String WARN_MESSAGE = "In a clustering environment , the endpoint " +
- " name should be specified" +
- "even for anonymous endpoints. Otherwise , the clustering would not be " +
- "functional correctly if there are more than one anonymous endpoints. ";
+ public static final String WARN_MESSAGE = "In a clustering environment, the endpoint " +
+ "name should be specified even for anonymous endpoints. Otherwise the clustering " +
+ "would not function properly, if there are more than one anonymous endpoints.";
/**
* Name of the endpoint. Used for named endpoints which can be referred using the key attribute
@@ -99,18 +98,19 @@
private Dispatcher dispatcher = null;
/**
- * The dispatcher context , place holder for keep any runtime states that are used when
+ * The dispatcher context, place holder for keeping any runtime states that are used when
* finding endpoint for the session
*/
private final DispatcherContext dispatcherContext = new DispatcherContext();
+
/**
- * The endpoint context , place holder for keep any runtime states related to the endpoint
+ * The endpoint context, place holder for keeping any runtime states related to the endpoint
*/
private final EndpointContext endpointContext = new EndpointContext();
/**
- * The algorithm context , place holder for keep any runtime states related to the load balance
- * algorithm
+ * The algorithm context, place holder for keeping any runtime states related to the load
+ * balance algorithm
*/
private final AlgorithmContext algorithmContext = new AlgorithmContext();
@@ -118,7 +118,7 @@
public void send(MessageContext synMessageContext) {
if (log.isDebugEnabled()) {
- log.debug("Start : Session Affinity Load-balance Endpoint");
+ log.debug("Start : Session Affinity Load-balance Endpoint " + name);
}
boolean isClusteringEnable = false;
@@ -128,40 +128,66 @@
ConfigurationContext cc = axisMC.getConfigurationContext();
//The check for clustering environment
-
ClusterManager clusterManager = cc.getAxisConfiguration().getClusterManager();
if (clusterManager != null &&
clusterManager.getContextManager() != null) {
isClusteringEnable = true;
}
- String endPointName = this.getName();
- if (endPointName == null) {
-
- if (log.isDebugEnabled() && isClusteringEnable) {
+ String endpointName = this.getName();
+ if (endpointName == null) {
+ if (isClusteringEnable) {
log.warn(WARN_MESSAGE);
}
- endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
+ if (log.isDebugEnabled()) {
+ log.debug("Using the name for the anonymous endpoint as : '"
+ + SynapseConstants.ANONYMOUS_ENDPOINT + "'");
+ }
+ endpointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
if (isClusteringEnable) {
- // if this is a cluster environment , then set configuration context to endpoint context
+
+ // if this is a cluster environment, then set configuration context to endpoint context
if (endpointContext.getConfigurationContext() == null) {
- endpointContext.setConfigurationContext(cc);
- endpointContext.setContextID(endPointName);
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the ConfigurationContext to " +
+ "the EndpointContext with the name " + endpointName +
+ " for replicating data on the cluster");
+ }
+ endpointContext.setConfigurationContext(cc);
+ endpointContext.setContextID(endpointName);
}
- // if this is a cluster environment , then set configuration context to load balance
+
+ // if this is a cluster environment, then set configuration context to load balance
// algorithm context
if (algorithmContext.getConfigurationContext() == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the ConfigurationContext to " +
+ "the AlgorithmContext with the name " + endpointName +
+ " for replicating data on the cluster");
+ }
algorithmContext.setConfigurationContext(cc);
- algorithmContext.setContextID(endPointName);
+ algorithmContext.setContextID(endpointName);
}
- // if this is a cluster environment , then set configuration context to session based
+
+ // if this is a cluster environment, then set configuration context to session based
// endpoint dispatcher
if (dispatcherContext.getConfigurationContext() == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the ConfigurationContext to " +
+ "the DispatcherContext with the name " + endpointName +
+ " for replicating data on the cluster");
+ }
dispatcherContext.setConfigurationContext(cc);
- dispatcherContext.setContextID(endPointName);
+ dispatcherContext.setContextID(endpointName);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the endpoints to the DispatcherContext : " + endpoints);
+ }
dispatcherContext.setEndpoints(endpoints);
}
}
@@ -178,82 +204,77 @@
// this is a start of a new session. so update session map.
if (dispatcher.isServerInitiatedSession()) {
+ if (log.isDebugEnabled()) {
+ log.debug("Adding a new server initiated session for the current message");
+ }
+
// add this endpoint to the endpoint sequence of operation context.
Axis2MessageContext axis2MsgCtx = (Axis2MessageContext) synMessageContext;
OperationContext opCtx = axis2MsgCtx.getAxis2MessageContext().getOperationContext();
- if (isClusteringEnable) { // if this is a clustering env.
- //Only keeps endpoint names , because , it is heavy task to
- // replicate endpoint itself
+ if (isClusteringEnable) {
+ // If running on a cluster keep endpoint names, because it is heavy to
+ // replicate endpoint itself
Object o = opCtx.getPropertyNonReplicable(ENDPOINT_NAME_LIST);
- if (o != null) {
-
- List endpointList = (List) o;
- endpointList.add(endPointName);
+ List<String> epNameList;
+ if (o instanceof List) {
+ epNameList = (List<String>) o;
+ epNameList.add(endpointName);
+ } else {
+ // this is the first endpoint in the heirachy. so create the queue and
+ // insert this as the first element.
+ epNameList = new ArrayList<String>();
+ epNameList.add(endpointName);
+ opCtx.setNonReplicableProperty(ROOT_ENDPOINT, this);
+ }
+
+ // if the next endpoint is not a session affinity one, endpoint sequence ends
+ // here. but we have to add the next endpoint to the list.
+ if (!(endpoint instanceof SALoadbalanceEndpoint)) {
- // if the next endpoint is not a session affinity one, endpoint sequence ends
- // here. but we have to add the next endpoint to the list.
- if (!(endpoint instanceof SALoadbalanceEndpoint)) {
- String name = endpoint.getName();
- if (name == null) {
- log.warn(WARN_MESSAGE);
- name = SynapseConstants.ANONYMOUS_ENDPOINT;
- }
- endpointList.add(name);
+ String name;
+ if (endpoint instanceof IndirectEndpoint) {
+ name = ((IndirectEndpoint) endpoint).getKey();
+ } else {
+ name = endpoint.getName();
}
- } else {
- // this is the first endpoint in the heirachy. so create the queue and insert
- // this as the first element.
- List endpointList = new ArrayList();
- endpointList.add(endPointName);
-
- // if the next endpoint is not a session affinity one, endpoint sequence ends
- // here. but we have to add the next endpoint to the list.
- if (!(endpoint instanceof SALoadbalanceEndpoint)) {
- String name = endpoint.getName();
- if (name == null) {
- log.warn(WARN_MESSAGE);
- name = SynapseConstants.ANONYMOUS_ENDPOINT;
- }
- endpointList.add(name);
+ if (name == null) {
+ log.warn(WARN_MESSAGE);
+ name = SynapseConstants.ANONYMOUS_ENDPOINT;
}
-
- opCtx.setProperty(ENDPOINT_NAME_LIST, endpointList);
+ epNameList.add(name);
}
- }
-
- Object o = opCtx.getProperty(ENDPOINT_LIST);
-
- if (o != null) {
- List<Endpoint> endpointList = (List<Endpoint>) o;
- endpointList.add(this);
-
- // if the next endpoint is not a session affinity one, endpoint sequence ends
- // here. but we have to add the next endpoint to the list.
- if (!(endpoint instanceof SALoadbalanceEndpoint)) {
- endpointList.add(endpoint);
+ if (log.isDebugEnabled()) {
+ log.debug("Operating on a cluster. Setting the endpoint name list to " +
+ "the OperationContext : " + epNameList);
}
+ opCtx.setProperty(ENDPOINT_NAME_LIST, epNameList);
} else {
-
- // this is the first endpoint in the heirachy. so create the queue and insert
- // this as the first element.
- List endpointList = new ArrayList();
- endpointList.add(this);
-
+
+ Object o = opCtx.getProperty(ENDPOINT_LIST);
+ List<Endpoint> endpointList;
+ if (o instanceof List) {
+ endpointList = (List<Endpoint>) o;
+ endpointList.add(this);
+ } else {
+ // this is the first endpoint in the heirachy. so create the queue and
+ // insert this as the first element.
+ endpointList = new ArrayList<Endpoint>();
+ endpointList.add(this);
+ opCtx.setProperty(ENDPOINT_LIST, endpointList);
+ }
+
// if the next endpoint is not a session affinity one, endpoint sequence ends
// here. but we have to add the next endpoint to the list.
if (!(endpoint instanceof SALoadbalanceEndpoint)) {
endpointList.add(endpoint);
}
-
- opCtx.setProperty(ENDPOINT_LIST, endpointList);
}
-
} else {
dispatcher.updateSession(synMessageContext, dispatcherContext, endpoint);
}
@@ -273,6 +294,12 @@
// endpoints given by session dispatchers may not be active. therefore, we have check
// it here.
if (endpoint.isActive(synMessageContext)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the endpoint on the session with "
+ + ((endpoint instanceof IndirectEndpoint) ? "key : "
+ + ((IndirectEndpoint) endpoint).getKey() : "name : "
+ + endpoint.getName()) + " for sending the message");
+ }
endpoint.send(synMessageContext);
} else {
informFailure(synMessageContext);
@@ -281,6 +308,10 @@
} else {
// all child endpoints have failed. so mark this also as failed.
+ if (log.isDebugEnabled()) {
+ log.debug("Marking the Endpoint as failed, " +
+ "because all child endpoints has been failed");
+ }
setActive(false, synMessageContext);
informFailure(synMessageContext);
}
@@ -294,21 +325,27 @@
* @param isClusteringEnable
*/
public void updateSession(MessageContext responseMsgCtx, List endpointList,
- boolean isClusteringEnable) {
+ boolean isClusteringEnable) {
Endpoint endpoint = null;
if (isClusteringEnable) {
- // if this is a clustering env.
- // Only keeps endpoint names , because , it is heavy task to
+ // if this is a clustering env. only keep endpoint names, because, it is heavy to
// replicate endpoint itself
String epNameObj = (String) endpointList.remove(0);
- for (Iterator it = endpointList.iterator(); it.hasNext();) {
- Object epObj = it.next();
- if (epObj != null && epObj instanceof Endpoint) {
- String name = ((Endpoint) epObj).getName();
+ for (Endpoint ep : endpoints) {
+ if (ep != null) {
+
+ String name;
+ if (ep instanceof IndirectEndpoint) {
+ name = ((IndirectEndpoint) ep).getKey();
+ } else {
+ name = ep.getName();
+ }
+
if (name != null && name.equals(epNameObj)) {
- endpoint = ((Endpoint) epObj);
+ endpoint = ep;
+ break;
}
}
}
@@ -356,8 +393,37 @@
*/
public boolean isActive(MessageContext synMessageContext) {
// todo: implement above
+ boolean active;
+ Endpoint endpoint = dispatcher.getEndpoint(synMessageContext, dispatcherContext);
+ if (endpoint == null) { // If a session is not started
+ active = endpointContext.isActive();
+ if (!active && endpoints != null) {
+ for (Endpoint ep : endpoints) {
+ if (ep != null) {
+ active = ep.isActive(synMessageContext);
+ if (active) { //AND at least one child endpoint is active
+ endpointContext.setActive(active);
+ // don't break the loop though we found one active endpoint. calling isActive()
+ // on all child endpoints will update their active state. so this is a good
+ // time to do that.
+ }
+ }
+ }
+ }
+ } else {
+ //If a session is started AND the binding endpoint is active.
+ active = endpoint.isActive(synMessageContext);
+ if (active) {
+ endpointContext.setActive(active);
+ }
+ }
- return endpointContext.isActive();
+ if (log.isDebugEnabled()) {
+ log.debug("SALoadbalanceEndpoint with name '" + getName() + "' is in "
+ + (active ? "active" : "inactive") + " state");
+ }
+
+ return active;
}
public void setActive(boolean active, MessageContext synMessageContext) {
@@ -416,11 +482,11 @@
private void informFailure(MessageContext synMessageContext) {
+ log.warn("Failed to send using the selected endpoint, becasue it is inactive");
+
if (parentEndpoint != null) {
parentEndpoint.onChildEndpointFail(this, synMessageContext);
-
} else {
-
Object o = synMessageContext.getFaultStack().pop();
if (o != null) {
((FaultHandler) o).handleFault(synMessageContext);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/WSDLEndpoint.java Mon Jun 9 03:43:19 2008
@@ -240,6 +240,12 @@
endpointContext.setActive(true);
}
}
+
+ if (log.isDebugEnabled()) {
+ log.debug("WSDLEndpoint with name '" + name + "' is in "
+ + (active ? "active" : "inactive") + " state");
+ }
+
return active;
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java Mon Jun 9 03:43:19 2008
@@ -45,17 +45,18 @@
private static final String UNDERSCORE_STRING = "_";
private static final String CURRENT_EPR = "currentEPR";
- /*The axis configuration context- this will hold the all callers states
- *when doing throttling in a clustered environment. */
+ /* The axis configuration context- this will hold the all callers states
+ * when doing throttling in a clustered environment. */
private ConfigurationContext configCtx;
/* Is this env. support clustering*/
private boolean isClusteringEnable = false;
- /*The key for 'currentEPR' attribute and this is used when this attribute value being replicated */
+ /* The key for 'currentEPR' attribute and this is used when this attribute value being
+ * replicated */
private String currentEPRPropertyKey;
- /*The pointer to current epr - The position of the current EPR */
+ /* The pointer to current epr - The position of the current EPR */
private int currentEPR = 0;
/**
@@ -102,10 +103,17 @@
if (isClusteringEnable) { // if this is a clustering env.
if (currentEPRPropertyKey != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the current EPR " + currentEPR
+ + " with the key " + currentEPRPropertyKey);
+ }
// Sets the property and replicates the current state so that all instances
setAndReplicateState(currentEPRPropertyKey, currentEPR);
}
} else {
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the current EPR " + currentEPR);
+ }
this.currentEPR = currentEPR;
}
}
@@ -155,7 +163,6 @@
buffer.append(UNDERSCORE_STRING);
buffer.append(CURRENT_EPR);
currentEPRPropertyKey = buffer.toString();
-
}
@@ -165,7 +172,6 @@
* @param msg The error message
*/
protected void handleException(String msg) {
-
log.error(msg);
throw new SynapseException(msg);
}
@@ -177,7 +183,6 @@
* @param e The exception
*/
protected void handleException(String msg, Exception e) {
-
log.error(msg, e);
throw new SynapseException(msg, e);
}
@@ -196,17 +201,21 @@
try {
if (log.isDebugEnabled()) {
- log.debug("Going to replicate the property with key : " + key
+ log.debug("Start replicating the property with key : " + key
+ " value : " + value);
}
configCtx.setProperty(key, value);
Replicator.replicate(configCtx, new String[]{key});
+ if (log.isDebugEnabled()) {
+ log.debug("Completed replication of the property with key : " + key);
+ }
+
} catch (ClusteringFault clusteringFault) {
handleException("Error during the replicating states ", clusteringFault);
}
}
}
-}
+}
\ No newline at end of file
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/RoundRobin.java Mon Jun 9 03:43:19 2008
@@ -19,17 +19,24 @@
package org.apache.synapse.endpoints.algorithms;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
import org.apache.synapse.endpoints.Endpoint;
import java.util.ArrayList;
/**
- * This is the implementation of the round robin load balancing algorithm. It simply iterates through
- * the endpoint list one by one for until an active endpoint is found.
+ * This is the implementation of the round robin load balancing algorithm. It simply iterates
+ * through the endpoint list one by one for until an active endpoint is found.
*/
public class RoundRobin implements LoadbalanceAlgorithm {
+ private static final Log log = LogFactory.getLog(RoundRobin.class);
+
+ /**
+ * Endpoints list for the round robin algorithm
+ */
private ArrayList endpoints = null;
public RoundRobin(ArrayList endpoints) {
@@ -44,7 +51,12 @@
* @param algorithmContext The context in which holds run time states related to the algorithm
* @return endpoint to send the next message
*/
- public Endpoint getNextEndpoint(MessageContext synapseMessageContext, AlgorithmContext algorithmContext) {
+ public Endpoint getNextEndpoint(MessageContext synapseMessageContext,
+ AlgorithmContext algorithmContext) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Using the Round Robin loadbalancing algorithm to select the next endpoint");
+ }
Endpoint nextEndpoint;
int attempts = 0;
@@ -64,6 +76,7 @@
attempts++;
if (attempts > endpoints.size()) {
+ log.warn("Couldn't find an endpoint from the Round Robin loadbalancing algorithm");
return null;
}
@@ -73,6 +86,9 @@
}
public void reset(AlgorithmContext algorithmContext) {
+ if (log.isDebugEnabled()) {
+ log.debug("Resetting the Round Robin loadbalancing algorithm ...");
+ }
algorithmContext.setCurrentEPR(0);
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/Dispatcher.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/Dispatcher.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/Dispatcher.java Mon Jun 9 03:43:19 2008
@@ -37,24 +37,28 @@
* synapseMessageContext is not found it should return null.
*
* @param synCtx client -> esb message context.
+ * @param dispatcherContext context for dispatching
* @return Endpoint Endpoint associated with this session.
*/
public Endpoint getEndpoint(MessageContext synCtx, DispatcherContext dispatcherContext);
/**
* Updates the session maps. This will be called in the first client -> synapse -> server flow
- * for client initiated sessions. For server initiated sessions, this will be called in the first
- * server -> synapse -> client flow.
+ * for client initiated sessions. For server initiated sessions, this will be called in the
+ * first server -> synapse -> client flow.
*
* @param synCtx SynapseMessageContext
+ * @param dispatcherContext context for dispatching
* @param endpoint Selected endpoint for this session.
*/
- public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext, Endpoint endpoint);
+ public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext,
+ Endpoint endpoint);
/**
* Removes the session belonging to the given message context.
*
* @param synCtx MessageContext containing an session ID.
+ * @param dispatcherContext context for dispatching
*/
public void unbind(MessageContext synCtx, DispatcherContext dispatcherContext);
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/DispatcherContext.java Mon Jun 9 03:43:19 2008
@@ -26,6 +26,8 @@
import org.apache.synapse.SynapseConstants;
import org.apache.synapse.SynapseException;
import org.apache.synapse.endpoints.Endpoint;
+import org.apache.synapse.endpoints.IndirectEndpoint;
+import org.apache.synapse.endpoints.SALoadbalanceEndpoint;
import java.util.Collections;
import java.util.HashMap;
@@ -40,8 +42,8 @@
* For a non-clustered environment , all data are kept locally.
* <p/>
* This class provide the abstraction need to separate the dynamic data from the static data and
- * improve the high cohesion and provides capability to replicate only required state at a given time
- * This improves the performance when replicate data.
+ * improve the high cohesion and provides capability to replicate only required state at a given
+ * time. This improves the performance when replicate data.
*/
public class DispatcherContext {
@@ -85,15 +87,21 @@
handleException("Cannot find the required key prefix to find the " +
"shared state of one of 'session'");
}
- // gets the value from configuration context (The shared state across all instances )
+ // gets the value from configuration context (The shared state across all instances)
Object value = this.configCtx.getPropertyNonReplicable(this.keyPrefix + sessionID);
if (value != null && value instanceof String) {
+ if (log.isDebugEnabled()) {
+ log.debug("Retrieving the endpoint from the session id " + value);
+ }
return endpointsMap.get(value.toString());
}
} else {
synchronized (sessionMap) {
+ if (log.isDebugEnabled()) {
+ log.debug("Retrieving the endpoint from the session id " + sessionID);
+ }
return sessionMap.get(sessionID);
}
}
@@ -110,25 +118,37 @@
public void setEndpoint(String sessionID, Endpoint endpoint) {
if (isClusteringEnable) { // if this is a clustering env.
- String endPointName = endpoint.getName();
- if (endPointName == null) {
+ String endpointName;
+ if (endpoint instanceof IndirectEndpoint) {
+ endpointName = ((IndirectEndpoint) endpoint).getKey();
+ } else {
+ endpointName = endpoint.getName();
+ }
+
+ if (endpointName == null) {
if (log.isDebugEnabled() && isClusteringEnable()) {
- log.warn("In a clustering environment , the endpoint name should be" +
- " specified even for anonymous endpoints. Otherwise , the " +
- "clustering would not be functioned correctly if there are" +
- " more than one anonymous endpoints. ");
+ log.warn(SALoadbalanceEndpoint.WARN_MESSAGE);
}
- endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
+ endpointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
+
if (keyPrefix != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Adding the enpoint " + endpointName + " with the session id "
+ + keyPrefix + sessionID + " for replication to the session");
+ }
// replicates the state so that all instances across cluster can see this state
- setAndReplicateState(keyPrefix + sessionID, endPointName);
+ setAndReplicateState(keyPrefix + sessionID, endpointName);
}
} else {
synchronized (sessionMap) {
+ if (log.isDebugEnabled()) {
+ log.debug("Adding the endpoint " + endpoint
+ + " with the session id " + sessionID + " to the session");
+ }
sessionMap.put(sessionID, endpoint);
}
}
@@ -145,15 +165,21 @@
if (isClusteringEnable) { // if this is a clustering env.
if (keyPrefix != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Removing and replicating " +
+ "the session with the session id " + keyPrefix + id);
+ }
//Removes the endpoint name and then replicates the current
//state so that all instances
removeAndReplicateState(keyPrefix + id);
-
}
} else {
synchronized (sessionMap) {
+ if (log.isDebugEnabled()) {
+ log.debug("Removing the session with the session id " + id);
+ }
sessionMap.remove(id);
}
}
@@ -214,7 +240,6 @@
* @param msg The error message
*/
protected void handleException(String msg) {
-
log.error(msg);
throw new SynapseException(msg);
}
@@ -226,7 +251,6 @@
* @param e The exception
*/
protected void handleException(String msg, Exception e) {
-
log.error(msg, e);
throw new SynapseException(msg, e);
}
@@ -245,7 +269,7 @@
try {
if (log.isDebugEnabled()) {
- log.debug("Going to replicate the property with key : " +
+ log.debug("Start replicating the property with key : " +
key + " value : " + value);
}
@@ -255,6 +279,10 @@
Replicator.replicate(configCtx, new String[]{key});
}
+ if (log.isDebugEnabled()) {
+ log.debug("Completed replication of the property with key: " + key);
+ }
+
} catch (ClusteringFault clusteringFault) {
handleException("Error during the replicating states ", clusteringFault);
}
@@ -274,12 +302,16 @@
try {
if (log.isDebugEnabled()) {
- log.debug("Going to replicate the property with key : " + key);
+ log.debug("Start replicating the property removal with key : " + key);
}
configCtx.removeProperty(key);
Replicator.replicate(configCtx, new String[]{key});
+ if (log.isDebugEnabled()) {
+ log.debug("Completed replication of the property removal with key : " + key);
+ }
+
} catch (ClusteringFault clusteringFault) {
handleException("Error during the replicating states ", clusteringFault);
}
@@ -305,20 +337,27 @@
if (endpoints != null) {
for (Endpoint endpoint : endpoints) {
- String endPointName = endpoint.getName();
- if (endPointName == null) {
+
+ String endpointName;
+ if (endpoint instanceof IndirectEndpoint) {
+ endpointName = ((IndirectEndpoint) endpoint).getKey();
+ } else {
+ endpointName = endpoint.getName();
+ }
+
+ if (endpointName == null) {
if (log.isDebugEnabled() && isClusteringEnable()) {
- log.warn("In a clustering environment , the endpoint name should be" +
- " specified even for anonymous endpoints. Otherwise , the " +
- "clustering would not be functioned correctly if there are" +
- " more than one anonymous endpoints. ");
+ log.warn(SALoadbalanceEndpoint.WARN_MESSAGE);
}
- endPointName = SynapseConstants.ANONYMOUS_ENDPOINT;
+ endpointName = SynapseConstants.ANONYMOUS_ENDPOINT;
}
- endpointsMap.put(endPointName, endpoint);
-
+ if (log.isDebugEnabled()) {
+ log.debug("Adding an endpoint with the name/key "
+ + endpointName + " to the endpoints map");
+ }
+ endpointsMap.put(endpointName, endpoint);
}
}
}
-}
+}
\ No newline at end of file
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/HttpSessionDispatcher.java Mon Jun 9 03:43:19 2008
@@ -28,9 +28,9 @@
import java.util.Map;
/**
- * Dispatches sessions based on HTTP cookies. Session is initiated by the server in the first response
- * when it sends "Set-Cookie" HTTP header with the session ID. For all successive messages client
- * should send "Cookie" HTTP header with session ID send by the server.
+ * Dispatches sessions based on HTTP cookies. Session is initiated by the server in the first
+ * response when it sends "Set-Cookie" HTTP header with the session ID. For all successive messages
+ * client should send "Cookie" HTTP header with session ID send by the server.
*/
public class HttpSessionDispatcher implements Dispatcher {
@@ -42,9 +42,9 @@
private final static String SET_COOKIE = "Set-Cookie";
/**
- * Check if "Cookie" HTTP header is available. If so, check if that cookie is in the session map.
- * If cookie is available, there is a session for this cookie. return the (server) endpoint for
- * that session.
+ * Check if "Cookie" HTTP header is available. If so, check if that cookie is in the session
+ * map. If cookie is available, there is a session for this cookie. return the (server)
+ * endpoint for that session.
*
* @param synCtx MessageContext possibly containing a "Cookie" HTTP header.
* @return Endpoint Server endpoint for the given HTTP session.
@@ -62,10 +62,23 @@
Object cookie = headerMap.get(COOKIE);
if (cookie != null && cookie instanceof String) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Using the HTTP header 'Cookie: " + cookie
+ + "' to retrieve the endpoint in the transport session");
+ }
+
Object ep = dispatcherContext.getEndpoint((String) cookie);
if (ep != null && ep instanceof Endpoint) {
endpoint = (Endpoint) ep;
+ } else if (log.isDebugEnabled()) {
+ log.debug("No endpoint found in the transport " +
+ "session for the session id " + cookie);
}
+
+ } else if (log.isDebugEnabled()) {
+ log.debug("No 'Cookie' HTTP headers found to extract the " +
+ "endpoint from the transport session");
}
}
@@ -80,7 +93,8 @@
* @param synCtx MessageContext possibly containing the "Set-Cookie" HTTP header.
* @param endpoint Endpoint to be mapped to the session.
*/
- public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext, Endpoint endpoint) {
+ public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext,
+ Endpoint endpoint) {
if (endpoint == null || dispatcherContext == null) {
return;
@@ -95,7 +109,30 @@
Object cookie = headerMap.get(SET_COOKIE);
if (cookie != null && cookie instanceof String) {
- dispatcherContext.setEndpoint((String) cookie, endpoint);
+
+ // extract the first name value pair of the Set-Cookie header, which is considered
+ // as the session id which will be sent back from the client with the Cookie header
+ // for example;
+ // Set-Cookie: JSESSIONID=760764CB72E96A7221506823748CF2AE; Path=/
+ // will result in the session id "JSESSIONID=760764CB72E96A7221506823748CF2AE"
+ // and the client is expected to send the Cookie header as;
+ // Cookie: JSESSIONID=760764CB72E96A7221506823748CF2AE
+ if (log.isDebugEnabled()) {
+ log.debug("Found the HTTP header 'Set-Cookie: "
+ + cookie + "' for updating the session");
+ }
+ String sessionId = ((String) cookie).split(";")[0];
+
+ if (log.isDebugEnabled()) {
+ log.debug("Using the session id '" + sessionId +
+ "' extracted from the Set-Cookie header to update the session " +
+ "with the endpoint " + endpoint);
+ }
+ dispatcherContext.setEndpoint(sessionId, endpoint);
+
+ } else if (log.isDebugEnabled()) {
+ log.debug("No 'Set-Cookie' HTTP header is specified in " +
+ "the message to update the session");
}
}
}
@@ -111,7 +148,16 @@
Object cookie = headerMap.get(COOKIE);
if (cookie != null && cookie instanceof String) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Using the HTTP header 'Cookie: "
+ + cookie + "' to unbind the session");
+ }
dispatcherContext.removeSession((String) cookie);
+
+ } else if (log.isDebugEnabled()) {
+ log.debug("No 'Cookie' HTTP header is specified in " +
+ "the message to unbind the session");
}
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SimpleClientSessionDispatcher.java Mon Jun 9 03:43:19 2008
@@ -30,7 +30,7 @@
/**
* This dispatcher is implemented to demonstrate a sample client session. It will detect sessions
- * based on the <syn:ClientID xmlns:syn="http://ws.apache.org/namespaces/synapse"> soap header of the
+ * based on the <syn:ClientID xmlns:syn="http://ws.apache.org/ns/synapse"> soap header of the
* request message. Therefore, above header has to be included in the request soap messages by the
* client who wants to initiate and maintain a session.
*/
@@ -38,31 +38,42 @@
private static final Log log = LogFactory.getLog(SimpleClientSessionDispatcher.class);
+ private static final QName CSID_QNAME
+ = new QName("http://ws.apache.org/ns/synapse", "ClientID", "syn");
+
public Endpoint getEndpoint(MessageContext synCtx, DispatcherContext dispatcherContext) {
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
- OMElement sgcIDElm = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/synapse", "ClientID", "syn"));
+ OMElement sgcIDElm = header.getFirstChildWithName(CSID_QNAME);
if (sgcIDElm != null) {
String sgcID = sgcIDElm.getText();
if (sgcID != null) {
+ log.debug("Using the client session id : '"
+ + sgcID + "' extracted from current message to retrieve endpoint");
Object o = dispatcherContext.getEndpoint(sgcID);
if (o != null && o instanceof Endpoint) {
return (Endpoint) o;
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the client session id for the current message " +
+ "to retrieve endpoint");
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find a SOAP header with the QName " + CSID_QNAME +
+ " for the current message to retrieve the endpoint");
}
}
return null;
}
- public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext, Endpoint endpoint) {
+ public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext,
+ Endpoint endpoint) {
if (endpoint == null || dispatcherContext == null) {
return;
@@ -71,15 +82,24 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
- OMElement csIDElm = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/synapse", "ClientID", "syn"));
+ OMElement csIDElm = header.getFirstChildWithName(CSID_QNAME);
if (csIDElm != null) {
String csID = csIDElm.getText();
if (csID != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the client session id : '"
+ + csID + "' extracted from current message to update the session");
+ }
dispatcherContext.setEndpoint(csID, endpoint);
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the client session id for the current message " +
+ "to update the session");
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find a SOAP header with the QName " + CSID_QNAME +
+ " for the current message to update the session");
}
}
}
@@ -94,15 +114,20 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
- OMElement csIDElm = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/synapse", "ClientID", "syn"));
+ OMElement csIDElm = header.getFirstChildWithName(CSID_QNAME);
if (csIDElm != null) {
String csID = csIDElm.getText();
if (csID != null) {
dispatcherContext.removeSession(csID);
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the client session id for the current message " +
+ "to unbind the session");
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find a SOAP header with the QName " + CSID_QNAME +
+ " for the current message to unbind the session");
}
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/dispatch/SoapSessionDispatcher.java Mon Jun 9 03:43:19 2008
@@ -21,6 +21,7 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.addressing.AddressingConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
@@ -32,33 +33,38 @@
private static final Log log = LogFactory.getLog(SoapSessionDispatcher.class);
+ private static final QName QNAME_SERVICE_GROUP_ID
+ = new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2");
+
/**
* Gives the endpoint based on the service group context ID of the request message.
*
* @param synCtx Request MessageContext, possibly containing a service group context ID.
* @return Endpoint associated with the soap session, if current message is a soap session
- * message and if current message is not the first message of the session. Returns null, if
- * an Endpoint could not be found for the session.
+ * message and if current message is not the first message of the session. Returns null,
+ * if an Endpoint could not be found for the session.
*/
public Endpoint getEndpoint(MessageContext synCtx, DispatcherContext dispatcherContext) {
- Endpoint endpoint = null;
+ Endpoint endpoint = null;
SOAPHeader header = synCtx.getEnvelope().getHeader();
-
+
if (header != null) {
- OMElement sgcElm = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
+ OMElement sgcElm = header.getFirstChildWithName(QNAME_SERVICE_GROUP_ID);
if (sgcElm != null) {
String sgcID = sgcElm.getText();
if (sgcID != null) {
- Object e = dispatcherContext.getEndpoint(sgcID);
-
- if (e != null && e instanceof Endpoint) {
- endpoint = (Endpoint) e;
+ if (log.isDebugEnabled()) {
+ log.debug("Using the ServiceGroupId SOAP header value "
+ + sgcID + " to retrieve endpoint on the session");
}
+ endpoint = dispatcherContext.getEndpoint(sgcID);
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the ServiceQroupId SOAP " +
+ "header to retrieve the endpoint on the session");
}
}
@@ -73,7 +79,8 @@
* @param synCtx MessageContext of the response message.
* @param endpoint Endpoint to associate with the session.
*/
- public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext, Endpoint endpoint) {
+ public void updateSession(MessageContext synCtx, DispatcherContext dispatcherContext,
+ Endpoint endpoint) {
if (endpoint == null || dispatcherContext == null) {
return;
@@ -86,24 +93,38 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
- OMElement replyTo = header.getFirstChildWithName
- (new QName("http://www.w3.org/2005/08/addressing", "ReplyTo", "wsa"));
+ OMElement replyTo = header.getFirstChildWithName(
+ AddressingConstants.Final.QNAME_WSA_REPLY_TO);
if (replyTo != null) {
OMElement referenceParameters = replyTo.getFirstChildWithName(new QName(
"http://www.w3.org/2005/08/addressing", "ReferenceParameters", "wsa"));
if (referenceParameters != null) {
- OMElement sgcElm = referenceParameters.getFirstChildWithName(new QName(
- "http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
-
- // synchronized to avoid possible replacement of sessions
- String sgcID = sgcElm.getText();
+ OMElement sgcElm
+ = referenceParameters.getFirstChildWithName(QNAME_SERVICE_GROUP_ID);
- if (sgcID != null) {
- dispatcherContext.setEndpoint(sgcID, endpoint);
+ if (sgcElm != null) {
+ // synchronized to avoid possible replacement of sessions
+ String sgcID = sgcElm.getText();
+
+ if (sgcID != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the ServiceGroupId value "
+ + sgcID + " to update the endpoint session");
+ }
+ dispatcherContext.setEndpoint(sgcID, endpoint);
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the WSA ServiceQroupId on the " +
+ "ReferenceParameters of the Reply-To header to update the session");
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the WSA ReferenceParameters in the Reply-To " +
+ "header to retrieve the ServiceQroupId");
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the WSA Reply-To header to retrieve the ServiceQroupId");
}
}
}
@@ -113,15 +134,20 @@
SOAPHeader header = synCtx.getEnvelope().getHeader();
if (header != null) {
- OMElement sgcIDElm = header.getFirstChildWithName(
- new QName("http://ws.apache.org/namespaces/axis2", "ServiceGroupId", "axis2"));
+ OMElement sgcIDElm = header.getFirstChildWithName(QNAME_SERVICE_GROUP_ID);
if (sgcIDElm != null) {
String sgcID = sgcIDElm.getText();
if (sgcID != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Using the ServiceGroupId value "
+ + sgcID + " to unbind session");
+ }
dispatcherContext.removeSession(sgcID);
}
+ } else if (log.isDebugEnabled()) {
+ log.debug("Couldn't find the ServiceQroupId SOAP header to unbind the session");
}
}
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java?rev=664672&r1=664671&r2=664672&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CalloutMediator.java Mon Jun 9 03:43:19 2008
@@ -22,6 +22,9 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.description.Parameter;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
@@ -32,6 +35,7 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseException;
import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.synapse.util.MessageHelper;
import org.apache.synapse.util.xpath.SynapseXPath;
@@ -79,6 +83,16 @@
if (action != null) {
options.setAction(action);
+ } else {
+ if (synCtx.isSOAP11()) {
+ options.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION, true);
+ } else {
+ Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
+ org.apache.axis2.context.MessageContext axis2MessageCtx =
+ axis2smc.getAxis2MessageContext();
+ axis2MessageCtx.getTransportOut().addParameter(
+ new Parameter(HTTPConstants.OMIT_SOAP_12_ACTION, true));
+ }
}
options.setProperty(