geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r952899 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
Date Wed, 09 Jun 2010 04:49:38 GMT
Author: xuhaihong
Date: Wed Jun  9 04:49:38 2010
New Revision: 952899

URL: http://svn.apache.org/viewvc?rev=952899&view=rev
Log:
Identify the interface type while exposing EJB as web service, or OpenEJB could not determine
the current invocation type while the same interface is used for both business interface and
endpointInterface

Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBMessageReceiver.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java

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=952899&r1=952898&r2=952899&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
Wed Jun  9 04:49:38 2010
@@ -42,12 +42,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.openejb.ApplicationException;
 import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
 import org.apache.openejb.RpcContainer;
 
 public class EJBMessageReceiver implements MessageReceiver
 {
     private static final Logger LOG = LoggerFactory.getLogger(EJBMessageReceiver.class);
-    
+
     private DeploymentInfo deploymentInfo;
     private Class serviceImplClass;
     private EJBWebServiceContainer container;
@@ -57,17 +58,17 @@ public class EJBMessageReceiver implemen
         this.serviceImplClass = serviceImplClass;
         this.deploymentInfo = deploymentInfo;
     }
-    
-    public void receive(org.apache.axis2.context.MessageContext axisMsgCtx) throws AxisFault
{         
+
+    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));
-        
+
         SoapMessageContext jaxwsContext =
             MessageContextFactory.createSoapMessageContext(requestMsgCtx);
-        
+
         Method method = null;
         if (Provider.class.isAssignableFrom(this.serviceImplClass)) {
             method = getProviderMethod();
@@ -77,26 +78,26 @@ public class EJBMessageReceiver implemen
             method = getServiceMethod(requestMsgCtx);
             ContextUtils.addWSDLProperties(requestMsgCtx, jaxwsContext);
         }
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("Invoking '" + method.getName() + "' method.");
         }
-        
+
         EJBInterceptor interceptor = new EJBInterceptor(this.container, requestMsgCtx);
         EJBAddressingSupport wsaSupport = new EJBAddressingSupport(jaxwsContext);
         Object[] arguments = { jaxwsContext, interceptor, wsaSupport };
-        
+
         RpcContainer container = (RpcContainer) this.deploymentInfo.getContainer();
 
         Class callInterface = this.deploymentInfo.getServiceEndpointInterface();
-        
+
         method = getMostSpecificMethod(method, callInterface);
-        
+
         //This assumes that we are on the ultimate execution thread
-        ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,

-                                                           axisMsgCtx);        
+        ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,
+                                                           axisMsgCtx);
         try {
-            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), callInterface,
method, arguments, null);
+            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), InterfaceType.SERVICE_ENDPOINT,
callInterface, method, arguments, null);
             // TODO: update response message with new response value?
         } catch (ApplicationException e) {
             if (e.getCause() instanceof AxisFault) {
@@ -107,11 +108,11 @@ public class EJBMessageReceiver implemen
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
         } finally {
-            ThreadContextMigratorUtil.performThreadCleanup(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,

+            ThreadContextMigratorUtil.performThreadCleanup(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID,
                                                            axisMsgCtx);
         }
     }
-    
+
     private static Method getMostSpecificMethod(Method method, Class<?> targetClass)
{
         if (method != null && targetClass != null) {
             try {
@@ -123,7 +124,7 @@ public class EJBMessageReceiver implemen
         }
         return method;
     }
-    
+
     private Method getServiceMethod(MessageContext mc) {
         OperationDescription opDesc = mc.getOperationDescription();
         if (opDesc == null) {
@@ -138,11 +139,11 @@ public class EJBMessageReceiver implemen
 
         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(
@@ -156,7 +157,7 @@ public class EJBMessageReceiver implemen
         OperationDescription op = ops[0];
         return op;
     }
-    
+
     private EndpointDescription getEndpointDescription(MessageContext mc) {
         AxisService axisSvc = mc.getAxisMessageContext().getAxisService();
 
@@ -165,7 +166,7 @@ public class EJBMessageReceiver implemen
         EndpointDescription ed = (EndpointDescription) param.getValue();
         return ed;
     }
-    
+
     private Method getProviderMethod() {
         try {
             return this.serviceImplClass.getMethod("invoke", getProviderType());
@@ -173,12 +174,12 @@ public class EJBMessageReceiver implemen
             throw ExceptionFactory.makeWebServiceException("Could not get Provider.invoke()
method");
         }
     }
-    
+
     private Class<?> getProviderType() {
         Type[] giTypes = this.serviceImplClass.getGenericInterfaces();
         for (Type giType : giTypes) {
             if (giType instanceof ParameterizedType) {
-                ParameterizedType paramType = (ParameterizedType)giType;            
+                ParameterizedType paramType = (ParameterizedType)giType;
                 Class interfaceName = (Class)paramType.getRawType();
                 if (interfaceName == javax.xml.ws.Provider.class) {
                     if (paramType.getActualTypeArguments().length > 1) {
@@ -186,11 +187,11 @@ public class EJBMessageReceiver implemen
                             "Provider cannot have more than one Generic Types defined as
per JAX-WS Specification");
                     }
                 }
-                return (Class)paramType.getActualTypeArguments()[0];                    
       
+                return (Class)paramType.getActualTypeArguments()[0];
             }
         }
         throw ExceptionFactory.makeWebServiceException(
             "Provider has to implement javax.xml.ws.Provider interface as javax.xml.ws.Provider<DataSource>,
javax.xml.ws.Provider<SOAPMessage>, javax.xml.ws.Provider<Source> or javax.xml.ws.Provider<JAXBContext>");
     }
-    
+
 }

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java?rev=952899&r1=952898&r2=952899&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-ejb/src/main/java/org/apache/geronimo/cxf/ejb/EJBMethodInvoker.java
Wed Jun  9 04:49:38 2010
@@ -35,6 +35,7 @@ import org.apache.cxf.message.FaultMode;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.service.invoker.Factory;
 import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.InterfaceType;
 import org.apache.openejb.RpcContainer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,10 +43,10 @@ import org.slf4j.LoggerFactory;
 public class EJBMethodInvoker extends AbstractJAXWSMethodInvoker {
 
     private static final Logger LOG = LoggerFactory.getLogger(EJBMethodInvoker.class);
-    
-    private static final String HANDLER_PROPERTIES = 
+
+    private static final String HANDLER_PROPERTIES =
             "HandlerProperties";
-    
+
     private DeploymentInfo deploymentInfo;
     private Bus bus;
     private EJBEndpoint endpoint;
@@ -61,19 +62,19 @@ public class EJBMethodInvoker extends Ab
     public Object getServiceObject(Exchange context) {
         return null;
     }
-    
+
     @Override
     public void releaseServiceObject(Exchange ex, Object obj) {
         // do nothing
     }
-    
+
     @Override
-    protected Object invoke(Exchange exchange, 
-                            Object serviceObject, 
-                            Method m, 
-                            List<Object> params) {       
+    protected Object invoke(Exchange exchange,
+                            Object serviceObject,
+                            Method m,
+                            List<Object> params) {
         Object result = null;
-        
+
         InvocationContext invContext = exchange.get(InvocationContext.class);
         if (invContext == null) {
             LOG.debug("PreEJBInvoke");
@@ -81,42 +82,42 @@ public class EJBMethodInvoker extends Ab
         } else {
             LOG.debug("EJBInvoke"); // calls performInvocation()
             result = super.invoke(exchange, serviceObject, m, params);
-        }    
-        
+        }
+
         return result;
     }
-    
+
     @Override
-    protected Object performInvocation(Exchange exchange, 
-                                       Object serviceObject, 
+    protected Object performInvocation(Exchange exchange,
+                                       Object serviceObject,
                                        Method m,
                                        Object[] paramArray) throws Exception {
         InvocationContext invContext = exchange.get(InvocationContext.class);
         invContext.setParameters(paramArray);
         Object res = invContext.proceed();
-        
+
         EJBMessageContext ctx = (EJBMessageContext)invContext.getContextData();
-        
+
         Map<String, Object> handlerProperties = (Map<String, Object>)exchange.get(HANDLER_PROPERTIES);
         addHandlerProperties(ctx, handlerProperties);
-        
+
         updateWebServiceContext(exchange, ctx);
-                      
+
         return res;
     }
-    
-    private Object preEjbInvoke(Exchange exchange, 
-                                Object serviceObject, 
-                                Method method, 
-                                List<Object> params) {           
-        
+
+    private Object preEjbInvoke(Exchange exchange,
+                                Object serviceObject,
+                                Method method,
+                                List<Object> params) {
+
         EJBMessageContext ctx = new EJBMessageContext(exchange.getInMessage(), Scope.APPLICATION);
         WebServiceContextImpl.setMessageContext(ctx);
 
         Map<String, Object> handlerProperties = removeHandlerProperties(ctx);
         exchange.put(HANDLER_PROPERTIES, handlerProperties);
-        
-        try {           
+
+        try {
             EJBInterceptor interceptor = new EJBInterceptor(params, method, this.endpoint,
this.bus, exchange);
             Object[] arguments = { ctx, interceptor, ctx };
 
@@ -124,7 +125,7 @@ public class EJBMethodInvoker extends Ab
 
             Class callInterface = this.deploymentInfo.getServiceEndpointInterface();
             method = getMostSpecificMethod(method, callInterface);
-            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), callInterface,
method, arguments, null);
+            Object res = container.invoke(this.deploymentInfo.getDeploymentID(), InterfaceType.SERVICE_ENDPOINT,
callInterface, method, arguments, null);
 
             if (exchange.isOneWay()) {
                 return null;
@@ -141,10 +142,10 @@ public class EJBMethodInvoker extends Ab
             WebServiceContextImpl.clear();
         }
     }
-    
-    public Object directEjbInvoke(Exchange exchange, 
-                                  Method m, 
-                                  List<Object> params) throws Exception {        
+
+    public Object directEjbInvoke(Exchange exchange,
+                                  Method m,
+                                  List<Object> params) throws Exception {
         Object[] paramArray;
         if (params != null) {
             paramArray = params.toArray();
@@ -153,5 +154,5 @@ public class EJBMethodInvoker extends Ab
         }
         return performInvocation(exchange, null, m, paramArray);
     }
-            
+
 }



Mime
View raw message