geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r545552 - in /geronimo/server/trunk/modules/geronimo-axis2/src: main/java/org/apache/geronimo/axis2/ main/java/org/apache/geronimo/axis2/client/ main/java/org/apache/geronimo/axis2/ejb/ main/java/org/apache/geronimo/axis2/pojo/ test/java/or...
Date Fri, 08 Jun 2007 16:28:44 GMT
Author: gawor
Date: Fri Jun  8 09:28:41 2007
New Revision: 545552

URL: http://svn.apache.org/viewvc?view=rev&rev=545552
Log:
getting service injection working right plus a bunch of other improvements

Added:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
  (with props)
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2HandlerResolver.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
Fri Jun  8 09:28:41 2007
@@ -17,20 +17,21 @@
 
 package org.apache.geronimo.axis2;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.xbeans.javaee.HandlerChainType;
-import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
-import org.apache.geronimo.xbeans.javaee.PortComponentHandlerType;
-import org.apache.geronimo.xbeans.javaee.HandlerChainsDocument;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.jws.HandlerChain;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.LogicalHandler;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.xbeans.javaee.HandlerChainType;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsDocument;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
+import org.apache.geronimo.xbeans.javaee.PortComponentHandlerType;
 
 /**
  * @version $Rev$ $Date$

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2HandlerResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2HandlerResolver.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2HandlerResolver.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2HandlerResolver.java
Fri Jun  8 09:28:41 2007
@@ -17,16 +17,17 @@
 
 package org.apache.geronimo.axis2;
 
-import org.apache.geronimo.jaxws.annotations.AnnotationException;
-import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
-import org.apache.geronimo.xbeans.javaee.HandlerChainType;
-import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.HandlerResolver;
-import java.util.ArrayList;
-import java.util.List;
+
+import org.apache.geronimo.jaxws.annotations.AnnotationException;
+import org.apache.geronimo.jaxws.annotations.AnnotationProcessor;
+import org.apache.geronimo.xbeans.javaee.HandlerChainType;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
 
 /**
  * @version $Rev$ $Date$

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Fri Jun  8 09:28:41 2007
@@ -35,12 +35,10 @@
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.context.ServiceGroupContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
 import org.apache.axis2.transport.OutTransportInfo;
@@ -64,7 +62,7 @@
  */
 public abstract class Axis2WebServiceContainer implements WebServiceContainer {
 
-    private static final Log log = LogFactory.getLog(Axis2WebServiceContainer.class);
+    private static final Log LOG = LogFactory.getLog(Axis2WebServiceContainer.class);
 
     public static final String REQUEST = Axis2WebServiceContainer.class.getName() + "@Request";
     public static final String RESPONSE = Axis2WebServiceContainer.class.getName() + "@Response";
@@ -89,47 +87,40 @@
         this.portInfo = portInfo;
         this.configurationBaseUrl = configurationBaseUrl;
         this.jndiResolver = new ServerJNDIResolver(context);
-        
-        init();  
     }
 
-    public void init() {
-        try {
-            this.endpointClass = classLoader.loadClass(this.endpointClassName);
-            configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
-
-            // check to see if the wsdlLocation property is set in portInfo,
-            // if not checking if wsdlLocation exists in annotation
-            // if already set, annotation should not overwrite it.
-            if (portInfo.getWsdlFile() == null || portInfo.getWsdlFile().equals("")) {
-                // getwsdllocation from annotation if it exists
-                if (JAXWSUtils.containsWsdlLocation(this.endpointClass, classLoader)) {
-                    portInfo.setWsdlFile(JAXWSUtils.getServiceWsdlLocation(this.endpointClass,
classLoader));
-                }
-            }
-
-            AxisServiceGenerator serviceGen = createServiceGenerator();            
-            if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals(""))
{ 
-                // WSDL file has been provided 
-                service = serviceGen.getServiceFromWSDL(portInfo, endpointClass, configurationBaseUrl);
-            } else {
-                // No WSDL, let Axis2 handle it.
-                
-                // FIXME: AxisServiceGenerator method should be used as it understands annotations
-                // but right now that method causes some problems when WSDL is requested.
-                service = AxisService.createService(endpointClassName, configurationContext.getAxisConfiguration(),
JAXWSMessageReceiver.class);                
-                // service = serviceGen.getServiceFromClass(this.endpointClass);
+    public void init() throws Exception {
+        this.endpointClass = classLoader.loadClass(this.endpointClassName);
+        configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
+
+        // check to see if the wsdlLocation property is set in portInfo,
+        // if not checking if wsdlLocation exists in annotation
+        // if already set, annotation should not overwrite it.
+        if (portInfo.getWsdlFile() == null || portInfo.getWsdlFile().equals("")) {
+            // getwsdllocation from annotation if it exists
+            if (JAXWSUtils.containsWsdlLocation(this.endpointClass, classLoader)) {
+                portInfo.setWsdlFile(JAXWSUtils.getServiceWsdlLocation(this.endpointClass,
classLoader));
             }
+        }
 
-            service.setScope(Constants.SCOPE_APPLICATION);
-            configurationContext.getAxisConfiguration().addService(service);
+        AxisServiceGenerator serviceGen = createServiceGenerator();
+        if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals(""))
{
+            // WSDL file has been provided
+            service = serviceGen.getServiceFromWSDL(portInfo, endpointClass, configurationBaseUrl);
+        } else {
+            // No WSDL, let Axis2 handle it.
 
-        } catch (AxisFault af) {
-            throw new RuntimeException(af);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+            // FIXME: AxisServiceGenerator method should be used as it understands annotations
+            // but right now that method causes some problems when WSDL is requested.
+            service = AxisService.createService(endpointClassName, 
+                                                configurationContext.getAxisConfiguration(),

+                                                JAXWSMessageReceiver.class);
+            // service = serviceGen.getServiceFromClass(this.endpointClass);
         }
 
+        service.setScope(Constants.SCOPE_APPLICATION);
+        configurationContext.getAxisConfiguration().addService(service);
+
         this.wsdlQueryHandler = new WSDLQueryHandler(this.service);
     }  
 
@@ -155,8 +146,8 @@
             throws Exception {
         initContextRoot(request);
 
-        if (log.isDebugEnabled()) {
-            log.debug("Target URI: " + request.getURI());
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Target URI: " + request.getURI());
         }
 
         MessageContext msgContext = new MessageContext();
@@ -200,7 +191,7 @@
             doService2(request, response, msgContext);
         } catch (Throwable e) {
             String msg = "Exception occurred while trying to invoke service method doService()";
-            log.error(msg, e);
+            LOG.error(msg, e);
             try {
                 AxisEngine engine = new AxisEngine(this.configurationContext);
 
@@ -224,7 +215,7 @@
                     PrintWriter pw = new PrintWriter(response.getOutputStream());
                     ex.printStackTrace(pw);
                     pw.flush();
-                    log.error(msg, ex);
+                    LOG.error(msg, ex);
                 }
             }
         }
@@ -262,9 +253,9 @@
         
 
         if (request.getMethod() == Request.GET) {
-            processGetRequest(request, response, this.service, configurationContext, msgContext);
+            processGETRequest(request, response, this.service, configurationContext, msgContext);
         } else if (request.getMethod() == Request.POST) {
-            processPostRequest(request, response, this.service, configurationContext, msgContext);
+            processPOSTRequest(request, response, this.service, configurationContext, msgContext);
         } else {
             throw new UnsupportedOperationException("[" + request.getMethod() + " ] method
not supported");
         }
@@ -278,7 +269,6 @@
             isTwoChannel = operationContext.getProperty(Constants.DIFFERENT_EPR);
         }
 
-
         if ((contextWritten != null) && Constants.VALUE_TRUE.equals(contextWritten))
{
             if ((isTwoChannel != null) && Constants.VALUE_TRUE.equals(isTwoChannel))
{
                 response.setStatusCode(202);
@@ -293,7 +283,7 @@
     public void destroy() {
     }
         
-    public class Axis2TransportInfo implements OutTransportInfo {
+    public static class Axis2TransportInfo implements OutTransportInfo {
         private Response response;
 
         public Axis2TransportInfo(Response response) {
@@ -305,27 +295,22 @@
         }
     }
     
-    class Axis2RequestResponseTransport implements RequestResponseTransport {
+    static class Axis2RequestResponseTransport implements RequestResponseTransport {
         private Response response;
 
         private CountDownLatch responseReadySignal = new CountDownLatch(1);
 
-        RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
+        private RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
 
-        AxisFault faultToBeThrownOut = null;
+        private AxisFault faultToBeThrownOut = null;
 
         Axis2RequestResponseTransport(Response response) {
             this.response = response;
         }
 
         public void acknowledgeMessage(MessageContext msgContext) throws AxisFault {
-            if (log.isDebugEnabled()) {
-                log.debug("acknowledgeMessage");
-            }
-
-            if (log.isDebugEnabled()) {
-                log.debug("Acking one-way request");
-            }
+            LOG.debug("acknowledgeMessage");
+            LOG.debug("Acking one-way request");
 
             response.setContentType("text/xml; charset="
                                     + msgContext.getProperty("message.character-set-encoding"));
@@ -341,9 +326,7 @@
         }
 
         public void awaitResponse() throws InterruptedException, AxisFault {
-            if (log.isDebugEnabled()) {
-                log.debug("Blocking servlet thread -- awaiting response");
-            }
+            LOG.debug("Blocking servlet thread -- awaiting response");
             status = RequestResponseTransportStatus.WAITING;
             responseReadySignal.await();
             if (faultToBeThrownOut != null) {
@@ -357,9 +340,7 @@
         }
 
         public void signalResponseReady() {
-            if (log.isDebugEnabled()) {
-                log.debug("Signalling response available");
-            }
+            LOG.debug("Signalling response available");
             status = RequestResponseTransportStatus.SIGNALLED;
             responseReadySignal.countDown();
         }
@@ -369,7 +350,7 @@
         }
     }
     
-    protected void processGetRequest(Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception{  
     
+    protected void processGETRequest(Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception{  
     
         if (request.getURI().getQuery() != null &&
             (request.getURI().getQuery().startsWith("wsdl") ||
              request.getURI().getQuery().startsWith("xsd"))) {
@@ -430,7 +411,7 @@
         msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, servletContext);   
    
     }
 
-    protected void processPostRequest (Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception {
+    protected void processPOSTRequest (Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception {
         String contentType = request.getHeader(HTTPConstants.HEADER_CONTENT_TYPE);
         String soapAction = request.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
         if (soapAction == null) {
@@ -438,19 +419,15 @@
         }
         
         configurationContext.fillServiceContextAndServiceGroupContext(msgContext);
-        ServiceGroupContext serviceGroupContext = msgContext.getServiceGroupContext();
-        DependencyManager.initService(serviceGroupContext);
-        //endpointInstance = msgContext.getServiceContext().getProperty(ServiceContext.SERVICE_OBJECT);
 
         setMsgContextProperties(msgContext, service, response, request);
 
-        HTTPTransportUtils.processHTTPPostRequest(
-                msgContext,
-                request.getInputStream(),
-                response.getOutputStream(),
-                contentType,
-                soapAction,
-                request.getURI().getPath());
+        HTTPTransportUtils.processHTTPPostRequest(msgContext,
+                                                  request.getInputStream(), 
+                                                  response.getOutputStream(), 
+                                                  contentType, 
+                                                  soapAction, 
+                                                  request.getURI().getPath());
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
Fri Jun  8 09:28:41 2007
@@ -67,8 +67,6 @@
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 
-//TODO: Handle RPC Style Messaging
-
 /**
  * @version $Rev$ $Date$
  */

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
Fri Jun  8 09:28:41 2007
@@ -17,6 +17,12 @@
 
 package org.apache.geronimo.axis2.client;
 
+import java.net.URI;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.HandlerResolver;
+
 import org.apache.axis2.jaxws.context.WebServiceContextImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -30,17 +36,12 @@
 import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
 import org.apache.xmlbeans.XmlException;
 
-import javax.xml.namespace.QName;
-import javax.xml.ws.handler.HandlerResolver;
-import java.net.URI;
-import java.util.Map;
-
 /**
  * @version $Rev$ $Date$
  */
 public class Axis2ServiceReference extends JAXWSServiceReference {
 
-    private static final Log log = LogFactory.getLog(Axis2ServiceReference.class);
+    private static final Log LOG = LogFactory.getLog(Axis2ServiceReference.class);
 
     public Axis2ServiceReference(String serviceClassName,
                                  String referenceClassName,
@@ -63,7 +64,7 @@
                 }
             }
         } catch (Exception e) {
-            log.warn("Failed to deserialize handler chains", e);
+            LOG.warn("Failed to deserialize handler chains", e);
         }
         JAXWSAnnotationProcessor annotationProcessor =
                 new JAXWSAnnotationProcessor(new JNDIResolver(), new WebServiceContextImpl());

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
Fri Jun  8 09:28:41 2007
@@ -17,14 +17,15 @@
 
 package org.apache.geronimo.axis2.ejb;
 
+import java.net.URL;
+
+import javax.naming.Context;
+
 import org.apache.axis2.util.JavaUtils;
 import org.apache.geronimo.axis2.Axis2WebServiceContainer;
 import org.apache.geronimo.axis2.AxisServiceGenerator;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.openejb.DeploymentInfo;
-
-import javax.naming.Context;
-import java.net.URL;
 
 /**
  * @version $Rev$ $Date$

Added: 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=auto&rev=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
Fri Jun  8 09:28:41 2007
@@ -0,0 +1,79 @@
+/*
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.geronimo.axis2.pojo;
+
+import org.apache.axis2.jaxws.context.factory.MessageContextFactory;
+import org.apache.axis2.jaxws.context.utils.ContextUtils;
+import org.apache.axis2.jaxws.core.MessageContext;
+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 {
+            // associate JAX-WS MessageContext with the thread
+            POJOWebServiceContext.setMessageContext(createSOAPMessageContext(context)); 
          
+        }
+        
+        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);
+        }
+    }
+    
+    private javax.xml.ws.handler.MessageContext createSOAPMessageContext(MessageContext mc)
{
+        SoapMessageContext soapMessageContext =
+                (SoapMessageContext)MessageContextFactory.createSoapMessageContext(mc);
+        ContextUtils.addProperties(soapMessageContext, mc);
+        return soapMessageContext;
+    }
+  
+    public void invokePostConstruct() throws EndpointLifecycleException { 
+    }
+
+    public void invokePreDestroy() throws EndpointLifecycleException {
+        if (this.instance != null) {
+            this.annotationProcessor.invokePreDestroy(this.instance);
+        }
+    }
+   
+}

Propchange: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=auto&rev=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
Fri Jun  8 09:28:41 2007
@@ -0,0 +1,45 @@
+/*
+ * 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
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.geronimo.axis2.pojo;
+
+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);  
     
+    }
+
+    @Override
+    public EndpointLifecycleManager createEndpointLifecycleManager(Object endpointInstance)
+            throws EndpointLifecycleException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public EndpointLifecycleManager createEndpointLifecycleManager() {
+        return this.lifecycleManager;
+    }
+    
+}

Propchange: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManagerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=545552&r1=545551&r2=545552
==============================================================================
--- 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 09:28:41 2007
@@ -17,53 +17,77 @@
 
 package org.apache.geronimo.axis2.pojo;
 
+import java.net.URL;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
+
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.engine.DependencyManager;
 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;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.axis2.Axis2HandlerResolver;
 import org.apache.geronimo.axis2.Axis2WebServiceContainer;
 import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
-import org.apache.geronimo.jaxws.JNDIResolver;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.annotations.AnnotationException;
-import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
 import org.apache.geronimo.xbeans.javaee.HandlerChainsDocument;
+import org.apache.geronimo.xbeans.javaee.HandlerChainsType;
 
-import javax.naming.Context;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.handler.Handler;
-import java.net.URL;
-import java.util.List;
+// FIXME: improve handler support, handler injection, thread-safetly for handlers
 
 /**
  * @version $Rev$ $Date$
  */
 public class POJOWebServiceContainer extends Axis2WebServiceContainer {
 
+    private static final Log LOG = LogFactory.getLog(POJOWebServiceContainer.class);
+    
     private JAXWSAnnotationProcessor annotationProcessor;
     private Object endpointInstance;
     private List<Handler> chain;
     private String contextRoot = null;
+    private EndpointLifecycleManager lifecycleManager;
     
     public POJOWebServiceContainer(PortInfo portInfo,
                                    String endpointClassName,
                                    ClassLoader classLoader,
                                    Context context,
                                    URL configurationBaseUrl) {
-        super(portInfo, endpointClassName, classLoader, context, configurationBaseUrl);
-        configurationContext.setServicePath(portInfo.getLocation());
+        super(portInfo, endpointClassName, classLoader, context, configurationBaseUrl); 
      
     }
     
     @Override
-    protected void processPostRequest (Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception {
+    public void init() throws Exception {
+        super.init();
+        
+        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);
+    }
+    
+    @Override
+    protected void processPOSTRequest(Request request, Response response, AxisService service,
ConfigurationContext configurationContext, MessageContext msgContext) throws Exception {
         String contentType = request.getHeader(HTTPConstants.HEADER_CONTENT_TYPE);
         String soapAction = request.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
         if (soapAction == null) {
@@ -71,27 +95,27 @@
         }
 
         configurationContext.fillServiceContextAndServiceGroupContext(msgContext);
-        ServiceGroupContext serviceGroupContext = msgContext.getServiceGroupContext();
-        DependencyManager.initService(serviceGroupContext);
-        endpointInstance = msgContext.getServiceContext().getProperty(ServiceContext.SERVICE_OBJECT);
         
         setMsgContextProperties(msgContext, service, response, request);
-        annotationProcessor = new JAXWSAnnotationProcessor(this.jndiResolver,
-                new POJOWebServiceContext(msgContext));
+
         initHandlers();
         try {
-            HTTPTransportUtils.processHTTPPostRequest(
-                    msgContext,
-                    request.getInputStream(),
-                    response.getOutputStream(),
-                    contentType,
-                    soapAction,
-                    request.getURI().getPath());
-        } finally {
+            HTTPTransportUtils.processHTTPPostRequest(msgContext,
+                                                      request.getInputStream(),
+                                                      response.getOutputStream(),
+                                                      contentType,
+                                                      soapAction,
+                                                      request.getURI().getPath());
+        } finally {            
             stopHandlers();
-        }        
+            
+            // de-associate JAX-WS MessageContext with the thread
+            // (association happens in POJOEndpointLifecycleManager.createService() call)
+            POJOWebServiceContext.clear();
+        } 
     }
     
+    @Override
     protected void setMsgContextProperties(MessageContext msgContext, AxisService service,
Response response, Request request) {
         BindingImpl binding = new BindingImpl("GeronimoBinding");
         binding.setHandlerChain(chain);
@@ -107,13 +131,6 @@
         } catch (Exception e) {
             throw new WebServiceException("Error configuring handlers", e);
         }
-
-        // inject resources into service
-        try {
-            injectResources(endpointInstance);
-        } catch (AnnotationException e) {
-            throw new WebServiceException("Service resource injection failed", e);
-        }
     }
 
     /*
@@ -125,10 +142,9 @@
         HandlerChainsType handlerChains = xml == null ? null : HandlerChainsDocument.Factory.parse(xml).getHandlerChains();
         Axis2HandlerResolver handlerResolver =
             new Axis2HandlerResolver(endpointInstance.getClass().getClassLoader(),
-                                   endpointInstance.getClass(),
-                                   handlerChains,
-                                   this.annotationProcessor);
-
+                                     endpointInstance.getClass(),
+                                     handlerChains,
+                                     this.annotationProcessor);
 
         // TODO: pass non-null PortInfo to get the right handlers
         chain = handlerResolver.getHandlerChain(null);
@@ -139,16 +155,9 @@
         for (Handler handler : chain) {
             this.annotationProcessor.invokePreDestroy(handler);
         }
-
-        // call service preDestroy
-        this.annotationProcessor.invokePreDestroy(endpointInstance);
     }
 
     private void injectResources(Object instance) throws AnnotationException {
-        if (instance == null)
-            System.out.println("instance is null");
-        if (annotationProcessor == null)
-            System.out.println("annotationProcessor is null");
         this.annotationProcessor.processAnnotations(instance);
         this.annotationProcessor.invokePostConstruct(instance);
     }
@@ -172,4 +181,16 @@
             configurationContext.setContextRoot(contextRoot);  
         }
     }     
+    
+    @Override
+    public void destroy() {
+        // invoke @preDestroy methods
+        try {
+            this.lifecycleManager.invokePreDestroy();
+        } catch (EndpointLifecycleException e) {
+            LOG.warn("", e);
+        }
+        
+        super.destroy();
+    }
 }

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
Fri Jun  8 09:28:41 2007
@@ -17,6 +17,13 @@
 
 package org.apache.geronimo.axis2.pojo;
 
+import java.net.URL;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -28,31 +35,27 @@
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerFactory;
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.transaction.TransactionManager;
-import java.net.URL;
-import java.util.Map;
-
 /**
  * @version $Rev$ $Date$
  */
 public class POJOWebServiceContainerFactoryGBean implements WebServiceContainerFactory {
 
-    private static final Log log = LogFactory.getLog(POJOWebServiceContainerFactoryGBean.class);
+    private static final Log LOG = LogFactory.getLog(POJOWebServiceContainerFactoryGBean.class);
+    
     private final ClassLoader classLoader;
     private final org.apache.geronimo.jaxws.PortInfo portInfo;
     private final String endpointClassName;
     private URL configurationBaseUrl;
     private Context context;
 
-    public POJOWebServiceContainerFactoryGBean(org.apache.geronimo.jaxws.PortInfo portInfo,

-            String endpointClassName, 
-            ClassLoader classLoader, 
-            Map componentContext,
-            Kernel kernel,
-            TransactionManager transactionManager,
-            URL configurationBaseUrl) throws InstantiationException, IllegalAccessException,
ClassNotFoundException {
+    public POJOWebServiceContainerFactoryGBean(org.apache.geronimo.jaxws.PortInfo portInfo,
+                                               String endpointClassName,
+                                               ClassLoader classLoader,
+                                               Map componentContext,
+                                               Kernel kernel,
+                                               TransactionManager transactionManager,
+                                               URL configurationBaseUrl)
+        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
         
         if (componentContext != null) {
             GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
@@ -62,7 +65,7 @@
                         kernel,
                         classLoader);
             } catch (NamingException e) {
-                log.warn("Failed to create naming context", e);
+                LOG.warn("Failed to create naming context", e);
             }
         }
 
@@ -74,7 +77,11 @@
 
     public WebServiceContainer getWebServiceContainer() {
         POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
classLoader, context, configurationBaseUrl);
-        container.init();
+        try {
+            container.init();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
         return container;
     }
 

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
Fri Jun  8 09:28:41 2007
@@ -17,13 +17,13 @@
 
 package org.apache.geronimo.axis2.pojo;
 
-import org.apache.axis2.jaxws.handler.LogicalMessageContext;
-import org.apache.axis2.transport.http.HTTPConstants;
+import java.security.Principal;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
-import java.security.Principal;
+
+import org.apache.axis2.transport.http.HTTPConstants;
 
 /**
  * Implementation of WebServiceContext for POJO WS to ensure that getUserPrincipal()
@@ -33,14 +33,13 @@
  */
 public class POJOWebServiceContext implements WebServiceContext {
 
-    private MessageContext ctx;
-
-    public POJOWebServiceContext(org.apache.axis2.context.MessageContext ctx) {
-        this.ctx = new LogicalMessageContext(new org.apache.axis2.jaxws.core.MessageContext(ctx));
-    }
+    private static ThreadLocal<MessageContext> context = new ThreadLocal<MessageContext>();
     
+    public POJOWebServiceContext() {        
+    }
+        
     public final MessageContext getMessageContext() {
-        return ctx;
+        return context.get();
     }
 
     private HttpServletRequest getHttpServletRequest() {
@@ -56,6 +55,14 @@
     public final boolean isUserInRole(String user) {
         HttpServletRequest request = getHttpServletRequest();
         return (request != null) ? request.isUserInRole(user) : false;
+    }
+            
+    public static void setMessageContext(MessageContext ctx) {
+        context.set(ctx);
+    }
+
+    public static void clear() {
+        context.set(null);
     }
 
 }

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java?view=diff&rev=545552&r1=545551&r2=545552
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
Fri Jun  8 09:28:41 2007
@@ -71,6 +71,7 @@
         
         String endpointClassName = "org.apache.geronimo.axis2.testdata.simple.HelloWorld";
         POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
cl, null, null);
+        container.init();
         container.invoke(req, res);
         out.flush();
 
@@ -142,6 +143,7 @@
                 Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1",
null, null, 8080, out);
 
                 POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo,
endPointClassName, cl, null, null);
+                container.init();
                 container.invoke(req, res);
                 System.out.println("Response "+out);
                 out.flush();



Mime
View raw message