[jbossws-commits] JBossWS SVN: r2409 - in trunk: integration-jboss50 and 5 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Feb 20 06:38:36 EST 2007


Author: thomas.diesler at jboss.com
Date: 2007-02-20 06:38:36 -0500 (Tue, 20 Feb 2007)
New Revision: 2409

Added:
   trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java
Modified:
   trunk/build/ant-import/build-thirdparty.xml
   trunk/integration-jboss50/.classpath
   trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB21.java
   trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryEJBTestCase.java
   trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryJSETestCase.java
   trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1205/JBWS1205TestCase.java
   trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/webserviceref/WebServiceRefServletTestCase.java
   trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/wsse/WebClientTestCase.java
Log:
[JBWS-758] Dynamically add the service endpoint interceptor
Resurect JAXRPC handlers on EJB21 endpoints



Modified: trunk/build/ant-import/build-thirdparty.xml
===================================================================
--- trunk/build/ant-import/build-thirdparty.xml	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/build/ant-import/build-thirdparty.xml	2007-02-20 11:38:36 UTC (rev 2409)
@@ -114,6 +114,8 @@
       <pathelement location="${jboss50.lib}/jboss-aop-jdk50.jar"/>
       <pathelement location="${jboss50.lib}/jboss-deployers.jar"/>
       <pathelement location="${jboss50.lib}/jboss-j2se.jar"/>
+      <pathelement location="${jboss50.lib}/jboss-system.jar"/>
+      <pathelement location="${jboss50.lib}/jboss-system-jmx.jar"/>
       <pathelement location="${jboss50.lib}/jboss-vfs.jar"/>
       <pathelement location="${jboss50.server.lib}/jboss.jar"/>
       <pathelement location="${jboss50.server.lib}/jnpserver.jar"/>

Modified: trunk/integration-jboss50/.classpath
===================================================================
--- trunk/integration-jboss50/.classpath	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/integration-jboss50/.classpath	2007-02-20 11:38:36 UTC (rev 2409)
@@ -30,5 +30,6 @@
 	<classpathentry kind="lib" path="/build/thirdparty/jbosssx-client.jar" sourcepath="/build/thirdparty/jbosssx-src.zip"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
 	<classpathentry kind="lib" path="/build/thirdparty/jboss-common.jar" sourcepath="/build/thirdparty/jboss-common-sources.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/integration-jboss42"/>
 	<classpathentry kind="output" path="output-eclipse"/>
 </classpath>

Added: trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java
===================================================================
--- trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java	                        (rev 0)
+++ trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -0,0 +1,139 @@
+/*
+* 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.ws.integration.jboss50;
+
+// $Id$
+
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ejb.plugins.AbstractInterceptor;
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvocationKey;
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.CommonBinding;
+import org.jboss.ws.core.CommonBindingProvider;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC;
+import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.jboss.ws.metadata.umdm.HandlerMetaData.HandlerType;
+
+/**
+ * This Interceptor does the ws4ee handler processing.
+ * 
+ * According to the ws4ee spec the handler logic must be invoked after the container
+ * applied method level security to the invocation. 
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 21-Sep-2005
+ */
+public class ServiceEndpointInterceptor extends AbstractInterceptor
+{
+   // provide logging
+   private static Logger log = Logger.getLogger(ServiceEndpointInterceptor.class);
+   
+   // Interceptor implementation --------------------------------------
+
+   /** Before and after we call the service endpoint bean, we process the handler chains.
+    */
+   public Object invoke(final Invocation mi) throws Exception
+   {
+      // If no msgContext, it's not for us
+      CommonMessageContext msgContext = (CommonMessageContext)mi.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
+      if (msgContext == null)
+      {
+         return getNext().invoke(mi);
+      }
+
+      // Get the endpoint invocation 
+      EndpointInvocation epInv = (EndpointInvocation)mi.getValue(EndpointInvocation.class.getName());
+      OperationMetaData opMetaData = epInv.getOperationMetaData();
+
+      // Get the handler callback 
+      String key = ServiceEndpointInvokerEJB21.HandlerCallback.class.getName();
+      ServiceEndpointInvokerEJB21.HandlerCallback callback = (ServiceEndpointInvokerEJB21.HandlerCallback)mi.getValue(key);
+      
+      // Handlers need to be Tx. Therefore we must invoke the handler chain after the TransactionInterceptor.
+      if (callback != null && epInv != null)
+      {
+         try
+         {
+            // call the request handlers
+            boolean handlersPass = callback.callRequestHandlerChain(HandlerType.ENDPOINT);
+            handlersPass = handlersPass && callback.callRequestHandlerChain(HandlerType.POST);
+
+            // Call the next interceptor in the chain
+            if (handlersPass)
+            {
+               // The SOAPContentElements stored in the EndpointInvocation might have changed after
+               // handler processing. Get the updated request payload. This should be a noop if request
+               // handlers did not modify the incomming SOAP message.
+               Object[] reqParams = epInv.getRequestPayload();
+               mi.setArguments(reqParams);
+               Object resObj = getNext().invoke(mi);
+               epInv.setReturnValue(resObj);
+               
+               // Bind the response message
+               CommonBindingProvider bindingProvider = new CommonBindingProvider(opMetaData.getEndpointMetaData());
+               CommonBinding binding = (CommonBinding)bindingProvider.getCommonBinding();
+               SOAPMessage resMessage = (SOAPMessage)binding.bindResponseMessage(opMetaData, epInv);
+               msgContext.setSOAPMessage(resMessage);
+            }
+            
+            // call the response handlers
+            handlersPass = callback.callResponseHandlerChain(HandlerType.POST);
+            handlersPass = handlersPass && callback.callResponseHandlerChain(HandlerType.ENDPOINT);
+            
+            // update the return value after response handler processing
+            Object resObj = epInv.getReturnValue();
+            
+            return resObj;
+         }
+         catch (Exception ex)
+         {
+            try
+            {
+               SOAPMessage faultMessage = SOAPFaultHelperJAXRPC.exceptionToFaultMessage(ex);
+               msgContext.setSOAPMessage(faultMessage);
+
+               // call the fault handlers
+               boolean handlersPass = callback.callFaultHandlerChain(HandlerType.POST, ex);
+               handlersPass = handlersPass && callback.callFaultHandlerChain(HandlerType.ENDPOINT, ex);
+            }
+            catch (Exception subEx)
+            {
+               log.warn("Cannot process handlerChain.handleFault, ignoring: ", subEx);
+            }
+            throw ex;
+         }
+         finally
+         {
+            // do nothing
+         }
+      }
+      else
+      {
+         log.warn("Handler callback not available");
+         return getNext().invoke(mi);
+      }
+   }
+}


Property changes on: trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB21.java
===================================================================
--- trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB21.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB21.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -29,6 +29,9 @@
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.jboss.ejb.EjbModule;
+import org.jboss.ejb.Interceptor;
+import org.jboss.ejb.StatelessSessionContainer;
 import org.jboss.invocation.Invocation;
 import org.jboss.invocation.InvocationKey;
 import org.jboss.invocation.InvocationType;
@@ -102,6 +105,36 @@
          throw new WSException("Cannot obtain JNDI name for: " + ejbName);
 
       objectName = ObjectNameFactory.create("jboss.j2ee:jndiName=" + jndiName + ",service=EJB");
+
+      // Dynamically add the service endpoint interceptor
+      // http://jira.jboss.org/jira/browse/JBWS-758
+      try
+      {
+         EjbModule ejbModule = (EjbModule)server.getAttribute(objectName, "EjbModule");
+         StatelessSessionContainer container = (StatelessSessionContainer)ejbModule.getContainer(ejbName);
+         
+         boolean injectionPointFound = false;
+         Interceptor prev = container.getInterceptor();
+         while (prev != null && prev.getNext() != null)
+         {
+            Interceptor next = prev.getNext();
+            if (next.getNext() == null)
+            {
+               log.debug("Inject service endpoint interceptor after: " + prev.getClass().getName());
+               ServiceEndpointInterceptor sepInterceptor = new ServiceEndpointInterceptor();
+               prev.setNext(sepInterceptor);
+               sepInterceptor.setNext(next);
+               injectionPointFound = true;
+            }
+            prev = next;
+         }
+         if (injectionPointFound == false)
+            log.warn("Cannot service endpoint interceptor injection point");
+      }
+      catch (Exception ex)
+      {
+         log.warn("Cannot add service endpoint interceptor", ex);
+      }
    }
 
    /** Load the SEI implementation bean if necessary 
@@ -148,6 +181,7 @@
          inv.setType(InvocationType.SERVICE_ENDPOINT);
 
          // Set the handler callback and endpoint invocation
+         inv.setValue(HandlerCallback.class.getName(), new HandlerCallback(seInfo), PayloadKey.TRANSIENT);
          inv.setValue(EndpointInvocation.class.getName(), epInv, PayloadKey.TRANSIENT);
 
          String[] sig = { Invocation.class.getName() };
@@ -192,4 +226,43 @@
       else
          return true;
    }
+   
+   // The ServiceEndpointInterceptor calls the methods in this callback
+   public class HandlerCallback
+   {
+      private ServiceEndpointInfo seInfo;
+
+      public HandlerCallback(ServiceEndpointInfo seInfo)
+      {
+         this.seInfo = seInfo;
+      }
+
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
+      public boolean callRequestHandlerChain(HandlerType type)
+      {
+         if (type == HandlerType.PRE)
+            return true;
+         else
+            return handlerDelegate.callRequestHandlerChain(seInfo, type);
+      }
+
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
+      public boolean callResponseHandlerChain(HandlerType type)
+      {
+         if (type == HandlerType.PRE)
+            return true;
+         else
+            return handlerDelegate.callResponseHandlerChain(seInfo, type);
+      }
+      
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
+      public boolean callFaultHandlerChain(HandlerType type, Exception ex)
+      {
+         if (type == HandlerType.PRE)
+            return true;
+         else
+            return handlerDelegate.callFaultHandlerChain(seInfo, type, ex);
+      }
+      
+   }
 }

Modified: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryEJBTestCase.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryEJBTestCase.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryEJBTestCase.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -47,7 +47,7 @@
    protected void setUp() throws Exception
    {
       super.setUp();
-      if (port == null && isTargetJBoss50() == false)
+      if (port == null)
       {
          InitialContext iniCtx = getInitialContext();
          Service service = (Service)iniCtx.lookup("java:comp/env/service/TestService");
@@ -57,12 +57,6 @@
 
    public void testHandlers() throws Exception
    {
-      if (isTargetJBoss50())
-      {
-         System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
-         return;
-      }
-      
       String res = port.helloEnvEntry("InitalMessage");
       assertEquals("InitalMessage:ClientSideHandler:appclient:8:ServerSideHandler:ejb:8:endpoint:ejb:8:ServerSideHandler:ejb:8:ClientSideHandler:appclient:8", res);
    }

Modified: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryJSETestCase.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryJSETestCase.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/enventry/EnvEntryJSETestCase.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -57,12 +57,6 @@
 
    public void testHandlers() throws Exception
    {
-      if (isTargetJBoss50())
-      {
-         System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
-         return;
-      }
-      
       String res = port.helloEnvEntry("InitalMessage");
       assertEquals("InitalMessage:ClientSideHandler:appclient:8:ServerSideHandler:web:8:endpoint:web:8:ServerSideHandler:web:8:ClientSideHandler:appclient:8", res);
    }

Modified: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1205/JBWS1205TestCase.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1205/JBWS1205TestCase.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/jbws1205/JBWS1205TestCase.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -61,12 +61,6 @@
 
    public void testEndpoint() throws Exception
    {
-      if (isTargetJBoss50())
-      {
-         System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
-         return;
-      }
-      
       port.performTest();
    }
 }

Modified: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/webserviceref/WebServiceRefServletTestCase.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/webserviceref/WebServiceRefServletTestCase.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/webserviceref/WebServiceRefServletTestCase.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -76,12 +76,6 @@
 
    public void testServletClient() throws Exception
    {
-      if (isTargetJBoss50())
-      {
-         System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
-         return;
-      }
-      
       URL url = new URL(TARGET_ENDPOINT_ADDRESS + "-servlet-client?echo=HelloWorld");
       BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
       String retStr = br.readLine();

Modified: trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/wsse/WebClientTestCase.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/wsse/WebClientTestCase.java	2007-02-20 10:18:40 UTC (rev 2408)
+++ trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxrpc/wsse/WebClientTestCase.java	2007-02-20 11:38:36 UTC (rev 2409)
@@ -48,12 +48,6 @@
     */
    public void testWebClient() throws Exception
    {
-      if (isTargetJBoss50())
-      {
-         System.out.println("FIXME: [JBAS-3824] Fix ENC for EJB2.1 and Servlets");
-         return;
-      }
-      
       URL url = new URL("http://" + getServerHost() + ":8080/jaxrpc-wsse-rpc/RpcTestClientServlet?input=Hello");
       BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
       String res = br.readLine();




More information about the jbossws-commits mailing list