geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r544651 - in /geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb: EJBEndpointController.java EJBMessageReceiver.java EJBProviderDispatcher.java
Date Tue, 05 Jun 2007 21:57:50 GMT
Author: gawor
Date: Tue Jun  5 14:57:49 2007
New Revision: 544651

URL: http://svn.apache.org/viewvc?view=rev&rev=544651
Log:
handle ejb-based web servies annotated with WebServiceProvider

Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java

Modified: 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=diff&rev=544651&r1=544650&r2=544651
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBEndpointController.java
Tue Jun  5 14:57:49 2007
@@ -36,7 +36,7 @@
     protected EndpointDispatcher getEndpointDispatcher(Class serviceImplClass, Object serviceInstance)
         throws Exception {    
         if (Provider.class.isAssignableFrom(serviceImplClass)) {
-            return new EJBProviderDispatcher(this.invContext);
+            return new EJBProviderDispatcher(serviceImplClass, this.invContext);
         } else {
             return new EJBServiceDispatcher(this.invContext);
         }

Modified: 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=diff&rev=544651&r1=544650&r2=544651
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
Tue Jun  5 14:57:49 2007
@@ -18,6 +18,10 @@
 package org.apache.geronimo.axis2.ejb;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.xml.ws.Provider;
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.description.AxisService;
@@ -53,11 +57,14 @@
         // 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);
+        Method method = null;
+        if (Provider.class.isAssignableFrom(this.serviceImplClass)) {
+            method = getProviderMethod();
+        } else {
+            requestMsgCtx.setOperationDescription(getOperationDescription(requestMsgCtx));
+            method = getServiceMethod(requestMsgCtx);
+        }
         
         if (LOG.isDebugEnabled()) {
             LOG.debug("Invoking '" + method.getName() + "' method.");
@@ -95,13 +102,13 @@
         return method;
     }
     
-    private Method getJavaMethod(MessageContext mc, Class serviceImplClass) {
+    private Method getServiceMethod(MessageContext mc) {
         OperationDescription opDesc = mc.getOperationDescription();
         if (opDesc == null) {
             throw ExceptionFactory.makeWebServiceException("Operation Description was not
set");
         }
 
-        Method returnMethod = opDesc.getMethodFromServiceImpl(serviceImplClass);
+        Method returnMethod = opDesc.getMethodFromServiceImpl(this.serviceImplClass);
         if (returnMethod == null) {
             throw ExceptionFactory
                     .makeWebServiceException(Messages.getMessage("JavaBeanDispatcherErr1"));
@@ -135,6 +142,39 @@
 
         EndpointDescription ed = (EndpointDescription) param.getValue();
         return ed;
+    }
+    
+    private Method getProviderMethod() {
+        try {
+            return this.serviceImplClass.getMethod("invoke", getProviderType());
+        } catch (NoSuchMethodException e) {
+            throw ExceptionFactory.makeWebServiceException("Could not get Provider.invoke()
method");
+        }
+    }
+    
+    private Class<?> getProviderType() {
+        Class providerType = null;
+
+        Type[] giTypes = this.serviceImplClass.getGenericInterfaces();
+        for (Type giType : giTypes) {
+            ParameterizedType paramType = null;
+            try {
+                paramType = (ParameterizedType)giType;
+            } catch (ClassCastException e) {
+                throw ExceptionFactory.makeWebServiceException(
+                        "Provider based SEI Class has to implement javax.xml.ws.Provider
as javax.xml.ws.Provider<String>, javax.xml.ws.Provider<SOAPMessage>, javax.xml.ws.Provider<Source>
or javax.xml.ws.Provider<JAXBContext>");
+            }
+            Class interfaceName = (Class)paramType.getRawType();
+
+            if (interfaceName == javax.xml.ws.Provider.class) {
+                if (paramType.getActualTypeArguments().length > 1) {
+                    throw ExceptionFactory.makeWebServiceException(
+                            "Provider cannot have more than one Generic Types defined as
Per JAX-WS Specification");
+                }
+                providerType = (Class)paramType.getActualTypeArguments()[0];
+            }
+        }
+        return providerType;
     }
     
 }

Modified: 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=diff&rev=544651&r1=544650&r2=544651
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ejb/EJBProviderDispatcher.java
Tue Jun  5 14:57:49 2007
@@ -21,6 +21,7 @@
 import javax.interceptor.InvocationContext;
 import javax.xml.ws.Provider;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher;
 
@@ -28,9 +29,18 @@
 
     private InvocationContext invContext;
 
-    public EJBProviderDispatcher(InvocationContext invContext) {
-        super(null, null); 
+    public EJBProviderDispatcher(Class serviceImplClass, InvocationContext invContext) {
+        super(serviceImplClass, getDummyInstance(serviceImplClass)); 
         this.invContext = invContext;
+    }
+    
+    //  TODO: change ProviderDispatcher so that instance is not required
+    private static Object getDummyInstance(Class serviceImplClass) {
+        try {
+            return serviceImplClass.newInstance();
+        } catch (Exception e) {
+            throw ExceptionFactory.makeWebServiceException("Failed to create provider instance");
+        }
     }
 
     @Override



Mime
View raw message