[jbossws-commits] JBossWS SVN: r5202 - in stack/cxf/trunk: ant-import and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Dec 6 07:36:18 EST 2007


Author: thomas.diesler at jboss.com
Date: 2007-12-06 07:36:18 -0500 (Thu, 06 Dec 2007)
New Revision: 5202

Added:
   stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
Modified:
   stack/cxf/trunk/ant-import/build-thirdparty.xml
   stack/cxf/trunk/build.xml
   stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java
   stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java
   stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt
   stack/cxf/trunk/version.properties
Log:
Add support for EJB3 endpoints

Modified: stack/cxf/trunk/ant-import/build-thirdparty.xml
===================================================================
--- stack/cxf/trunk/ant-import/build-thirdparty.xml	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/ant-import/build-thirdparty.xml	2007-12-06 12:36:18 UTC (rev 5202)
@@ -67,6 +67,7 @@
     <get src="${jboss.repository}/sun-jaxb/${sun-jaxb}/lib/jaxb-api.jar" dest="${thirdparty.dir}/jaxb-api.jar" usetimestamp="true" verbose="true"/>
     <get src="${jboss.repository}/sun-jaxb/${sun-jaxb}/lib/jaxb-impl.jar" dest="${thirdparty.dir}/jaxb-impl.jar" usetimestamp="true" verbose="true"/>
     <get src="${jboss.repository}/sun-jaxb/${sun-jaxb}/lib/jaxb-xjc.jar" dest="${thirdparty.dir}/jaxb-xjc.jar" usetimestamp="true" verbose="true"/>
+    <get src="${jboss.repository}/sun-jaxrpc/${sun-jaxrpc}/lib/jaxrpc-api.jar" dest="${thirdparty.dir}/jaxrpc-api.jar" usetimestamp="true" verbose="true"/>
     <get src="${jboss.repository}/sun-servlet/${sun-servlet}/lib/servlet-api.jar" dest="${thirdparty.dir}/servlet-api.jar" usetimestamp="true" verbose="true"/>
     <get src="${jboss.repository}/woodstox/${woodstox}/lib/wstx.jar" dest="${thirdparty.dir}/wstx.jar" usetimestamp="true" verbose="true"/>
     

Modified: stack/cxf/trunk/build.xml
===================================================================
--- stack/cxf/trunk/build.xml	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/build.xml	2007-12-06 12:36:18 UTC (rev 5202)
@@ -171,6 +171,7 @@
         <include name="XmlSchema-${cxf.xmlschema}.jar"/>
         <include name="jaxb-api.jar"/>
         <include name="jaxb-impl.jar"/>
+        <include name="jaxrpc-api.jar"/>
         <include name="stax-api.jar"/>
         <include name="wsdl4j.jar"/>
         <include name="wstx.jar"/>
@@ -223,6 +224,7 @@
         <include name="XmlSchema-${cxf.xmlschema}.jar"/>
         <include name="jaxb-api.jar"/>
         <include name="jaxb-impl.jar"/>
+        <include name="jaxrpc-api.jar"/>
         <include name="stax-api.jar"/>
         <include name="wsdl4j.jar"/>
         <include name="wstx.jar"/>

Added: stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java
===================================================================
--- stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java	                        (rev 0)
+++ stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/AbstractInvoker.java	2007-12-06 12:36:18 UTC (rev 5202)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf;
+
+//$Id: InvokerJSE.java 5200 2007-12-06 11:46:07Z thomas.diesler at jboss.com $
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
+
+import org.apache.cxf.frontend.MethodDispatcher;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxws.context.WebServiceContextImpl;
+import org.apache.cxf.jaxws.context.WrappedMessageContext;
+import org.apache.cxf.jaxws.support.ContextPropertiesMapping;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.MessageContentsList;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.invoker.Invoker;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.EndpointAssociation;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * An abstract CXF invoker
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-Dec-2007
+ */
+public abstract class AbstractInvoker implements Invoker
+{
+   public Object invoke(Exchange exchange, Object o)
+   {
+      // set up the webservice request context 
+      MessageContext msgCtx = ContextPropertiesMapping.createWebServiceContext(exchange);
+
+      Map<String, Scope> scopes = CastUtils.cast((Map<?, ?>)msgCtx.get(WrappedMessageContext.SCOPES));
+      Map<String, Object> handlerScopedStuff = new HashMap<String, Object>();
+      if (scopes != null)
+      {
+         for (Map.Entry<String, Scope> scope : scopes.entrySet())
+         {
+            if (scope.getValue() == Scope.HANDLER)
+            {
+               handlerScopedStuff.put(scope.getKey(), msgCtx.get(scope.getKey()));
+            }
+         }
+         for (String key : handlerScopedStuff.keySet())
+         {
+            msgCtx.remove(key);
+         }
+      }
+
+      WebServiceContextImpl.setMessageContext(msgCtx);
+
+      BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
+      MethodDispatcher md = (MethodDispatcher)exchange.get(Service.class).get(MethodDispatcher.class.getName());
+      Method m = md.getMethod(bop);
+
+      List<Object> paramList = CastUtils.cast((List<?>)o);
+      Object[] params = paramList.toArray();
+
+      Endpoint ep = EndpointAssociation.getEndpoint();
+      InvocationHandler invHandler = ep.getInvocationHandler();
+
+      Invocation inv = invHandler.createInvocation();
+      InvocationContext invContext = inv.getInvocationContext();
+      inv.getInvocationContext().addAttachment(WebServiceContext.class, getWebServiceContext(msgCtx));
+      invContext.addAttachment(MessageContext.class, msgCtx);
+      inv.setJavaMethod(m);
+      inv.setArgs(params);
+
+      Object retObj = null;
+      try
+      {
+         invContext.setTargetBean(getTargetBean(ep));
+         invHandler.invoke(ep, inv);
+         retObj = inv.getReturnValue();
+      }
+      catch (Exception ex)
+      {
+         handleException(ex);
+      }
+
+      for (Map.Entry<String, Object> key : handlerScopedStuff.entrySet())
+      {
+         msgCtx.put(key.getKey(), key.getValue());
+         msgCtx.setScope(key.getKey(), Scope.HANDLER);
+      }
+
+      //update the webservice response context
+      ContextPropertiesMapping.updateWebServiceContext(exchange, msgCtx);
+      //clear the WebServiceContextImpl's ThreadLocal variable
+      WebServiceContextImpl.clear();
+
+      return new MessageContentsList(retObj);
+   }
+
+   protected abstract WebServiceContext getWebServiceContext(MessageContext msgCtx);
+
+   protected Object getTargetBean(Endpoint ep) throws InstantiationException, IllegalAccessException
+   {
+      Class beanClass = ep.getTargetBeanClass();
+      return beanClass.newInstance();
+   }
+
+   protected void handleException(Exception ex)
+   {
+      Throwable th = ex;
+      if (ex instanceof InvocationTargetException)
+         th = ((InvocationTargetException)ex).getTargetException();
+
+      throw new RuntimeException(th);
+   }
+
+}
\ No newline at end of file

Modified: stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java
===================================================================
--- stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerEJB3.java	2007-12-06 12:36:18 UTC (rev 5202)
@@ -23,54 +23,21 @@
 
 //$Id$
 
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.service.invoker.Invoker;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
 
+import org.jboss.wsf.spi.invocation.WebServiceContextEJB;
+
 /**
  * An XFire invoker for EJB3
  * 
  * @author Thomas.Diesler at jboss.org
  * @since 21-May-2007
  */
-public class InvokerEJB3 implements Invoker
+public class InvokerEJB3 extends AbstractInvoker
 {
-   public Object invoke(Exchange arg0, Object arg1)
+   protected WebServiceContext getWebServiceContext(MessageContext msgCtx)
    {
-      // TODO Auto-generated method stub
-      return null;
+      return new WebServiceContextEJB(msgCtx);
    }
-
-   /*
-    public Object invoke(Method m, Object[] params, MessageContext context) 
-    {
-    Endpoint ep = EndpointAssociation.getEndpoint();
-    InvocationHandler invHandler = ep.getInvocationHandler();
-
-    Invocation inv = invHandler.createInvocation();
-    inv.getInvocationContext().addAttachment(MessageContext.class, context);
-    inv.setJavaMethod(m);
-    inv.setArgs(params);
-
-    Object retObj = null;
-    try
-    {
-    invHandler.invoke(ep, inv);
-    retObj = inv.getReturnValue();
-    }
-    catch (Exception ex)
-    {
-    handleException(ex);
-    }
-
-    return retObj;
-    }
-
-    private void handleException(Exception ex) throws XFireFault
-    {
-    if (ex instanceof InvocationTargetException)
-    throw XFireFault.createFault(((InvocationTargetException)ex).getTargetException());
-
-    throw XFireFault.createFault(ex);
-    }
-    */
 }

Modified: stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java
===================================================================
--- stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/InvokerJSE.java	2007-12-06 12:36:18 UTC (rev 5202)
@@ -23,31 +23,9 @@
 
 //$Id$
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.MessageContext.Scope;
 
-import org.apache.cxf.frontend.MethodDispatcher;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.jaxws.context.WebServiceContextImpl;
-import org.apache.cxf.jaxws.context.WrappedMessageContext;
-import org.apache.cxf.jaxws.support.ContextPropertiesMapping;
-import org.apache.cxf.message.Exchange;
-import org.apache.cxf.message.MessageContentsList;
-import org.apache.cxf.service.Service;
-import org.apache.cxf.service.invoker.Invoker;
-import org.apache.cxf.service.model.BindingOperationInfo;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.EndpointAssociation;
-import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.InvocationContext;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
 import org.jboss.wsf.spi.invocation.WebServiceContextJSE;
 
 /**
@@ -56,88 +34,10 @@
  * @author Thomas.Diesler at jboss.org
  * @since 21-May-2007
  */
-public class InvokerJSE implements Invoker
+public class InvokerJSE extends AbstractInvoker
 {
-   public Object invoke(Exchange exchange, Object o)
+   protected WebServiceContext getWebServiceContext(MessageContext msgCtx)
    {
-      // set up the webservice request context 
-      MessageContext msgCtx = ContextPropertiesMapping.createWebServiceContext(exchange);
-
-      Map<String, Scope> scopes = CastUtils.cast((Map<?, ?>)msgCtx.get(WrappedMessageContext.SCOPES));
-      Map<String, Object> handlerScopedStuff = new HashMap<String, Object>();
-      if (scopes != null)
-      {
-         for (Map.Entry<String, Scope> scope : scopes.entrySet())
-         {
-            if (scope.getValue() == Scope.HANDLER)
-            {
-               handlerScopedStuff.put(scope.getKey(), msgCtx.get(scope.getKey()));
-            }
-         }
-         for (String key : handlerScopedStuff.keySet())
-         {
-            msgCtx.remove(key);
-         }
-      }
-
-      WebServiceContextImpl.setMessageContext(msgCtx);
-
-      BindingOperationInfo bop = exchange.get(BindingOperationInfo.class);
-      MethodDispatcher md = (MethodDispatcher)exchange.get(Service.class).get(MethodDispatcher.class.getName());
-      Method m = md.getMethod(bop);
-
-      List<Object> paramList = CastUtils.cast((List<?>)o);
-      Object[] params = paramList.toArray();
-
-      Endpoint ep = EndpointAssociation.getEndpoint();
-      InvocationHandler invHandler = ep.getInvocationHandler();
-
-      Invocation inv = invHandler.createInvocation();
-      InvocationContext invContext = inv.getInvocationContext();
-      inv.getInvocationContext().addAttachment(WebServiceContext.class, new WebServiceContextJSE(msgCtx));
-      invContext.addAttachment(MessageContext.class, msgCtx);
-      inv.setJavaMethod(m);
-      inv.setArgs(params);
-
-      Object retObj = null;
-      try
-      {
-         invContext.setTargetBean(getTargetBean(ep));
-         invHandler.invoke(ep, inv);
-         retObj = inv.getReturnValue();
-      }
-      catch (Exception ex)
-      {
-         handleException(ex);
-      }
-
-      for (Map.Entry<String, Object> key : handlerScopedStuff.entrySet())
-      {
-         msgCtx.put(key.getKey(), key.getValue());
-         msgCtx.setScope(key.getKey(), Scope.HANDLER);
-      }
-
-      //update the webservice response context
-      ContextPropertiesMapping.updateWebServiceContext(exchange, msgCtx);
-      //clear the WebServiceContextImpl's ThreadLocal variable
-      WebServiceContextImpl.clear();
-
-      return new MessageContentsList(retObj);
+      return new WebServiceContextJSE(msgCtx);
    }
-
-   private Object getTargetBean(Endpoint ep) throws InstantiationException, IllegalAccessException
-   {
-      Class beanClass = ep.getTargetBeanClass();
-      return beanClass.newInstance();
-   }
-
-   private void handleException(Exception ex)
-   {
-      Throwable th = ex;
-      if (ex instanceof InvocationTargetException)
-         th = ((InvocationTargetException)ex).getTargetException();
-
-      throw new RuntimeException(th);
-   }
-
 }
\ No newline at end of file

Modified: stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt
===================================================================
--- stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt	2007-12-06 12:36:18 UTC (rev 5202)
@@ -11,11 +11,6 @@
 #
 ###################################################################
 
-# [CXF-817] Add support for configurable invoker in cxf.xml
-org/jboss/test/ws/jaxws/samples/context/WebServiceContextEJBTestCase.*
-org/jboss/test/ws/jaxws/samples/webservice/WebServiceEJB3TestCase.*
-org/jboss/test/ws/jaxws/samples/swaref/**
-
 # [JBWS-1683] Fix JAXR samples for CXF
 org/jboss/test/ws/jaxws/samples/jaxr/**
 

Modified: stack/cxf/trunk/version.properties
===================================================================
--- stack/cxf/trunk/version.properties	2007-12-06 12:32:32 UTC (rev 5201)
+++ stack/cxf/trunk/version.properties	2007-12-06 12:36:18 UTC (rev 5202)
@@ -47,6 +47,7 @@
 jboss-security-spi=2.0.0.Beta
 stax-api=1.0
 sun-jaxb=2.1.4
+sun-jaxrpc=1.1
 sun-servlet=2.5
 woodstox=3.1.1
 




More information about the jbossws-commits mailing list