Author: ruwan Date: Tue Jul 28 07:55:07 2009 New Revision: 798435 URL: http://svn.apache.org/viewvc?rev=798435&view=rev Log: Fixing the handler module (1.3 branch)
Modified: synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java Modified: synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java?rev=798435&r1=798434&r2=798435&view=diff ============================================================================== --- synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java (original) +++ synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java Tue Jul 28 07:55:07 2009 @@ -28,10 +28,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.neethi.Assertion; import org.apache.neethi.Policy; -import org.apache.synapse.ServerConfigurationInformation; -import org.apache.synapse.ServerConfigurationInformationFactory; -import org.apache.synapse.ServerContextInformation; -import org.apache.synapse.ServerManager; +import org.apache.synapse.*; /** * This will be the Module class for the Synapse handler based mediations inside axis2 server. This @@ -56,14 +53,19 @@ public void init(ConfigurationContext configurationContext, AxisModule axisModule) throws AxisFault { - log.info("Initializing the Synapse as a handler"); - ServerConfigurationInformation configurationInformation = - ServerConfigurationInformationFactory.createServerConfigurationInformation( - configurationContext.getAxisConfiguration()); ServerManager serverManager = ServerManager.getInstance(); - ServerContextInformation contextInfo = new ServerContextInformation(configurationContext); - serverManager.init(configurationInformation, contextInfo); - serverManager.start(); + if (!(serverManager.getServerState() == ServerState.STARTED)) { + log.info("Initializing the Synapse as a handler"); + ServerConfigurationInformation configurationInformation = + ServerConfigurationInformationFactory.createServerConfigurationInformation( + configurationContext.getAxisConfiguration()); + ServerContextInformation contextInfo + = new ServerContextInformation(configurationContext); + serverManager.init(configurationInformation, contextInfo); + serverManager.start(); + } else { + log.info("Detected an already strated synapse instance using that for the mediation"); + } } public void engageNotify(AxisDescription axisDescription) throws AxisFault {} Modified: synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java?rev=798435&r1=798434&r2=798435&view=diff ============================================================================== --- synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java (original) +++ synapse/branches/1.3/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java Tue Jul 28 07:55:07 2009 @@ -58,11 +58,13 @@ } public static boolean mediateInMessage(Log log, MessageContext messageContext, - org.apache.synapse.MessageContext synCtx) throws AxisFault { + org.apache.synapse.MessageContext synCtx) + throws AxisFault { AxisService service = messageContext.getAxisService(); if (service != null) { - Parameter inMediationParam = service.getParameter(HandlerConstants.IN_SEQUENCE_PARAM_NAME); + Parameter inMediationParam + = service.getParameter(HandlerConstants.IN_SEQUENCE_PARAM_NAME); if (inMediationParam != null && inMediationParam.getValue() != null) { if (inMediationParam.getValue() instanceof Mediator) { Mediator inMessageSequence = (Mediator) inMediationParam.getValue(); @@ -73,12 +75,14 @@ return inMessageSequence.mediate(synCtx); } else { if (log.isDebugEnabled()) { - log.debug("The provided in message mediation sequence is not a proper mediator"); + log.debug("The provided in message mediation " + + "sequence is not a proper mediator"); } } } else { if (log.isDebugEnabled()) { - log.debug("Couldn't find the incoming mediation for the service " + service.getName()); + log.debug("Couldn't find the incoming mediation for the service " + + service.getName()); } } } else { @@ -91,11 +95,13 @@ } public static boolean mediateOutMessage(Log log, MessageContext messageContext, - org.apache.synapse.MessageContext synCtx) throws AxisFault { + org.apache.synapse.MessageContext synCtx) + throws AxisFault { AxisService service = messageContext.getAxisService(); if (service != null) { - Parameter inMediationParam = service.getParameter(HandlerConstants.OUT_SEQUENCE_PARAM_NAME); + Parameter inMediationParam + = service.getParameter(HandlerConstants.OUT_SEQUENCE_PARAM_NAME); if (inMediationParam != null && inMediationParam.getValue() != null) { if (inMediationParam.getValue() instanceof Mediator) { Mediator inMessageSequence = (Mediator) inMediationParam.getValue(); @@ -106,12 +112,14 @@ return inMessageSequence.mediate(synCtx); } else { if (log.isDebugEnabled()) { - log.debug("The provided out message mediation sequence is not a proper mediator"); + log.debug("The provided out message mediation " + + "sequence is not a proper mediator"); } } } else { if (log.isDebugEnabled()) { - log.debug("Couldn't find the outgoing mediation for the service " + service.getName()); + log.debug("Couldn't find the outgoing mediation for the service " + + service.getName()); } } } else {