Author: ruwan
Date: Sun Apr 26 19:57:55 2009
New Revision: 34150
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=34150

Log:
ServerContextInfirmation to carry the SynapseConfig and the SynapseEnv

Modified:
   
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
   
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerContextInformation.java
   
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerManager.java

Modified: 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java?rev=34150&r1=34149&r2=34150&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
       (original)
+++ 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/Axis2SynapseController.java
       Sun Apr 26 19:57:55 2009
@@ -84,9 +84,9 @@
     /**
      * Initiates the  Axis2 Based Server Environment
      *
-     * @param configurationInformation ServerConfigurationInformation Instance
-     * @param contextInformation       Server Context if the Axis2 Based Server
-     *                                 Environment has been already set up.
+     * @param serverConfigurationInformation ServerConfigurationInformation 
Instance
+     * @param contextInformation Server Context if the Axis2 Based Server 
Environment has been
+     *          already set up.
      */
     public void init(ServerConfigurationInformation 
serverConfigurationInformation,
                      ServerContextInformation contextInformation) {
@@ -94,7 +94,7 @@
         log.info("Initializing Synapse at : " + new Date());
 
         this.serverConfigurationInformation = serverConfigurationInformation;
-        
+
         /* If no system property for the JMX agent is specified from outside, 
use a default one
            to show all MBeans (including the Axis2-MBeans) within the Synapse 
tree */
         if (System.getProperty(JMX_AGENT_NAME) == null) {
@@ -189,11 +189,11 @@
                 listenerManager.start();
             } else {
                 handleFatal("Couldn't start Synapse, ListenerManager not 
found");
-            }
+            }
             /* if JMX Adapter has been configured and started, output usage 
information rather
                at the end of the startup process to make it more obvious */
             if (jmxAdapter != null && jmxAdapter.isRunning()) {
-                log.info("Management using JMX available via: " 
+                log.info("Management using JMX available via: "
                         + jmxAdapter.getJmxInformation().getJmxUrl());
             }
         }
@@ -277,13 +277,12 @@
             throw new SynapseException("Synapse startup failed", axisFault);
         }
 
-        Parameter synapseEnvironmentParameter = new 
Parameter(SynapseConstants.SYNAPSE_ENV, null);
         synapseEnvironment = new Axis2SynapseEnvironment(
                 configurationContext, synapseConfiguration);
-        synapseEnvironmentParameter.setValue(synapseEnvironment);
-
         MessageContextCreatorForAxis2.setSynEnv(synapseEnvironment);
 
+        Parameter synapseEnvironmentParameter = new Parameter(
+                SynapseConstants.SYNAPSE_ENV, synapseEnvironment);
         try {
             
configurationContext.getAxisConfiguration().addParameter(synapseEnvironmentParameter);
         } catch (AxisFault e) {
@@ -318,13 +317,11 @@
 
         // Set the Axis2 ConfigurationContext to the SynapseConfiguration
         
synapseConfiguration.setAxisConfiguration(configurationContext.getAxisConfiguration());
-
-        // set the Synapse configuration and environment into the Axis2 
configuration
-        Parameter synapseConfigurationParameter = new Parameter(
-                SynapseConstants.SYNAPSE_CONFIG, null);
-        synapseConfigurationParameter.setValue(synapseConfiguration);
         MessageContextCreatorForAxis2.setSynConfig(synapseConfiguration);
 
+        // set the Synapse configuration into the Axis2 configuration
+        Parameter synapseConfigurationParameter = new Parameter(
+                SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration);
         try {
             
configurationContext.getAxisConfiguration().addParameter(synapseConfigurationParameter);
         } catch (AxisFault e) {
@@ -371,7 +368,7 @@
                 // SynapseServer shutdown hook.
                 listenerManager.setShutdownHookRequired(false);
             }
-            
+
         } catch (Throwable t) {
             handleFatal("Failed to create a new Axis2 instance...", t);
         }

Modified: 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerContextInformation.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerContextInformation.java?rev=34150&r1=34149&r2=34150&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerContextInformation.java
     (original)
+++ 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerContextInformation.java
     Sun Apr 26 19:57:55 2009
@@ -1,4 +1,4 @@
-/*
+/**
  *  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
@@ -18,6 +18,9 @@
  */
 package org.apache.synapse;
 
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.core.SynapseEnvironment;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -25,11 +28,15 @@
  * Encapsulates server context information
  */
 public class ServerContextInformation {
-    
+
     /* Underlying server's context - EX : Axis2 ConfigurationConext */
     private Object serverContext;
     /* A map to hold any context information*/
     private final Map<String, Object> properties = new HashMap<String, 
Object>();
+    /* Keeps the SynapseConfiguration */
+    private SynapseConfiguration synapseConfiguration;
+    /* Keeps the SynapseEnvironment */
+    private SynapseEnvironment synapseEnvironment;
 
     private ServerState serverState = ServerState.UNDETERMINED;
 
@@ -63,4 +70,20 @@
     public void setServerState(ServerState serverState) {
         this.serverState = serverState;
     }
+
+    public SynapseConfiguration getSynapseConfiguration() {
+        return synapseConfiguration;
+    }
+
+    public void setSynapseConfiguration(SynapseConfiguration 
synapseConfiguration) {
+        this.synapseConfiguration = synapseConfiguration;
+    }
+
+    public SynapseEnvironment getSynapseEnvironment() {
+        return synapseEnvironment;
+    }
+
+    public void setSynapseEnvironment(SynapseEnvironment synapseEnvironment) {
+        this.synapseEnvironment = synapseEnvironment;
+    }
 }

Modified: 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
URL: 
http://wso2.org/svn/browse/wso2/branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerManager.java?rev=34150&r1=34149&r2=34150&view=diff
==============================================================================
--- 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
        (original)
+++ 
branches/synapse/1.3-wso2v1/modules/core/src/main/java/org/apache/synapse/ServerManager.java
        Sun Apr 26 19:57:55 2009
@@ -98,7 +98,7 @@
      * Destroyes the Server instance. If the Server is stopped this will 
destroy the
      * ServerManager, and if it is running (i.e. in the STARTED state) this 
will first stop the
      * ServerManager and destroy it in turn
-     * 
+     *
      * @return the state after the destruction, {...@link 
org.apache.synapse.ServerState#UNDETERMINED}
      */
     public synchronized ServerState destroy() {
@@ -129,7 +129,7 @@
         this.synapseController = null;
         this.contextInformation = null;
         this.configurationInformation = null;
-        
+
         this.initialized = false;
         return ServerState.UNDETERMINED;
     }
@@ -145,7 +145,7 @@
 
         // if the system is not initialized we are not happy
         assertInitialized();
-        
+
         // starts the system
         doStart();
         return this.contextInformation.getServerState();
@@ -170,7 +170,7 @@
             String message = "Couldn't stop the ServerManager, it has not been 
started yet";
             handleException(message);
         }
-        
+
         return this.contextInformation.getServerState();
     }
 
@@ -273,9 +273,11 @@
         if (serverState == ServerState.INITIALIZED || serverState == 
ServerState.STOPPED) {
 
             // creates the Synapse Configuration using the SynapseController
-            synapseController.createSynapseConfiguration();
+            contextInformation.setSynapseConfiguration(
+                    synapseController.createSynapseConfiguration());
             // creates the Synapse Environment using the SynapseController
-            synapseController.createSynapseEnvironment();
+            contextInformation.setSynapseEnvironment(
+                    synapseController.createSynapseEnvironment());
             // starts the SynapseController
             synapseController.start();
 
@@ -301,8 +303,10 @@
             synapseController.stop();
             // destroy the created Synapse Configuration
             synapseController.destroySynapseConfiguration();
+            contextInformation.setSynapseConfiguration(null);
             // destroy the created Synapse Environment
             synapseController.destroySynapseEnvironment();
+            contextInformation.setSynapseEnvironment(null);
 
             chanageState(ServerState.STOPPED);
         } else {

_______________________________________________
Esb-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev

Reply via email to