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 2009/07/28 08:45:27 UTC

svn commit: r798418 - in /synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler: SynapseModule.java util/HandlerUtil.java

Author: ruwan
Date: Tue Jul 28 06:45:27 2009
New Revision: 798418

URL: http://svn.apache.org/viewvc?rev=798418&view=rev
Log:
Fixing the handler module

Modified:
    synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java
    synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java

Modified: synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java?rev=798418&r1=798417&r2=798418&view=diff
==============================================================================
--- synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java (original)
+++ synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/SynapseModule.java Tue Jul 28 06:45:27 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/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java?rev=798418&r1=798417&r2=798418&view=diff
==============================================================================
--- synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java (original)
+++ synapse/trunk/java/modules/handler/src/main/java/org/apache/synapse/handler/util/HandlerUtil.java Tue Jul 28 06:45:27 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 {