geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r701913 - in /geronimo/server/trunk/plugins/axis2: geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/ geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/ geronimo...
Date Mon, 06 Oct 2008 02:02:41 GMT
Author: gawor
Date: Sun Oct  5 19:02:40 2008
New Revision: 701913

URL: http://svn.apache.org/viewvc?rev=701913&view=rev
Log:
get addressing somewhat working (GERONIMO-4327)

Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/resources/META-INF/geronimo-axis2.xml

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java?rev=701913&r1=701912&r2=701913&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
Sun Oct  5 19:02:40 2008
@@ -28,12 +28,16 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.jaxws.ExceptionFactory;
+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.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.handler.SoapMessageContext;
 import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.util.ThreadContextMigratorUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.openejb.ApplicationException;
@@ -61,12 +65,17 @@
         requestMsgCtx.setOperationName(requestMsgCtx.getAxisMessageContext().getAxisOperation().getName());
         requestMsgCtx.setEndpointDescription(getEndpointDescription(requestMsgCtx));
         
+        SoapMessageContext jaxwsContext =
+            MessageContextFactory.createSoapMessageContext(requestMsgCtx);
+        
         Method method = null;
         if (Provider.class.isAssignableFrom(this.serviceImplClass)) {
             method = getProviderMethod();
+            ContextUtils.addWSDLProperties_provider(requestMsgCtx, jaxwsContext);
         } else {
             requestMsgCtx.setOperationDescription(getOperationDescription(requestMsgCtx));
             method = getServiceMethod(requestMsgCtx);
+            ContextUtils.addWSDLProperties(requestMsgCtx, jaxwsContext);
         }
         
         if (LOG.isDebugEnabled()) {
@@ -74,8 +83,6 @@
         }
         
         EJBInterceptor interceptor = new EJBInterceptor(this.container, requestMsgCtx);
-
-        SoapMessageContext jaxwsContext = new SoapMessageContext(requestMsgCtx);
         EJBAddressingSupport wsaSupport = new EJBAddressingSupport(jaxwsContext);
         Object[] arguments = { jaxwsContext, interceptor, wsaSupport };
         
@@ -85,6 +92,9 @@
         
         method = getMostSpecificMethod(method, callInterface);
         
+        //This assumes that we are on the ultimate execution thread
+        ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,

+                                                           axisMsgCtx);        
         try {
             Object res = container.invoke(this.deploymentInfo.getDeploymentID(), callInterface,
method, arguments, null);
             // TODO: update response message with new response value?
@@ -96,6 +106,9 @@
             }
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
+        } finally {
+            ThreadContextMigratorUtil.performThreadCleanup(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,

+                                                           axisMsgCtx);
         }
     }
     

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?rev=701913&r1=701912&r2=701913&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Sun Oct  5 19:02:40 2008
@@ -20,6 +20,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
+import java.net.URI;
 import java.net.URL;
 import java.util.List;
 
@@ -27,6 +28,7 @@
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.namespace.QName;
 import javax.xml.ws.Binding;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
@@ -41,11 +43,14 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.Handler.InvocationResponse;
-import org.apache.axis2.jaxws.binding.BindingImpl;
+import org.apache.axis2.jaxws.addressing.util.EndpointContextMap;
+import org.apache.axis2.jaxws.addressing.util.EndpointContextMapManager;
+import org.apache.axis2.jaxws.addressing.util.EndpointKey;
 import org.apache.axis2.jaxws.binding.BindingUtils;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.impl.DescriptionUtils;
@@ -98,6 +103,7 @@
     protected Binding binding;
     protected JAXWSAnnotationProcessor annotationProcessor;
     protected Context context;
+    protected String address;
 
     public Axis2WebServiceContainer(PortInfo portInfo,
                                     String endpointClassName,
@@ -152,9 +158,25 @@
          * HandlerResolver.
          */        
         FactoryRegistry.setFactory(HandlerLifecycleManagerFactory.class, 
-                                   new GeronimoHandlerLifecycleManagerFactory());       
                           
+                                   new GeronimoHandlerLifecycleManagerFactory());     
+        
+        configureAddressing();
+        
+        this.service.addParameter(new Parameter(org.apache.axis2.jaxws.spi.Constants.CACHE_CLASSLOADER,
classLoader));
     }  
 
+    static String getBaseUri(URI request) {
+        return request.getScheme() + "://" + request.getHost() + ":" + request.getPort()
+ request.getPath();
+    }
+    
+    synchronized void updateAddress(Request request) {
+        if (this.address == null) {
+            String requestAddress = getBaseUri(request.getURI());
+            this.service.setEPRs(new String [] {requestAddress});
+            this.address = requestAddress;
+        }
+    }
+    
     protected AxisServiceGenerator createServiceGenerator() {
         return new AxisServiceGenerator();
     }
@@ -180,6 +202,8 @@
             LOG.debug("Target URI: " + request.getURI());
         }
 
+        updateAddress(request);
+        
         MessageContext msgContext = new MessageContext();
         msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
         msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());
@@ -429,14 +453,25 @@
         }
     }    
     
+    protected void configureAddressing() throws Exception {
+        EndpointDescription desc = AxisServiceGenerator.getEndpointDescription(this.service);
+        
+        QName serviceName = desc.getServiceQName();
+        QName portName = desc.getPortQName();
+        EndpointKey key = new EndpointKey(serviceName, portName);
+        
+        EndpointContextMapManager.setEndpointContextMap(null);
+        EndpointContextMap map = EndpointContextMapManager.getEndpointContextMap();
+        map.put(key, this.service);
+        
+        configurationContext.setProperty(org.apache.axis2.jaxws.Constants.ENDPOINT_CONTEXT_MAP,
map);
+    }
+    
     /*
      * Gets the right handlers for the port/service/bindings and performs injection.
      */
     protected void configureHandlers() throws Exception {
         EndpointDescription desc = AxisServiceGenerator.getEndpointDescription(this.service);
-        if (desc == null) {
-            throw new RuntimeException("No EndpointDescription for service");
-        }
         
         String xml = this.portInfo.getHandlersAsXML();
         HandlerChainsType handlerChains = null;

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java?rev=701913&r1=701912&r2=701913&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOEndpointLifecycleManager.java
Sun Oct  5 19:02:40 2008
@@ -19,12 +19,13 @@
 package org.apache.geronimo.axis2.pojo;
 
 import org.apache.axis2.context.ServiceContext;
+import org.apache.axis2.jaxws.context.WebServiceContextImpl;
 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.axis2.jaxws.server.endpoint.lifecycle.impl.EndpointLifecycleManagerImpl;
 
 public class POJOEndpointLifecycleManager implements EndpointLifecycleManager {
         
@@ -37,19 +38,20 @@
         ServiceContext serviceContext = msgContext.getServiceContext();                
         Object instance = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT);
         
+        SoapMessageContext soapMessageContext =
+            MessageContextFactory.createSoapMessageContext(context);
+        WebServiceContextImpl wsContext = new WebServiceContextImpl();
+        wsContext.setSoapMessageContext(soapMessageContext);
+        
         // associate JAX-WS MessageContext with the thread
-        POJOWebServiceContext.setMessageContext(createSOAPMessageContext(context)); 
+        POJOWebServiceContext.set(wsContext);
+        
+        // XXX: JUST A HACK
+        serviceContext.setProperty(EndpointLifecycleManagerImpl.WEBSERVICE_MESSAGE_CONTEXT,
wsContext);
         
         return instance;
     }
     
-    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 { 
     }
 

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java?rev=701913&r1=701912&r2=701913&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContext.java
Sun Oct  5 19:02:40 2008
@@ -66,13 +66,11 @@
         return (wsContext == null) ? null : wsContext.getEndpointReference(clazz, referenceParameters);
     }
     
-    public static void setMessageContext(MessageContext ctx) {
-        WebServiceContextImpl wsContext = new WebServiceContextImpl();
-        wsContext.setSoapMessageContext(ctx);
-        context.set(wsContext);
+    static void set(WebServiceContextImpl ctx) {
+        context.set(ctx);
     }
 
-    public static void clear() {
+    static void clear() {
         context.set(null);
     }
     

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/resources/META-INF/geronimo-axis2.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/resources/META-INF/geronimo-axis2.xml?rev=701913&r1=701912&r2=701913&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/resources/META-INF/geronimo-axis2.xml
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/resources/META-INF/geronimo-axis2.xml
Sun Oct  5 19:02:40 2008
@@ -66,6 +66,10 @@
     <!-- Following parameter will set the host name for the epr-->
     <!--<parameter name="hostname" locked="true">myhost.com</parameter>-->
 
+    <threadContextMigrators>
+        <threadContextMigrator listId="JAXWS-ThreadContextMigrator-List" class="org.apache.axis2.jaxws.addressing.migrator.EndpointContextMapMigrator"/>
+    </threadContextMigrators>
+
     <!-- ================================================= -->
     <!-- Message Receivers -->
     <!-- ================================================= -->



Mime
View raw message