[jbossws-commits] JBossWS SVN: r4087 - in trunk/integration: jboss42/src/main/java/org/jboss/wsf/container/jboss42 and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Aug 2 06:14:28 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-08-02 06:14:28 -0400 (Thu, 02 Aug 2007)
New Revision: 4087

Added:
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/AbstractInvocationHandler.java
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandler.java
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXRPC.java
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXWS.java
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/AbstractInvocationHandler.java
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandler.java
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXRPC.java
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXWS.java
Modified:
   trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerEJB3.java
   trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerFactoryImpl.java
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerEJB3.java
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerMDB21.java
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB3.java
Log:
Remove SPI dependency on JavaUtils

Modified: trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerEJB3.java
===================================================================
--- trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerEJB3.java	2007-08-02 10:09:53 UTC (rev 4086)
+++ trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerEJB3.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -31,10 +31,10 @@
 import org.jboss.aop.Dispatcher;
 import org.jboss.ejb3.stateless.StatelessContainer;
 import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.container.jboss42.AbstractInvocationHandler;
 import org.jboss.wsf.spi.deployment.ArchiveDeployment;
 import org.jboss.wsf.spi.deployment.Endpoint;
 import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
 
 /**
  * Handles invocations on EJB3 endpoints.
@@ -42,7 +42,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Apr-2007
  */
-public class InvocationHandlerEJB3 extends InvocationHandler
+public class InvocationHandlerEJB3 extends AbstractInvocationHandler
 {
    private ObjectName objectName;
 
@@ -52,7 +52,7 @@
    }
 
    public void init(Endpoint ep)
-   {    
+   {
       String ejbName = ep.getShortName();
       ArchiveDeployment dep = (ArchiveDeployment)ep.getService().getDeployment();
       String nameStr = "jboss.j2ee:name=" + ejbName + ",service=EJB3,jar=" + dep.getSimpleName();
@@ -68,7 +68,6 @@
          throw new WebServiceException("Cannot find service endpoint target: " + objectName);
    }
 
-
    public void invoke(Endpoint ep, Invocation epInv) throws Exception
    {
       try

Modified: trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerFactoryImpl.java
===================================================================
--- trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerFactoryImpl.java	2007-08-02 10:09:53 UTC (rev 4086)
+++ trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/InvocationHandlerFactoryImpl.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -21,7 +21,13 @@
  */
 package org.jboss.wsf.container.jboss40;
 
-import org.jboss.wsf.spi.invocation.*;
+import org.jboss.wsf.container.jboss42.DefaultInvocationHandlerJAXRPC;
+import org.jboss.wsf.container.jboss42.DefaultInvocationHandlerJAXWS;
+import org.jboss.wsf.container.jboss42.InvocationHandlerEJB21;
+import org.jboss.wsf.container.jboss42.InvocationHandlerMDB21;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.InvocationHandlerFactory;
+import org.jboss.wsf.spi.invocation.InvocationType;
 
 /**
  * @author Heiko.Braun at jboss.com
@@ -39,16 +45,16 @@
             handler = new DefaultInvocationHandlerJAXRPC();
             break;
          case JAXRPC_EJB21:
-            handler = new org.jboss.wsf.container.jboss42.InvocationHandlerEJB21();
+            handler = new InvocationHandlerEJB21();
             break;
          case JAXRPC_MDB21:
-            handler = new org.jboss.wsf.container.jboss42.InvocationHandlerMDB21();
+            handler = new InvocationHandlerMDB21();
             break;
          case JAXWS_JSE:
             handler = new DefaultInvocationHandlerJAXWS();
             break;
          case JAXWS_EJB21:
-            handler = new org.jboss.wsf.container.jboss42.InvocationHandlerEJB21();
+            handler = new InvocationHandlerEJB21();
             break;
          case JAXWS_EJB3:
             handler = new InvocationHandlerEJB3();

Added: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/AbstractInvocationHandler.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/AbstractInvocationHandler.java	                        (rev 0)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/AbstractInvocationHandler.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,55 @@
+/*
+ * 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.container.jboss42;
+
+// $Id: InvocationHandlerEJB3.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+import java.lang.reflect.Method;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public abstract class AbstractInvocationHandler extends InvocationHandler
+{
+   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}
\ No newline at end of file

Added: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandler.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandler.java	                        (rev 0)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandler.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,121 @@
+/*
+ * 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.container.jboss42;
+
+// $Id: DefaultInvocationHandlerJAXWS.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+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.ResourceInjector;
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandler extends InvocationHandler
+{
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+   }
+
+   protected Object getTargetBean(Endpoint ep, Invocation epInv)
+   {
+      InvocationContext invCtx = epInv.getInvocationContext();
+      Object targetBean = invCtx.getTargetBean();
+      if (targetBean == null)
+      {
+         try
+         {
+            Class epImpl = ep.getTargetBeanClass();
+            targetBean = epImpl.newInstance();
+            invCtx.setTargetBean(targetBean);
+         }
+         catch (Exception ex)
+         {
+            throw new IllegalStateException("Canot get target bean instance", ex);
+         }
+      }
+      return targetBean;
+   }
+
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+         if (wsContext != null)
+         {
+            SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+            ResourceInjectorFactory factory = spiProvider.getSPI(ResourceInjectorFactory.class);
+            ResourceInjector injector = factory.newResourceInjector();
+            injector.inject(targetBean, wsContext);
+         }
+
+         Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
+         Object retObj = method.invoke(targetBean, epInv.getArgs());
+         epInv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+
+   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}

Added: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXRPC.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXRPC.java	                        (rev 0)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXRPC.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,72 @@
+/*
+ * 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.container.jboss42;
+
+// $Id: DefaultInvocationHandlerJAXRPC.java 3959 2007-07-20 14:44:19Z heiko.braun at jboss.com $
+
+import javax.xml.rpc.server.ServiceLifecycle;
+import javax.xml.rpc.server.ServletEndpointContext;
+
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandlerJAXRPC extends DefaultInvocationHandler
+{
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         if (targetBean instanceof ServiceLifecycle)
+         {
+            ServletEndpointContext sepContext = invContext.getAttachment(ServletEndpointContext.class);
+            if (sepContext != null)
+               ((ServiceLifecycle)targetBean).init(sepContext);
+         }
+
+         try
+         {
+            super.invoke(ep, epInv);
+         }
+         finally
+         {
+            if (targetBean instanceof ServiceLifecycle)
+            {
+               ((ServiceLifecycle)targetBean).destroy();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+}

Added: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXWS.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXWS.java	                        (rev 0)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/DefaultInvocationHandlerJAXWS.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,34 @@
+/*
+ * 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.container.jboss42;
+
+// $Id: DefaultInvocationHandlerJAXWS.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandlerJAXWS extends DefaultInvocationHandler
+{
+}

Modified: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerEJB3.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerEJB3.java	2007-08-02 10:09:53 UTC (rev 4086)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerEJB3.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -54,7 +54,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Apr-2007
  */
-public class InvocationHandlerEJB3 extends InvocationHandler
+public class InvocationHandlerEJB3 extends AbstractInvocationHandler
 {
    private ObjectName objectName;
 

Modified: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerMDB21.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerMDB21.java	2007-08-02 10:09:53 UTC (rev 4086)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/InvocationHandlerMDB21.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -37,7 +37,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Apr-2007
  */
-public class InvocationHandlerMDB21 extends InvocationHandler
+public class InvocationHandlerMDB21 extends AbstractInvocationHandler
 {
    // provide logging
    private static final Logger log = Logger.getLogger(InvocationHandlerMDB21.class);

Added: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/AbstractInvocationHandler.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/AbstractInvocationHandler.java	                        (rev 0)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/AbstractInvocationHandler.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,55 @@
+/*
+ * 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.container.jboss50;
+
+// $Id: InvocationHandlerEJB3.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+import java.lang.reflect.Method;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.invocation.InvocationHandler;
+
+/**
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public abstract class AbstractInvocationHandler extends InvocationHandler
+{
+   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}
\ No newline at end of file

Added: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandler.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandler.java	                        (rev 0)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandler.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,121 @@
+/*
+ * 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.container.jboss50;
+
+// $Id: DefaultInvocationHandlerJAXWS.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+import java.lang.reflect.Method;
+
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.common.JavaUtils;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Endpoint;
+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.ResourceInjector;
+import org.jboss.wsf.spi.invocation.ResourceInjectorFactory;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandler extends InvocationHandler
+{
+   public Invocation createInvocation()
+   {
+      return new Invocation();
+   }
+
+   public void init(Endpoint ep)
+   {
+   }
+
+   protected Object getTargetBean(Endpoint ep, Invocation epInv)
+   {
+      InvocationContext invCtx = epInv.getInvocationContext();
+      Object targetBean = invCtx.getTargetBean();
+      if (targetBean == null)
+      {
+         try
+         {
+            Class epImpl = ep.getTargetBeanClass();
+            targetBean = epImpl.newInstance();
+            invCtx.setTargetBean(targetBean);
+         }
+         catch (Exception ex)
+         {
+            throw new IllegalStateException("Canot get target bean instance", ex);
+         }
+      }
+      return targetBean;
+   }
+
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         WebServiceContext wsContext = invContext.getAttachment(WebServiceContext.class);
+         if (wsContext != null)
+         {
+            SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+            ResourceInjectorFactory factory = spiProvider.getSPI(ResourceInjectorFactory.class);
+            ResourceInjector injector = factory.newResourceInjector();
+            injector.inject(targetBean, wsContext);
+         }
+
+         Method method = getImplMethod(targetBean.getClass(), epInv.getJavaMethod());
+         Object retObj = method.invoke(targetBean, epInv.getArgs());
+         epInv.setReturnValue(retObj);
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+
+   protected Method getImplMethod(Class implClass, Method seiMethod) throws ClassNotFoundException, NoSuchMethodException
+   {
+      String methodName = seiMethod.getName();
+      Class[] paramTypes = seiMethod.getParameterTypes();
+      for (int i = 0; i < paramTypes.length; i++)
+      {
+         Class paramType = paramTypes[i];
+         if (JavaUtils.isPrimitive(paramType) == false)
+         {
+            String paramTypeName = paramType.getName();
+            paramType = JavaUtils.loadJavaType(paramTypeName);
+            paramTypes[i] = paramType;
+         }
+      }
+
+      Method implMethod = implClass.getMethod(methodName, paramTypes);
+      return implMethod;
+   }
+}

Added: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXRPC.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXRPC.java	                        (rev 0)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXRPC.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,72 @@
+/*
+ * 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.container.jboss50;
+
+// $Id: DefaultInvocationHandlerJAXRPC.java 3959 2007-07-20 14:44:19Z heiko.braun at jboss.com $
+
+import javax.xml.rpc.server.ServiceLifecycle;
+import javax.xml.rpc.server.ServletEndpointContext;
+
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.Invocation;
+import org.jboss.wsf.spi.invocation.InvocationContext;
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandlerJAXRPC extends DefaultInvocationHandler
+{
+   public void invoke(Endpoint ep, Invocation epInv) throws Exception
+   {
+      try
+      {
+         Object targetBean = getTargetBean(ep, epInv);
+
+         InvocationContext invContext = epInv.getInvocationContext();
+         if (targetBean instanceof ServiceLifecycle)
+         {
+            ServletEndpointContext sepContext = invContext.getAttachment(ServletEndpointContext.class);
+            if (sepContext != null)
+               ((ServiceLifecycle)targetBean).init(sepContext);
+         }
+
+         try
+         {
+            super.invoke(ep, epInv);
+         }
+         finally
+         {
+            if (targetBean instanceof ServiceLifecycle)
+            {
+               ((ServiceLifecycle)targetBean).destroy();
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         handleInvocationException(e);
+      }
+   }
+}

Added: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXWS.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXWS.java	                        (rev 0)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/DefaultInvocationHandlerJAXWS.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -0,0 +1,34 @@
+/*
+ * 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.container.jboss50;
+
+// $Id: DefaultInvocationHandlerJAXWS.java 4023 2007-07-28 07:14:06Z thomas.diesler at jboss.com $
+
+/**
+ * Handles invocations on JSE endpoints.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DefaultInvocationHandlerJAXWS extends DefaultInvocationHandler
+{
+}

Modified: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB3.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB3.java	2007-08-02 10:09:53 UTC (rev 4086)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB3.java	2007-08-02 10:14:28 UTC (rev 4087)
@@ -54,7 +54,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 25-Apr-2007
  */
-public class InvocationHandlerEJB3 extends InvocationHandler
+public class InvocationHandlerEJB3 extends AbstractInvocationHandler
 {
    private ObjectName objectName;
 




More information about the jbossws-commits mailing list