You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by de...@apache.org on 2005/12/22 12:37:46 UTC

svn commit: r358558 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/template/java/ core/src/org/apache/axis2/client/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/description/ core/src/org/apache/axis2/engin...

Author: deepal
Date: Thu Dec 22 03:36:57 2005
New Revision: 358558

URL: http://svn.apache.org/viewcvs?rev=358558&view=rev
Log:
1. Removed invalid method from ConfigurationConetxt , getServiceContext();
2. Implemented session management in server side 
  
There can be 4 level of session scope
   1. Request
   2. TransportSessionScope
   3. SOAPSessionScope
   4. ApplicationScope

If the session is TransportSession then the service context and service group context will be stored in SessionContext and Transport guy has to care of setting correct SessionContext in to message context .

To get the full usage of session client has to send the session back.


Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SessionUtils.java
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Stub.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/SessionContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/InstanceDispatcher.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/ContextHierarchyTest.java
    webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/OperationContextTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mail/MailRequestResponseRawXMLTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Thu Dec 22 03:36:57 2005
@@ -52,7 +52,7 @@
         //creating the configuration
         _configurationContext = new org.apache.axis2.context.ConfigurationContextFactory().buildClientConfigurationContext(axis2Home);
         _configurationContext.getAxisConfiguration().addService(_service);
-        _serviceContext =new org.apache.axis2.context.ServiceGroupContext(_configurationContext, _service.getParent()).getServiceContext(_service.getName());
+        _serviceContext =new org.apache.axis2.context.ServiceGroupContext(_configurationContext, _service.getParent()).getServiceContext(_service);
         _clientOptions.setTo(new org.apache.axis2.addressing.EndpointReference(targetEndpoint));
 
         <!--  Set the soap version depending on the binding. Default is 1.1 so don't set anything for that case-->

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/MEPClient.java Thu Dec 22 03:36:57 2005
@@ -145,7 +145,7 @@
 
         configurationContext.getAxisConfiguration().addService(axisService);
         serviceContext = new ServiceGroupContext(configurationContext,
-                axisService.getParent()).getServiceContext(ANONYMOUS_SERVICE);
+                axisService.getParent()).getServiceContext(axisService);
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/ServiceClient.java Thu Dec 22 03:36:57 2005
@@ -97,8 +97,6 @@
 
     /**
      * If the AxisService is null this will create an AnonymousService
-     *
-     * @return
      */
     private AxisService createAnonymousService() {
         // since I have not been created with real service metadata, let's
@@ -128,7 +126,7 @@
     /**
      * Create the service context for myself
      */
-    private void createServiceContext() {
+    private void createServiceContext() throws AxisFault {
         if (axisService == null) {
             axisService = getAxisService();
         }
@@ -136,7 +134,7 @@
         // for myself as I'll need that later for stuff that I gotta do
         ServiceGroupContext sgc = new ServiceGroupContext(configContext,
                 getAxisService().getParent());
-        serviceContext = sgc.getServiceContext(getAxisService().getName());
+        serviceContext = sgc.getServiceContext(getAxisService());
     }
 
     /**
@@ -175,7 +173,6 @@
      *
      * @param headerName
      * @param headerText
-     * @see addHeader(OMElement)
      */
     public void addStringHeader(QName headerName, String headerText) {
         OMElement omElement = OMAbstractFactory.getOMFactory().createOMElement(
@@ -250,7 +247,7 @@
         mepClient.execute(true);
     }
 
-    public OMElement sendReceive(OMElement elem) {
+    public OMElement sendReceive(OMElement elem) throws AxisFault {
         if (serviceContext == null) {
             createServiceContext();
         }
@@ -262,7 +259,7 @@
                 "ServiceClient.sendReceive() is not yet implemented");
     }
 
-    public void sendReceiveNonblocking(OMElement elem, Callback callback) {
+    public void sendReceiveNonblocking(OMElement elem, Callback callback) throws AxisFault {
         if (serviceContext == null) {
             createServiceContext();
         }
@@ -286,7 +283,7 @@
      * @return a MEP client configured to talk to the given operation or null if
      *         the operation name is not found.
      */
-    public OperationClient createClient(QName operation) {
+    public OperationClient createClient(QName operation) throws AxisFault {
         AxisOperation axisOp = getAxisService().getOperation(operation);
         if (serviceContext == null) {
             createServiceContext();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Stub.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Stub.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Stub.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/client/Stub.java Thu Dec 22 03:36:57 2005
@@ -80,8 +80,8 @@
             throw new Exception(
                     "Client is running the session OFF mode: Start session before saving to a session ");
         }
-
-        return _configurationContext.getServiceContext(_currentSessionId).getProperty(key);
+        return null;
+//        return _configurationContext.getServiceContext(_currentSessionId).getProperty(key);
     }
 
     public void _setClientOptions(Options _clientOptions) {
@@ -95,8 +95,7 @@
             throw new Exception(
                     "Client is running the session OFF mode: Start session before saving to a session ");
         }
-
-        _configurationContext.getServiceContext(_currentSessionId).setProperty(key, value);
+//        _configurationContext.getServiceContext(_currentSessionId).setProperty(key, value);
     }
 
     public void _startSession() {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContext.java Thu Dec 22 03:36:57 2005
@@ -18,18 +18,16 @@
 package org.apache.axis2.context;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.description.AxisServiceGroup;
 import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.util.SessionUtils;
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.axis2.util.threadpool.ThreadFactory;
 import org.apache.axis2.util.threadpool.ThreadPool;
 
 import java.io.File;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
 
 /**
  * This contains all the configuration information for Axis2.
@@ -41,7 +39,6 @@
      * <code>OperationContext</code> mapping.
      */
     private final Map operationContextMap = new HashMap();
-    private final Map serviceContextMap = new Hashtable();
     private Hashtable serviceGroupContextMap = new Hashtable();
     private transient AxisConfiguration axisConfiguration;
     private File rootDir;
@@ -77,6 +74,7 @@
             MessageContext messageContext)
             throws AxisFault {
         String serviceGroupContextId = messageContext.getServiceGroupContextId();
+        SessionContext sessionContext = messageContext.getSessionContext();
 
         // by this time service group context id must have a value. Either from transport or from addressing
         ServiceGroupContext serviceGroupContext;
@@ -89,7 +87,7 @@
             serviceGroupContext =
                     getServiceGroupContext(serviceGroupContextId);
             serviceContext =
-                    serviceGroupContext.getServiceContext(messageContext.getAxisService().getName());
+                    serviceGroupContext.getServiceContext(messageContext.getAxisService());
         } else {
 
             // either the key is null or no SGC is found from the give key
@@ -102,17 +100,32 @@
                 AxisServiceGroup axisServiceGroup = messageContext.getAxisService().getParent();
 
                 serviceGroupContext = new ServiceGroupContext(this, axisServiceGroup);
-                serviceContext = serviceGroupContext.getServiceContext(
-                        messageContext.getAxisService().getName());
+                serviceContext = serviceGroupContext.getServiceContext(messageContext.getAxisService());
 
                 // set the serviceGroupContextID
                 serviceGroupContext.setId(serviceGroupContextId);
-                this.registerServiceGroupContext(serviceGroupContext);
             } else {
                 throw new AxisFault("AxisService Not found yet");
             }
         }
 
+        /**
+         * 1. Check the max scope of the service gruop , if it is grater than TarnsportSession
+         *    then need to store in configurationContext
+         * 2. Else need to store in SessionContext , and need to store both service context and
+         *    service group context
+         */
+        String maxScope = SessionUtils.calculateMaxScopeForServiceGroup(serviceGroupContext.getDescription());
+        if (Constants.APPLICATION_SCOPE.equals(maxScope)) {
+            //todo : needed to add to two tables
+            registerServiceGroupContext(serviceGroupContext);
+        } else if (Constants.TRANSPORT_SESSION_SCOPE.equals(maxScope)) {
+            //todo : needed to add to two tables
+            registerServiceGroupContext(serviceGroupContext);
+        } else {
+            sessionContext.addServiceGroupContext(serviceGroupContext, serviceGroupContextId);
+            sessionContext.addServiceContext(serviceContext);
+        }
         // when you come here operation context MUST already been assigned to the message context
         messageContext.getOperationContext().setParent(serviceContext);
         messageContext.setServiceContext(serviceContext);
@@ -176,18 +189,10 @@
         }
     }
 
-    /**
-     * Gets the ServiceContext for a service id.
-     *
-     * @param serviceInstanceID
-     */
-    public ServiceContext getServiceContext(String serviceInstanceID) {
-        return (ServiceContext) this.serviceContextMap.get(serviceInstanceID);
-    }
-
     public synchronized ServiceGroupContext getServiceGroupContext(String serviceGroupContextId) {
         if (serviceGroupContextMap != null) {
-            ServiceGroupContext serviceGroupContext = (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupContextId);
+            ServiceGroupContext serviceGroupContext = (ServiceGroupContext)
+                    serviceGroupContextMap.get(serviceGroupContextId);
             if (serviceGroupContext != null) {
                 serviceGroupContext.touch();
             }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java Thu Dec 22 03:36:57 2005
@@ -844,7 +844,6 @@
      */
     public void setServiceContext(ServiceContext context) {
         serviceContext = context;
-
         if ((operationContext != null)
                 && (operationContext.getParent() != null)) {
             operationContext.setParent(context);
@@ -853,6 +852,10 @@
         if (configurationContext == null) {
             //setting configcontext
             configurationContext = context.getConfigurationContext();
+        }
+        if (serviceGroupContext == null) {
+            //setting service group context
+            serviceGroupContext = context.getServiceGroupContext();
         }
         this.setAxisService(context.getAxisService());
     }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceContext.java Thu Dec 22 03:36:57 2005
@@ -27,11 +27,17 @@
  * So do NOT use this as it might not live up to your expectation.
  */
 public class ServiceContext extends AbstractContext {
+
     private transient AxisService axisService;
     private String serviceInstanceID;
+    private ServiceGroupContext serviceGroupContext;
+
+    //to store service implementation class , to handler session
+    private Object serviceImpl;
 
     public ServiceContext(AxisService serviceConfig, ServiceGroupContext serviceGroupContext) {
         super(serviceGroupContext);
+        this.serviceGroupContext = serviceGroupContext;
         this.axisService = serviceConfig;
 
         if (serviceConfig != null) {
@@ -69,5 +75,17 @@
 
         // todo we do not need this , this ID should equal to serviceName
         this.serviceInstanceID = serviceInstanceID;
+    }
+
+    public Object getServiceImpl() {
+        return serviceImpl;
+    }
+
+    public void setServiceImpl(Object serviceImpl) {
+        this.serviceImpl = serviceImpl;
+    }
+
+    public ServiceGroupContext getServiceGroupContext() {
+        return serviceGroupContext;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ServiceGroupContext.java Thu Dec 22 03:36:57 2005
@@ -17,6 +17,8 @@
 
 package org.apache.axis2.context;
 
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
 
@@ -25,7 +27,7 @@
 import java.util.Map;
 
 public class ServiceGroupContext extends AbstractContext {
-    private String axisServiceGroupName;
+
     private transient AxisServiceGroup axisServiceGroup;
     private String id;
     private Map serviceContextMap;
@@ -34,29 +36,6 @@
         super(parent);
         this.axisServiceGroup = axisServiceGroup;
         serviceContextMap = new HashMap();
-
-        if (axisServiceGroup != null) {
-            this.axisServiceGroupName = axisServiceGroup.getServiceGroupName();
-        }
-
-        fillServiceContexts();
-    }
-
-    /**
-     * This will create one ServiceContext per each serviceDesc in descrpition
-     * if serviceGroup desc has 2 service init , then two serviceContext will be
-     * created
-     */
-    private void fillServiceContexts() {
-        Iterator services = axisServiceGroup.getServices();
-
-        while (services.hasNext()) {
-            AxisService axisService = (AxisService) services.next();
-            ServiceContext serviceContext = new ServiceContext(axisService, this);
-            String serviceName = axisService.getName();
-
-            serviceContextMap.put(serviceName, serviceContext);
-        }
     }
 
     public AxisServiceGroup getDescription() {
@@ -67,9 +46,34 @@
         return id;
     }
 
-    // if the service name is foo:bar , you should pass only bar
-    public ServiceContext getServiceContext(String serviceName) {
-        return (ServiceContext) serviceContextMap.get(serviceName);
+    /**
+     * At each time you ask for a service context this will create a new one by
+     * passing AxisService into it , and no need to store service context inside serviceGroup
+     * context as well
+     *
+     * @param service
+     * @return
+     * @throws AxisFault
+     */
+    public ServiceContext getServiceContext(AxisService service) throws AxisFault {
+        AxisService axisService = axisServiceGroup.getService(service.getName());
+        if (axisService == null) {
+            throw new AxisFault("Invalid service " + service.getName() + " not belong to " +
+                    "service group " + axisServiceGroup.getServiceGroupName());
+        }
+        String scope = axisService.getScope();
+        ServiceContext serviceContext;
+        if (Constants.APPLICATION_SCOPE.equals(scope) || Constants.SOAP_SESSION_SCOPE.equals(scope)) {
+            //since the session scope is longer that trasport or request we need to store that some where
+            serviceContext = (ServiceContext) serviceContextMap.get(service.getName());
+            if (serviceContext == null) {
+                serviceContext = new ServiceContext(service, this);
+            }
+            serviceContextMap.put(service.getName(), serviceContext);
+        } else {
+            serviceContext = new ServiceContext(service, this);
+        }
+        return serviceContext;
     }
 
     public Iterator getServiceContexts() {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/SessionContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/SessionContext.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/SessionContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/SessionContext.java Thu Dec 22 03:36:57 2005
@@ -18,14 +18,20 @@
 package org.apache.axis2.context;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.AxisConfiguration;
 
+import java.util.HashMap;
+
 /**
  * All the engine components are stateless across the executions and all the states should be kept in the
  * Contexts, there are three context Global, Session and Message.
  */
 public class SessionContext extends AbstractContext {
 
+    private HashMap serviceContextMap = new HashMap();
+    private HashMap serviceGroupContextMap = new HashMap();
+
     /**
      * @param parent
      */
@@ -35,4 +41,21 @@
 
     public void init(AxisConfiguration axisConfiguration) throws AxisFault {
     }
+
+    public ServiceContext getServiceContext(AxisService axisService) {
+        return (ServiceContext) serviceContextMap.get(axisService.getName());
+    }
+
+    public void addServiceContext(ServiceContext serviceContext) {
+        serviceContextMap.put(serviceContext.getAxisService().getName(), serviceContext);
+    }
+
+    public void addServiceGroupContext(ServiceGroupContext serviceGroupContext, String serviceGroupID) {
+        serviceGroupContextMap.put(serviceGroupID, serviceGroupContext);
+    }
+
+    public ServiceGroupContext getServiceGroupContext(String serviceGroupID) {
+        return (ServiceGroupContext) serviceGroupContextMap.get(serviceGroupID);
+    }
+
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java Thu Dec 22 03:36:57 2005
@@ -165,7 +165,7 @@
         }
     }
 
-    public void removeService(QName name) throws AxisFault {
+    public void removeService(String name) throws AxisFault {
         AxisService service = getService(name);
 
         if (service != null) {
@@ -203,7 +203,7 @@
         return parent;
     }
 
-    public AxisService getService(QName name) throws AxisFault {
+    public AxisService getService(String name) throws AxisFault {
         return (AxisService) services.get(name);
     }
 

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/InstanceDispatcher.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/InstanceDispatcher.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/InstanceDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/InstanceDispatcher.java Thu Dec 22 03:36:57 2005
@@ -18,11 +18,10 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ServiceContext;
-import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.*;
 import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.handlers.AbstractHandler;
 
 /**
@@ -47,6 +46,8 @@
 
             return;
         }
+        //trying to get service context from Session context
+        fillContextsFromSessionContetxt(msgContext);
 
         AxisOperation axisOperation = msgContext.getAxisOperation();
 
@@ -70,16 +71,43 @@
             msgContext.setServiceContext(serviceContext);
             msgContext.setServiceGroupContext(serviceGroupContext);
             msgContext.setServiceGroupContextId(serviceGroupContext.getId());
-
-            return;
         } else {    // 2. if null, create new opCtxt
             operationContext = new OperationContext(axisOperation);
 
             axisOperation.registerOperationContext(msgContext, operationContext);
+            if (msgContext.getServiceContext() != null) {
+                // no need to added to configuration conetxt , since we are happy in
+                //  storing in session context
+                operationContext.setParent(msgContext.getServiceContext());
+            } else {
+                // fill the service group context and service context info
+                msgContext.getConfigurationContext().fillServiceContextAndServiceGroupContext(
+                        msgContext);
+            }
+        }
+    }
 
-            // fill the service group context and service context info
-            msgContext.getConfigurationContext().fillServiceContextAndServiceGroupContext(
-                    msgContext);
+    private void fillContextsFromSessionContetxt(MessageContext msgContext) throws AxisFault {
+        AxisService service = msgContext.getAxisService();
+        if (service == null) {
+            throw new AxisFault("AxisService Not found yet");
+        }
+        SessionContext sessionContext = msgContext.getSessionContext();
+        String serviceGroupContextId = msgContext.getServiceGroupContextId();
+        if (serviceGroupContextId != null) {
+            //setting service group context which is teken from session context
+            msgContext.setServiceGroupContext(
+                    sessionContext.getServiceGroupContext(serviceGroupContextId));
+        }
+        String scope = service.getScope();
+
+        if (Constants.TRANSPORT_SESSION_SCOPE.equals(scope)) {
+            ServiceContext sreviceContext = sessionContext.getServiceContext(service);
+            //found the serviceContext from session context , so adding that into msgContext
+            if (sreviceContext != null) {
+                msgContext.setServiceContext(sreviceContext);
+            }
         }
     }
+
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/receivers/AbstractMessageReceiver.java Thu Dec 22 03:36:57 2005
@@ -18,10 +18,8 @@
 package org.apache.axis2.receivers;
 
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.SessionContext;
+import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.MessageReceiver;
@@ -85,40 +83,16 @@
      * @throws AxisFault
      */
     protected Object getTheImplementationObject(MessageContext msgContext) throws AxisFault {
-        AxisService service =
-                msgContext.getOperationContext().getServiceContext().getAxisService();
-        Parameter scopeParam = service.getParameter(SCOPE);
-        String serviceName = service.getName();
-
-        if ((scopeParam != null) && Constants.SESSION_SCOPE.equals(scopeParam.getValue())) {
-            SessionContext sessionContext = msgContext.getSessionContext();
-
-            synchronized (sessionContext) {
-                Object obj = sessionContext.getProperty(serviceName);
-
-                if (obj == null) {
-                    obj = makeNewServiceObject(msgContext);
-                    sessionContext.setProperty(serviceName, obj);
-                }
-
-                return obj;
-            }
-        } else if ((scopeParam != null)
-                && Constants.APPLICATION_SCOPE.equals(scopeParam.getValue())) {
-            ConfigurationContext globalContext = msgContext.getConfigurationContext();
-
-            synchronized (globalContext) {
-                Object obj = globalContext.getProperty(serviceName);
-
-                if (obj == null) {
-                    obj = makeNewServiceObject(msgContext);
-                    globalContext.setProperty(serviceName, obj);
-                }
-
-                return obj;
-            }
+        ServiceContext serviceContext = msgContext.getOperationContext().getServiceContext();
+        Object serviceimpl = serviceContext.getServiceImpl();
+        if (serviceimpl != null) {
+            // since service impl is there in service context , take that from there
+            return serviceimpl;
         } else {
-            return makeNewServiceObject(msgContext);
+            // create a new service impl class for that service
+            serviceimpl = makeNewServiceObject(msgContext);
+            serviceContext.setServiceImpl(serviceimpl);
+            return serviceimpl;
         }
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPWorker.java Thu Dec 22 03:36:57 2005
@@ -66,7 +66,6 @@
             if (configurationContext == null) {
                 throw new AxisFault(Messages.getMessage("cannotBeNullConfigurationContext"));
             }
-
             InputStream inStream = request.getBody();
             TransportOutDescription transportOut =
                     configurationContext.getAxisConfiguration().getTransportOut(

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SimpleHTTPServer.java Thu Dec 22 03:36:57 2005
@@ -75,7 +75,7 @@
      *
      * @param systemContext
      */
-    public SimpleHTTPServer(ConfigurationContext systemContext, int port) throws IOException {
+    public SimpleHTTPServer(ConfigurationContext systemContext, int port) {
         this(systemContext, port, null);
     }
 
@@ -95,9 +95,7 @@
      * @param systemContext
      * @param pool
      */
-    public SimpleHTTPServer(ConfigurationContext systemContext, int port, ThreadFactory pool)
-            throws IOException {
-
+    public SimpleHTTPServer(ConfigurationContext systemContext, int port, ThreadFactory pool) {
         // If a threadPool is not passed-in the threadpool
         // from the ConfigurationContext
         // is used. This is a bit tricky, and might cause a

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SessionUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SessionUtils.java?rev=358558&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SessionUtils.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/SessionUtils.java Thu Dec 22 03:36:57 2005
@@ -0,0 +1,75 @@
+package org.apache.axis2.util;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisServiceGroup;
+
+import java.util.Iterator;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* @author : Deepal Jayasinghe (deepal@apache.org)
+*
+*/
+
+public class SessionUtils {
+
+    public static String calculateMaxScopeForServiceGroup(AxisServiceGroup axisServiceGroup) {
+        Iterator servics = axisServiceGroup.getServices();
+        int maxScope = 1;
+        while (servics.hasNext()) {
+            AxisService axisService = (AxisService) servics.next();
+            int scopeIntValue = getScopeIntValue(axisService.getScope());
+            if (maxScope < scopeIntValue) {
+                maxScope = scopeIntValue;
+            }
+        }
+        return getScopeString(maxScope);
+    }
+
+    private static int getScopeIntValue(String scope) {
+        if (Constants.REQUEST_SCOPE.equals(scope)) {
+            return 1;
+        } else if (Constants.TRANSPORT_SESSION_SCOPE.equals(scope)) {
+            return 2;
+        } else if (Constants.SOAP_SESSION_SCOPE.equals(scope)) {
+            return 3;
+        } else if (Constants.APPLICATION_SCOPE.equals(scope)) {
+            return 4;
+        } else {
+            return 2;
+        }
+    }
+
+    private static String getScopeString(int scope) {
+        switch (scope) {
+            case 1 : {
+                return Constants.REQUEST_SCOPE;
+            }
+            case 2 : {
+                return Constants.TRANSPORT_SESSION_SCOPE;
+            }
+            case 3 : {
+                return Constants.SOAP_SESSION_SCOPE;
+            }
+            case 4 : {
+                return Constants.APPLICATION_SCOPE;
+            }
+            default : {
+                return Constants.TRANSPORT_SESSION_SCOPE;
+            }
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/ContextHierarchyTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/ContextHierarchyTest.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/ContextHierarchyTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/ContextHierarchyTest.java Thu Dec 22 03:36:57 2005
@@ -51,7 +51,7 @@
         ServiceGroupContext serviceGroupContext = new ServiceGroupContext(
                 configurationContext, axisService.getParent());
         ServiceContext serviceContext = serviceGroupContext
-                .getServiceContext(axisService.getName());
+                .getServiceContext(axisService);
         MessageContext msgctx = new MessageContext(configurationContext);
         OperationContext opContext = axisOperation.findOperationContext(msgctx,
                 serviceContext);

Modified: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/OperationContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/OperationContextTest.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/OperationContextTest.java (original)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/context/OperationContextTest.java Thu Dec 22 03:36:57 2005
@@ -45,7 +45,7 @@
         ServiceGroupContext sgc = new ServiceGroupContext(configContext,
                 axisService.getParent());
 
-        ServiceContext sessionContext = sgc.getServiceContext("TempSC");
+        ServiceContext sessionContext = sgc.getServiceContext(axisService);
         MessageContext messageContext1 = this.getBasicMessageContext();
 
         messageContext1.setMessageID(UUIDGenerator.getUUID());

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/integration/UtilServer.java Thu Dec 22 03:36:57 2005
@@ -40,7 +40,7 @@
 
     public static final String FAILURE_MESSAGE = "Intentional Failure";
 
-    private static ThreadPool tp = null;
+//    private static ThreadPool tp = null;
 
     public static synchronized void deployService(AxisService service)
             throws AxisFault {
@@ -67,7 +67,6 @@
 
     public static synchronized void start(String repository) throws Exception {
         if (count == 0) {
-            tp = new ThreadPool();
             ConfigurationContext er = getNewConfigurationContext(repository);
 
             receiver = new SimpleHTTPServer(er, Constants.TESTING_PORT);
@@ -139,7 +138,7 @@
         configContext.getAxisConfiguration().addService(service);
 
         return new ServiceGroupContext(configContext, service.getParent())
-                .getServiceContext(service.getName());
+                .getServiceContext(service);
     }
 
     public static ServiceContext createAdressedEnabledClientSide(
@@ -161,7 +160,7 @@
         configContext.getAxisConfiguration().addService(service);
 
         return new ServiceGroupContext(configContext, service.getParent())
-                .getServiceContext(service.getName());
+                .getServiceContext(service);
     }
 
 }

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mail/MailRequestResponseRawXMLTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mail/MailRequestResponseRawXMLTest.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mail/MailRequestResponseRawXMLTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/mail/MailRequestResponseRawXMLTest.java Thu Dec 22 03:36:57 2005
@@ -32,7 +32,6 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.OutInAxisOperation;
-import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Echo;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.om.OMAbstractFactory;
@@ -59,18 +58,9 @@
 
     private QName operationName = new QName("echoOMElement");
 
-    private QName transportName = new QName("http://localhost/my",
-            "NullTransport");
-
-    private AxisConfiguration engineRegistry;
-
-    private MessageContext mc;
-
-    private SOAPEnvelope envelope;
-
     private boolean finish = false;
 
-    private ConfigurationContext config;
+    private SOAPEnvelope envelope;
 
     public MailRequestResponseRawXMLTest() {
         super(MailRequestResponseRawXMLTest.class.getName());
@@ -119,15 +109,14 @@
         AxisOperation axisOperation = new OutInAxisOperation();
         axisOperation.setName(operationName);
         axisOperation.setMessageReceiver(new MessageReceiver() {
-            public void receive(MessageContext messgeCtx) throws AxisFault {
+            public void receive(MessageContext messgeCtx) {
                 envelope = messgeCtx.getEnvelope();
             }
         });
         service.addOperation(axisOperation);
         configContext.getAxisConfiguration().addService(service);
         ServiceContext serviceContext = new ServiceGroupContext(configContext,
-                service.getParent()).getServiceContext(service.getName()
-        );
+                service.getParent()).getServiceContext(service);
 
         org.apache.axis2.client.Call call = new org.apache.axis2.client.Call(
                 serviceContext);

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java?rev=358558&r1=358557&r2=358558&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/processingModel/SoapProcessingModelTest.java Thu Dec 22 03:36:57 2005
@@ -81,7 +81,7 @@
 
             ServiceContext serviceContext = new ServiceGroupContext(
                     configContext, service.getParent())
-                    .getServiceContext(service.getName());
+                    .getServiceContext(service);
             inOutMC = new InOutMEPClient(serviceContext);
 
             MessageContext msgctx = new MessageContext(serviceContext