geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r545625 - in /geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo: POJOEndpointLifecycleManager.java POJOEndpointLifecycleManagerFactory.java POJOWebServiceContainer.java
Date Fri, 08 Jun 2007 21:14:15 GMT
Author: gawor
Date: Fri Jun  8 14:14:14 2007
New Revision: 545625

URL: http://svn.apache.org/viewvc?view=rev&rev=545625
Log:
reworked some instance managment

Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java?view=diff&rev=545625&r1=545624&r2=545625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
Fri Jun  8 14:14:14 2007
@@ -25,45 +25,22 @@
 import org.apache.axis2.jaxws.handler.SoapMessageContext;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
-import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
 
 public class POJOEndpointLifecycleManager implements EndpointLifecycleManager {
-
-    private JAXWSAnnotationProcessor annotationProcessor;
-    private Object instance;
-    
-    public POJOEndpointLifecycleManager(JAXWSAnnotationProcessor annotationProcessor) {
-        this.annotationProcessor = annotationProcessor;        
-    }
-    
+        
     /* 
      * This method is called on each web service call.
      */
     public Object createServiceInstance(MessageContext context, Class serviceClass) throws
EndpointLifecycleException {
-        if (context == null) {
-            // This is a special case, called at init time
-            createServiceInstance(serviceClass);
-        } else {
-            org.apache.axis2.context.MessageContext msgContext = context.getAxisMessageContext();
-            
-            ServiceContext serviceContext = msgContext.getServiceContext();
-            serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, this.instance);
-            
-            // associate JAX-WS MessageContext with the thread
-            POJOWebServiceContext.setMessageContext(createSOAPMessageContext(context)); 
-        }
+        org.apache.axis2.context.MessageContext msgContext = context.getAxisMessageContext();
         
-        return this.instance;
-    }
-    
-    private void createServiceInstance(Class serviceClass) throws EndpointLifecycleException
{
-        try {
-            this.instance = serviceClass.newInstance();
-            this.annotationProcessor.processAnnotations(instance);
-            this.annotationProcessor.invokePostConstruct(instance);
-        } catch (Exception e) {
-            throw new EndpointLifecycleException(e);
-        }
+        ServiceContext serviceContext = msgContext.getServiceContext();                
+        Object instance = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT);
+        
+        // associate JAX-WS MessageContext with the thread
+        POJOWebServiceContext.setMessageContext(createSOAPMessageContext(context)); 
+        
+        return instance;
     }
     
     private javax.xml.ws.handler.MessageContext createSOAPMessageContext(MessageContext mc)
{
@@ -77,9 +54,6 @@
     }
 
     public void invokePreDestroy() throws EndpointLifecycleException {
-        if (this.instance != null) {
-            this.annotationProcessor.invokePreDestroy(this.instance);
-        }
     }
    
 }

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java?view=diff&rev=545625&r1=545624&r2=545625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
Fri Jun  8 14:14:14 2007
@@ -21,14 +21,13 @@
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
-import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
 
 public class POJOEndpointLifecycleManagerFactory extends EndpointLifecycleManagerFactory
{
 
     private EndpointLifecycleManager lifecycleManager;
 
-    public POJOEndpointLifecycleManagerFactory(JAXWSAnnotationProcessor annotationProcessor)
{
-        this.lifecycleManager = new POJOEndpointLifecycleManager(annotationProcessor);  
     
+    public POJOEndpointLifecycleManagerFactory() {
+        this.lifecycleManager = new POJOEndpointLifecycleManager();        
     }
 
     @Override

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java?view=diff&rev=545625&r1=545624&r2=545625
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
Fri Jun  8 14:14:14 2007
@@ -26,12 +26,11 @@
 
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jaxws.binding.BindingImpl;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
-import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException;
-import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPTransportUtils;
@@ -59,7 +58,6 @@
     private Object endpointInstance;
     private List<Handler> chain;
     private String contextRoot = null;
-    private EndpointLifecycleManager lifecycleManager;
     
     public POJOWebServiceContainer(PortInfo portInfo,
                                    String endpointClassName,
@@ -71,17 +69,24 @@
     
     @Override
     public void init() throws Exception {
+        // XXX: This is a global operation
+        FactoryRegistry.setFactory(EndpointLifecycleManagerFactory.class, 
+                                   new POJOEndpointLifecycleManagerFactory());
+        
         super.init();
         
+        this.endpointInstance = this.endpointClass.newInstance();
+        
         this.configurationContext.setServicePath(this.portInfo.getLocation());
         this.annotationProcessor = 
             new JAXWSAnnotationProcessor(this.jndiResolver, new POJOWebServiceContext());
-        POJOEndpointLifecycleManagerFactory factory = 
-            new POJOEndpointLifecycleManagerFactory(this.annotationProcessor);
-        this.lifecycleManager = factory.createEndpointLifecycleManager();
-        this.endpointInstance = this.lifecycleManager.createServiceInstance(null, this.endpointClass);
-        
-        FactoryRegistry.setFactory(EndpointLifecycleManagerFactory.class, factory);
+
+        // inject resources into service
+        try {
+            injectResources(this.endpointInstance);
+        } catch (AnnotationException e) {
+            throw new WebServiceException("Service resource injection failed", e);
+        }
     }
     
     @Override
@@ -97,6 +102,9 @@
         
         setMsgContextProperties(msgContext, service, response, request);
 
+        ServiceContext serviceContext = msgContext.getServiceContext();
+        serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, this.endpointInstance);
+        
         initHandlers();
         try {
             HTTPTransportUtils.processHTTPPostRequest(msgContext,
@@ -122,7 +130,7 @@
         
         super.setMsgContextProperties(msgContext, service, response, request);
     }
-    
+        
     protected void initHandlers() {
         // configure and inject handlers
         try {
@@ -183,11 +191,9 @@
     
     @Override
     public void destroy() {
-        // invoke @preDestroy methods
-        try {
-            this.lifecycleManager.invokePreDestroy();
-        } catch (EndpointLifecycleException e) {
-            LOG.warn("", e);
+        // call service preDestroy
+        if (this.endpointInstance != null) {
+            this.annotationProcessor.invokePreDestroy(this.endpointInstance);
         }
         
         super.destroy();



Mime
View raw message