axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r509602 - in /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server: EndpointController.java endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
Date Tue, 20 Feb 2007 15:20:45 GMT
Author: scheu
Date: Tue Feb 20 07:20:44 2007
New Revision: 509602

URL: http://svn.apache.org/viewvc?view=rev&rev=509602
Log:
AXIS2-2227
Contributor: Rich Scheuerle
Don't create SOAPMessageContext unless needed for resource injection or handler invokes.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?view=diff&rev=509602&r1=509601&r2=509602
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
Tue Feb 20 07:20:44 2007
@@ -18,6 +18,7 @@
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.WebServiceException;
 
 import java.io.StringReader;
@@ -28,17 +29,21 @@
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.binding.SOAPBinding;
+import org.apache.axis2.jaxws.context.factory.MessageContextFactory;
+import org.apache.axis2.jaxws.context.utils.ContextUtils;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.core.util.MessageContextUtils;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.handler.SoapMessageContext;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
@@ -51,6 +56,7 @@
 import org.apache.axis2.jaxws.server.dispatcher.factory.EndpointDispatcherFactory;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
+import org.apache.axis2.jaxws.server.endpoint.lifecycle.impl.EndpointLifecycleManagerImpl;
 import org.apache.axis2.jaxws.spi.Constants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -130,7 +136,8 @@
             // the request message if appropriate.
             saveRequestMessage(requestMsgCtx);
             
-            // @TODO Invoke inbound application handlers.
+            // Invoke inbound application handlers.
+            invokeInboundHandlers(requestMsgCtx);
  
             // Dispatch to the 
             EndpointDispatcher dispatcher = getEndpointDispatcher(implClass, serviceInstance);

@@ -141,7 +148,8 @@
                 requestMsgCtx.getMessage().setPostPivot();
             }
             
-            // @TODO Invoke outbound application handlers
+            // Invoke outbound application handlers
+            invokeOutboundHandlers(requestMsgCtx);
             
         } catch (Exception e) {
             // TODO for now, throw it.  We probably should try to make an XMLFault object
and set it on the message
@@ -156,6 +164,68 @@
         return ic;
     }
     
+    /**
+     * Invoke Inbound Handlers
+     * @param requestMsgCtx
+     */
+    private void invokeInboundHandlers(MessageContext requestMsgCtx) {
+        // Stubbed out code
+        int numHandlers = 0;
+        
+        javax.xml.ws.handler.MessageContext handlerMessageContext = null;
+        if (numHandlers > 0) {
+            handlerMessageContext =findOrCreateMessageContext(requestMsgCtx);
+        }
+        
+        // TODO Invoke Handlers
+    }
+    
+    
+    
+    /**
+     * Invoke OutboundHandlers
+     * @param responseMsgCtx
+     */
+    private void invokeOutboundHandlers(MessageContext responseMsgCtx) {
+        // Stubbed out code
+        int numHandlers = 0;
+        
+        javax.xml.ws.handler.MessageContext handlerMessageContext = null;
+        if (numHandlers > 0) {
+            handlerMessageContext =findOrCreateMessageContext(responseMsgCtx);
+        }
+        
+        // TODO Invoke Handlers
+    }
+    
+    /**
+     * Find or Create Handler Message Context
+     * @param mc
+     * @return javax.xml.ws.handler.MessageContext
+     */
+    private javax.xml.ws.handler.MessageContext findOrCreateMessageContext(MessageContext
mc) {
+        // See if a soap message context is already present on the WebServiceContext
+        javax.xml.ws.handler.MessageContext handlerMessageContext = null;
+        ServiceContext serviceContext = mc.getAxisMessageContext().getServiceContext();
+        WebServiceContext ws = (WebServiceContext)serviceContext.getProperty(EndpointLifecycleManagerImpl.WEBSERVICE_MESSAGE_CONTEXT);
+        if (ws != null) {
+            handlerMessageContext = ws.getMessageContext();
+        }
+        if (handlerMessageContext == null) {
+            handlerMessageContext = createSOAPMessageContext(mc);
+        }
+        return handlerMessageContext; 
+    }
+    
+    /**
+     * @param mc
+     * @return new SOAPMessageContext
+     */
+    private javax.xml.ws.handler.MessageContext createSOAPMessageContext(MessageContext mc){
+        SoapMessageContext soapMessageContext = (SoapMessageContext)MessageContextFactory.createSoapMessageContext(mc);
+        ContextUtils.addProperties(soapMessageContext, mc);
+        return soapMessageContext;
+     }
     /*
 	 * Get the appropriate EndpointDispatcher for a given service endpoint.
 	 */

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java?view=diff&rev=509602&r1=509601&r2=509602
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/endpoint/lifecycle/impl/EndpointLifecycleManagerImpl.java
Tue Feb 20 07:20:44 2007
@@ -47,7 +47,7 @@
 import org.apache.commons.logging.LogFactory;
 
 public class EndpointLifecycleManagerImpl implements EndpointLifecycleManager {
-	private static final String WEBSERVICE_MESSAGE_CONTEXT = "javax.xml.ws.WebServiceContext";
+	public static final String WEBSERVICE_MESSAGE_CONTEXT = "javax.xml.ws.WebServiceContext";
 	private static final Log log = LogFactory.getLog(EndpointLifecycleManagerImpl.class);
 	private Object endpointInstance = null;
 	private Class endpointClazz = null;
@@ -69,9 +69,18 @@
 	 */
 	public Object createServiceInstance(MessageContext mc, Class serviceImplClass) throws EndpointLifecycleException,
ResourceInjectionException{
 		org.apache.axis2.context.MessageContext msgContext = mc.getAxisMessageContext();
+        
+		// Get the ServiceDescription and injectionDesc which contain
+        // cached information
+        ServiceDescription serviceDesc = mc.getServiceDescription();
+        ResourceInjectionServiceRuntimeDescription injectionDesc = null;
+        if (serviceDesc != null) {
+            injectionDesc = 
+                ResourceInjectionServiceRuntimeDescriptionFactory.get(serviceDesc, serviceImplClass);
+        }
+        
+        // See if there is an existing service object
         ServiceContext serviceContext = msgContext.getServiceContext();
-        //Create MessageContext for current invocation.
-        javax.xml.ws.handler.MessageContext soapMessageContext = createSOAPMessageContext(mc);
         Object serviceimpl = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT);
         if (serviceimpl != null) {
             this.endpointInstance = serviceimpl;
@@ -80,12 +89,19 @@
         	if (log.isDebugEnabled()) {
                 log.debug("Service Instance found in the service context, reusing the instance");
             }
-           //Get WebServiceContext from ServiceContext
-        	WebServiceContext ws = (WebServiceContext)serviceContext.getProperty(WEBSERVICE_MESSAGE_CONTEXT);
-        	//Add the MessageContext for current invocation
-        	if(ws !=null){
-        		updateWebServiceContext(ws, soapMessageContext);
-        	}
+            
+            // If resource injection is needed, create the SOAPMessageContext and update
the WebServiceContext
+        	// Create MessageContext for current invocation.
+            if (injectionDesc != null && injectionDesc.hasResourceAnnotation()) {
+                javax.xml.ws.handler.MessageContext soapMessageContext = createSOAPMessageContext(mc);
+                //Get WebServiceContext from ServiceContext
+                WebServiceContext ws = (WebServiceContext)serviceContext.getProperty(WEBSERVICE_MESSAGE_CONTEXT);
+                //Add the MessageContext for current invocation
+                if(ws !=null){
+                    updateWebServiceContext(ws, soapMessageContext);
+                }
+            }
+            
         	 //since service impl is there in service context , take that from there
             return serviceimpl;
         } else {
@@ -93,34 +109,28 @@
             serviceimpl = createServiceInstance(serviceImplClass);
             this.endpointInstance = serviceimpl;
             this.endpointClazz = serviceImplClass;
-            
-            // Get the ServiceDescription and injectionDesc which contain
-            // cached information
-            ServiceDescription serviceDesc = mc.getServiceDescription();
-            ResourceInjectionServiceRuntimeDescription injectionDesc = null;
-            if (serviceDesc != null) {
-                injectionDesc = 
-                    ResourceInjectionServiceRuntimeDescriptionFactory.get(serviceDesc, serviceImplClass);
+            if (log.isDebugEnabled()) {
+                log.debug("New Service Instance created");
             }
-
-            //Since Serivce Object is instantiated for the first time I will Inject any resource

-            //and call the PostConstruct lifecycle methods here.
-            
-            //Create WebServiceContext
-            WebServiceContextImpl wsContext = new WebServiceContextImpl();
-            //Add MessageContext for this request.
-            wsContext.setSoapMessageContext(soapMessageContext);
             
-            //Inject WebServiceContext
+            // If resource injection is needed, create the SOAPMessageContext and build the
WebServiceContext
+            // Create MessageContext for current invocation.
             if (injectionDesc != null && injectionDesc.hasResourceAnnotation()) {
+                javax.xml.ws.handler.MessageContext soapMessageContext = createSOAPMessageContext(mc);
+                // Create WebServiceContext
+                WebServiceContextImpl wsContext = new WebServiceContextImpl();
+                //Add MessageContext for this request.
+                wsContext.setSoapMessageContext(soapMessageContext);
+                // Inject WebServiceContext
                 injectWebServiceContext(mc, wsContext, serviceimpl);
+                serviceContext.setProperty(WEBSERVICE_MESSAGE_CONTEXT, wsContext);
+                
             }
             
             //Invoke PostConstruct
             if (injectionDesc != null && injectionDesc.getPostConstructMethod() !=
null) {
                 invokePostConstruct(injectionDesc.getPostConstructMethod());
             }
-            serviceContext.setProperty(WEBSERVICE_MESSAGE_CONTEXT, wsContext);
             serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceimpl);
             return serviceimpl;
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message