geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r544505 - in /geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2: ./ ejb/ pojo/
Date Tue, 05 Jun 2007 14:39:23 GMT
Author: gawor
Date: Tue Jun  5 07:39:21 2007
New Revision: 544505

URL: http://svn.apache.org/viewvc?view=rev&rev=544505
Log:
initial ws support for ejb-based endpoints for axis2

Added:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
  (with props)
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBInterceptor.java
  (with props)
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
  (with props)
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
  (with props)
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBServiceDispatcher.java
  (with props)
Modified:
    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/ejb/EJBWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.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

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=544505&r1=544504&r2=544505
==============================================================================
--- 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
Tue Jun  5 07:39:21 2007
@@ -74,6 +74,7 @@
     protected org.apache.geronimo.jaxws.PortInfo portInfo;
     protected ConfigurationContext configurationContext;
     protected JNDIResolver jndiResolver;
+    protected Class endpointClass;
     private AxisService service;
     private URL configurationBaseUrl;
     private WSDLQueryHandler wsdlQueryHandler;
@@ -87,23 +88,28 @@
         this.endpointClassName = endpointClassName;
         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("")){
-                Class clazz = classLoader.loadClass(endpointClassName);
                 //getwsdllocation from annotation if it exists
-                if (JAXWSUtils.containsWsdlLocation(clazz, classLoader))
-                    portInfo.setWsdlFile(JAXWSUtils.getServiceWsdlLocation(clazz, classLoader));
               
+                if (JAXWSUtils.containsWsdlLocation(this.endpointClass, classLoader)) {
+                    portInfo.setWsdlFile(JAXWSUtils.getServiceWsdlLocation(this.endpointClass,
classLoader));
+                }
             }
 
             if(portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")){
//WSDL file Has been provided
-                AxisServiceGenerator serviceGen = new AxisServiceGenerator();
+                AxisServiceGenerator serviceGen = createServiceGenerator();
                 service = serviceGen.getServiceFromWSDL(portInfo, endpointClassName, configurationBaseUrl,
classLoader);
                                             
             }else { //No WSDL, Axis2 will handle it. Is it ?
@@ -119,9 +125,12 @@
             throw new RuntimeException(e);
         }
         
-        this.wsdlQueryHandler = new WSDLQueryHandler(this.service);        
-        jndiResolver = new ServerJNDIResolver(context);
+        this.wsdlQueryHandler = new WSDLQueryHandler(this.service);
     }  
+
+    protected AxisServiceGenerator createServiceGenerator() {
+        return new AxisServiceGenerator();
+    }
 
     public void getWsdl(Request request, Response response) throws Exception {
         doService(request, response);

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=544505&r1=544504&r2=544505
==============================================================================
--- 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
Tue Jun  5 07:39:21 2007
@@ -45,6 +45,7 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
 import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
@@ -72,11 +73,16 @@
     
     private static String WSDL_ENCODING = "UTF-8";
     
+    private MessageReceiver messageReceiver;
+    
     public AxisServiceGenerator(){
-        super();
+        this.messageReceiver = new JAXWSMessageReceiver();
     }
     
-
+    public void setMessageReceiver(MessageReceiver messageReceiver) {
+        this.messageReceiver = messageReceiver;
+    }
+   
     public AxisService getServiceFromWSDL(PortInfo portInfo, String endpointClassName, URL
configurationBaseUrl, ClassLoader classLoader) throws Exception {
         Definition wsdlDefinition = getWSDLDefinition(portInfo, configurationBaseUrl, classLoader);
 
@@ -154,7 +160,7 @@
 
         for(Iterator<AxisOperation> opIterator = service.getOperations() ; opIterator.hasNext()
;){
             AxisOperation operation = opIterator.next();
-            operation.setMessageReceiver(JAXWSMessageReceiver.class.newInstance());
+            operation.setMessageReceiver(this.messageReceiver);
             String MEP = operation.getMessageExchangePattern();
             if (!WSDLUtil.isOutputPresentForMEP(MEP)) {
                 List<MethodDescriptionComposite> mdcList = dbc.getMethodDescriptionComposite(operation.getName().toString());
@@ -196,51 +202,50 @@
         }
     }
     
-    protected Definition getWSDLDefinition(PortInfo portInfo, URL configurationBaseUrl, ClassLoader
classLoader) throws IOException, WSDLException {
+    protected Definition getWSDLDefinition(PortInfo portInfo,
+                                           URL configurationBaseUrl,
+                                           ClassLoader classLoader) 
+        throws IOException, WSDLException {
         String wsdlFile = portInfo.getWsdlFile();
-        Definition wsdlDefinition = null;
         if (wsdlFile == null || wsdlFile.equals("")) {
-            log.debug("A WSDL file was not supplied.");
-            return null;
-        } else {
-            URL wsdlURL = getWsdlURL(wsdlFile, configurationBaseUrl, classLoader);
-            InputStream wsdlStream;
-            try {
-                wsdlStream = wsdlURL.openStream();
-                if(wsdlStream == null){
-                    throw new IOException("unable to read descriptor " + wsdlURL);
-                }
-                else {
-                    WSDLFactory factory = WSDLFactory.newInstance();
-                    WSDLReader reader = factory.newWSDLReader();
-                    reader.setFeature("javax.wsdl.importDocuments", true);
-                    reader.setFeature("javax.wsdl.verbose", false);
-                    wsdlDefinition = reader.readWSDL(wsdlURL.toString());
-                    wsdlStream.close();                   
-                }
-            } catch (RuntimeException e) {
-                throw new RuntimeException("invalid WSDL provided " + wsdlURL);
-            } 
-            return wsdlDefinition;
+            throw new IOException("WSDL file was not supplied.");
         }
+
+        Definition wsdlDefinition = null;
+        URL wsdlURL = getWsdlURL(wsdlFile, configurationBaseUrl, classLoader);
+        InputStream wsdlStream = null;
+        try {
+            wsdlStream = wsdlURL.openStream();
+            WSDLFactory factory = WSDLFactory.newInstance();
+            WSDLReader reader = factory.newWSDLReader();
+            reader.setFeature("javax.wsdl.importDocuments", true);
+            reader.setFeature("javax.wsdl.verbose", false);
+            wsdlDefinition = reader.readWSDL(wsdlURL.toString());
+        } catch (RuntimeException e) {
+            throw new RuntimeException("invalid WSDL provided " + wsdlURL);
+        } finally {
+            if (wsdlStream != null) {
+                wsdlStream.close();
+            }
+        }
+        return wsdlDefinition;
+
     }
     
     public static URL getWsdlURL(String wsdlFile, URL configurationBaseUrl, ClassLoader classLoader)
{
         URL wsdlURL = null;
         if (wsdlFile != null) {
-
             try {
                 wsdlURL = new URL(wsdlFile);
             } catch (MalformedURLException e) {
                 // Not a URL, try as a resource
-                wsdlURL = classLoader.getResource("/" + wsdlFile);
+                wsdlURL = classLoader.getResource(wsdlFile);
 
                 if (wsdlURL == null && configurationBaseUrl != null) {
                     // Cannot get it as a resource, try with
                     // configurationBaseUrl
                     try {
-                        wsdlURL = new URL(configurationBaseUrl.toString()
-                                + wsdlFile);
+                        wsdlURL = new URL(configurationBaseUrl, wsdlFile);
                     } catch (MalformedURLException ee) {
                         // ignore
                     }
@@ -249,4 +254,6 @@
         }
         return wsdlURL;
     }
+    
+      
 }

Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java?view=auto&rev=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
Tue Jun  5 07:39:21 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.ejb;
+
+import javax.interceptor.InvocationContext;
+import javax.xml.ws.Provider;
+
+import org.apache.axis2.jaxws.server.EndpointController;
+import org.apache.axis2.jaxws.server.dispatcher.EndpointDispatcher;
+
+public class EJBEndpointController extends EndpointController {
+ 
+    private InvocationContext invContext;
+
+    public EJBEndpointController(InvocationContext invContext) {
+        this.invContext = invContext;
+    }
+    
+    @Override
+    protected EndpointDispatcher getEndpointDispatcher(Class serviceImplClass, Object serviceInstance)
+        throws Exception {    
+        if (Provider.class.isAssignableFrom(serviceImplClass)) {
+            return new EJBProviderDispatcher(this.invContext);
+        } else {
+            return new EJBServiceDispatcher(this.invContext);
+        }
+    }
+
+}

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

Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBInterceptor.java?view=auto&rev=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBInterceptor.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBInterceptor.java
Tue Jun  5 07:39:21 2007
@@ -0,0 +1,115 @@
+/**
+ * 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.ejb;
+
+import javax.interceptor.AroundInvoke;
+import javax.xml.ws.Binding;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.InvocationContextFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.message.util.MessageUtils;
+import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004_Constants;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2006Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class EJBInterceptor {
+
+    private static final Log LOG = LogFactory.getLog(EJBInterceptor.class);
+
+    private MessageContext requestMsgCtx;
+
+    public EJBInterceptor(MessageContext requestCtx) {
+        this.requestMsgCtx = requestCtx;
+    }
+
+    @AroundInvoke
+    public Object intercept(javax.interceptor.InvocationContext invContext) throws Exception
{
+                
+        AxisOperation operation = this.requestMsgCtx.getAxisMessageContext().getAxisOperation();
+        String mep = operation.getMessageExchangePattern();
+        
+        EJBEndpointController controller = new EJBEndpointController(invContext);
+               
+        Binding binding = (Binding)this.requestMsgCtx.getAxisMessageContext().getProperty(JAXWSMessageReceiver.PARAM_BINDING);
+        InvocationContext ic = InvocationContextFactory.createInvocationContext(binding);
+        ic.setRequestMessageContext(this.requestMsgCtx);
+        
+        controller.invoke(ic);
+        
+        MessageContext responseMsgCtx = ic.getResponseMessageContext();
+
+        //If there is a fault it could be Robust In-Only
+        if (!isMepInOnly(mep) || hasFault(responseMsgCtx)) {
+            // If this is a two-way exchange, there should already be a
+            // JAX-WS MessageContext for the response.  We need to pull 
+            // the Message data out of there and set it on the Axis2 
+            // MessageContext.
+            org.apache.axis2.context.MessageContext axisResponseMsgCtx =
+                    responseMsgCtx.getAxisMessageContext();
+
+            MessageUtils.putMessageOnMessageContext(responseMsgCtx.getMessage(),
+                                                    axisResponseMsgCtx);
+
+            OperationContext opCtx = axisResponseMsgCtx.getOperationContext();
+            opCtx.addMessageContext(axisResponseMsgCtx);
+
+            // If this is a fault message, we want to throw it as an
+            // exception so that the transport can do the appropriate things
+            if (responseMsgCtx.getMessage().isFault()) {
+                throw new AxisFault("An error was detected during JAXWS processing",
+                                    axisResponseMsgCtx);
+            } else {
+                //Create the AxisEngine for the reponse and send it.
+                AxisEngine engine =
+                        new AxisEngine(axisResponseMsgCtx.getConfigurationContext());
+                engine.send(axisResponseMsgCtx);
+            }
+        }    
+        
+        // TODO: convert response into object?
+        return null;
+    }
+    
+    private boolean hasFault(MessageContext responseMsgCtx) {
+        if (responseMsgCtx == null || responseMsgCtx.getMessage() == null) {
+            return false;
+        }
+        return responseMsgCtx.getMessage().isFault();
+    }
+
+    private boolean isMepInOnly(String mep) {
+        boolean inOnly = mep.equals(WSDL20_2004_Constants.MEP_URI_ROBUST_IN_ONLY) ||
+                mep.equals(WSDL20_2004_Constants.MEP_URI_IN_ONLY) ||
+                mep.equals(WSDL2Constants.MEP_URI_IN_ONLY) ||
+                mep.equals(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY) ||
+                mep.equals(WSDL20_2006Constants.MEP_URI_ROBUST_IN_ONLY) ||
+                mep.equals(WSDL20_2006Constants.MEP_URI_IN_ONLY);
+        return inOnly;
+    }
+        
+}

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

Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java?view=auto&rev=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
Tue Jun  5 07:39:21 2007
@@ -0,0 +1,140 @@
+/**
+ * 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.ejb;
+
+import java.lang.reflect.Method;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.jaxws.ExceptionFactory;
+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.ProtectedMessageContext;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.RpcContainer;
+
+public class EJBMessageReceiver implements MessageReceiver {
+
+    private static final Log LOG = LogFactory.getLog(EJBMessageReceiver.class);
+    
+    private DeploymentInfo deploymentInfo;
+    private Class serviceImplClass;
+
+    public EJBMessageReceiver(Class serviceImplClass, DeploymentInfo deploymentInfo) {
+        this.serviceImplClass = serviceImplClass;
+        this.deploymentInfo = deploymentInfo;
+    }
+    
+    public void receive(org.apache.axis2.context.MessageContext axisMsgCtx) throws AxisFault
{         
+        MessageContext requestMsgCtx = new MessageContext(axisMsgCtx);
+        
+        // init some bits
+        requestMsgCtx.setOperationName(requestMsgCtx.getAxisMessageContext().getAxisOperation().getName());
+        requestMsgCtx.setEndpointDescription(getEndpointDescription(requestMsgCtx));
+        requestMsgCtx.setOperationDescription(getOperationDescription(requestMsgCtx));
+        
+        // TODO: will need to handle Provider.invoke() method here
+        
+        Method method = getJavaMethod(requestMsgCtx, this.serviceImplClass);
+        
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Invoking '" + method.getName() + "' method.");
+        }
+        
+        EJBInterceptor interceptor = new EJBInterceptor(requestMsgCtx);
+
+        ProtectedMessageContext jaxwsContext = new ProtectedMessageContext(requestMsgCtx);
+        
+        Object[] arguments = { jaxwsContext, interceptor };
+        
+        RpcContainer container = (RpcContainer) this.deploymentInfo.getContainer();
+
+        Class callInterface = this.deploymentInfo.getServiceEndpointInterface();
+        
+        method = getMostSpecificMethod(method, callInterface);
+        
+        try {
+            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), callInterface,
method, arguments, null);
+            // TODO: update response message with new response value?
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+    
+    private static Method getMostSpecificMethod(Method method, Class<?> targetClass)
{
+        if (method != null && targetClass != null) {
+            try {
+                method = targetClass.getMethod(method.getName(), method.getParameterTypes());
+            } catch (NoSuchMethodException ex) {
+                // Perhaps the target class doesn't implement this method:
+                // that's fine, just use the original method
+            }
+        }
+        return method;
+    }
+    
+    private Method getJavaMethod(MessageContext mc, Class serviceImplClass) {
+        OperationDescription opDesc = mc.getOperationDescription();
+        if (opDesc == null) {
+            throw ExceptionFactory.makeWebServiceException("Operation Description was not
set");
+        }
+
+        Method returnMethod = opDesc.getMethodFromServiceImpl(serviceImplClass);
+        if (returnMethod == null) {
+            throw ExceptionFactory
+                    .makeWebServiceException(Messages.getMessage("JavaBeanDispatcherErr1"));
+        }
+
+        return returnMethod;
+    }
+    
+    private OperationDescription getOperationDescription(MessageContext mc) {
+        EndpointDescription ed = mc.getEndpointDescription();
+        EndpointInterfaceDescription eid = ed.getEndpointInterfaceDescription();
+        
+        OperationDescription[] ops = eid.getDispatchableOperation(mc.getOperationName());
+        if (ops == null || ops.length == 0) {
+            throw ExceptionFactory.makeWebServiceException(
+                    "No operation found.  WSDL Operation name: " + mc.getOperationName());
+        }
+        if (ops.length > 1) {
+            throw ExceptionFactory.makeWebServiceException(
+                    "More than one operation found. Overloaded WSDL operations are not supported.
 WSDL Operation name: " +
+                            mc.getOperationName());
+        }
+        OperationDescription op = ops[0];
+        return op;
+    }
+    
+    private EndpointDescription getEndpointDescription(MessageContext mc) {
+        AxisService axisSvc = mc.getAxisMessageContext().getAxisService();
+
+        Parameter param = axisSvc.getParameter(EndpointDescription.AXIS_SERVICE_PARAMETER);
+
+        EndpointDescription ed = (EndpointDescription) param.getValue();
+        return ed;
+    }
+    
+}

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

Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java?view=auto&rev=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
Tue Jun  5 07:39:21 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.ejb;
+
+import javax.interceptor.InvocationContext;
+import javax.xml.ws.Provider;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher;
+
+public class EJBProviderDispatcher extends ProviderDispatcher {
+
+    private InvocationContext invContext;
+
+    public EJBProviderDispatcher(InvocationContext invContext) {
+        super(null, null); 
+        this.invContext = invContext;
+    }
+
+    @Override
+    protected Object invokeProvider(MessageContext ctx,
+                                    Provider provider,
+                                    Object input) throws Exception {
+        this.invContext.setParameters(new Object[] {input});
+        return this.invContext.proceed();
+    }
+    
+}

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

Added: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBServiceDispatcher.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBServiceDispatcher.java?view=auto&rev=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBServiceDispatcher.java
(added)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBServiceDispatcher.java
Tue Jun  5 07:39:21 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.ejb;
+
+import java.lang.reflect.Method;
+
+import javax.interceptor.InvocationContext;
+
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.server.dispatcher.JavaBeanDispatcher;
+
+public class EJBServiceDispatcher extends JavaBeanDispatcher {
+
+    private InvocationContext invContext;
+
+    public EJBServiceDispatcher(InvocationContext invContext) {
+        super(null, null); 
+        this.invContext = invContext;
+    }
+
+    @Override
+    protected Object invokeService(MessageContext ctx,
+                                   Method method, 
+                                   Object obj,
+                                   Object args[]) throws Exception {
+        this.invContext.setParameters(args);
+        return this.invContext.proceed();
+    }
+ 
+}

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

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=544505&r1=544504&r2=544505
==============================================================================
--- 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
Tue Jun  5 07:39:21 2007
@@ -19,7 +19,9 @@
 
 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;
@@ -30,15 +32,26 @@
 public class EJBWebServiceContainer extends Axis2WebServiceContainer {
 
     private String contextRoot = null;
+    private DeploymentInfo deploymnetInfo;
     
     public EJBWebServiceContainer(PortInfo portInfo,
-                                    String endpointClassName,
-                                    ClassLoader classLoader,
-                                    Context context,
-                                    URL configurationBaseUrl) {
+                                  String endpointClassName,
+                                  ClassLoader classLoader,
+                                  Context context,
+                                  URL configurationBaseUrl,
+                                  DeploymentInfo deploymnetInfo) {
         super(portInfo, endpointClassName, classLoader, context, configurationBaseUrl);
+        this.deploymnetInfo = deploymnetInfo;
     }
     
+    @Override
+    protected AxisServiceGenerator createServiceGenerator() {
+        AxisServiceGenerator serviceGenerator = super.createServiceGenerator();
+        serviceGenerator.setMessageReceiver(new EJBMessageReceiver(this.endpointClass, this.deploymnetInfo));
+        return serviceGenerator;
+    }
+    
+    @Override
     protected void initContextRoot(Request request) {       
         String servicePath = portInfo.getLocation();
         

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java?view=diff&rev=544505&r1=544504&r2=544505
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
Tue Jun  5 07:39:21 2007
@@ -17,7 +17,10 @@
 
 package org.apache.geronimo.axis2.ejb;
 
-import org.apache.geronimo.axis2.Axis2WebServiceContainer;
+import java.net.URL;
+
+import javax.naming.Context;
+
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -26,9 +29,7 @@
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.openejb.EjbDeployment;
 import org.apache.geronimo.webservices.SoapHandler;
-
-import javax.naming.Context;
-import java.net.URL;
+import org.apache.openejb.DeploymentInfo;
 
 /**
  * @version $Rev$ $Date$
@@ -37,6 +38,7 @@
 
     private SoapHandler soapHandler;
     private String location;
+    private EJBWebServiceContainer container;
 
     public EJBWebServiceGBean(EjbDeployment ejbDeploymentContext,
                               PortInfo portInfo,                              
@@ -52,24 +54,25 @@
             return;
         }
                 
+        this.soapHandler = soapHandler;
         this.location = portInfo.getLocation();
         
         assert this.location != null : "null location received";
                 
         String beanClassName = ejbDeploymentContext.getBeanClass().getName();    
-        Context context = ejbDeploymentContext.getComponentContext();
-        
+        Context context = ejbDeploymentContext.getComponentContext();        
         ClassLoader classLoader = ejbDeploymentContext.getClassLoader();
+        DeploymentInfo deploymnetInfo = ejbDeploymentContext.getDeploymentInfo();
         
-        //TODO: need to invoke the EJB container and forward the call to the EJB container.
-        
-        Axis2WebServiceContainer container = 
-            new EJBWebServiceContainer(portInfo, beanClassName, classLoader, context, configurationBaseUrl);
+        this.container = 
+            new EJBWebServiceContainer(portInfo, beanClassName, classLoader, 
+                                       context, configurationBaseUrl, deploymnetInfo);
+        this.container.init();
          
         if (soapHandler != null) {
             soapHandler.addWebService(this.location, 
                                       virtualHosts, 
-                                      container, 
+                                      this.container, 
                                       securityRealmName, 
                                       realmName, 
                                       transportGuarantee, 
@@ -85,7 +88,10 @@
     public void doStop() throws Exception {        
         if (this.soapHandler != null) {
             this.soapHandler.removeWebService(this.location);
-        }        
+        } 
+        if (this.container != null) {
+            this.container.destroy();
+        }
     }
 
     public void doFail() {

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=544505&r1=544504&r2=544505
==============================================================================
--- 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
Tue Jun  5 07:39:21 2007
@@ -78,7 +78,7 @@
         setMsgContextProperties(msgContext, service, response, request);
         annotationProcessor = new JAXWSAnnotationProcessor(this.jndiResolver,
                 new POJOWebServiceContext(msgContext));
-        init();
+        initHandlers();
         try {
             HTTPTransportUtils.processHTTPPostRequest(
                     msgContext,
@@ -88,7 +88,7 @@
                     soapAction,
                     request.getURI().getPath());
         } finally {
-            stop();
+            stopHandlers();
         }        
     }
     
@@ -100,7 +100,7 @@
         super.setMsgContextProperties(msgContext, service, response, request);
     }
     
-    protected void init() {
+    protected void initHandlers() {
         // configure and inject handlers
         try {
             configureHandlers();
@@ -134,7 +134,7 @@
         chain = handlerResolver.getHandlerChain(null);
     }
 
-    public void stop() {
+    public void stopHandlers() {
         // call handlers preDestroy
         for (Handler handler : chain) {
             this.annotationProcessor.invokePreDestroy(handler);

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=544505&r1=544504&r2=544505
==============================================================================
--- 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
Tue Jun  5 07:39:21 2007
@@ -73,7 +73,9 @@
     }
 
     public WebServiceContainer getWebServiceContainer() {
-        return new POJOWebServiceContainer(portInfo, endpointClassName, classLoader, context,
configurationBaseUrl);
+        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName,
classLoader, context, configurationBaseUrl);
+        container.init();
+        return container;
     }
 
     public static final GBeanInfo GBEAN_INFO;



Mime
View raw message