[jbossws-commits] JBossWS SVN: r3523 - in branches/jbossws-2.0: integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50 and 2 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Sat Jun 9 13:23:17 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-06-09 13:23:17 -0400 (Sat, 09 Jun 2007)
New Revision: 3523

Added:
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/DelegatingInvocation.java
Modified:
   branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ServiceEndpointInterceptor.java
   branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB21.java
   branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/ServiceEndpointInterceptor.java
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/HandlerCallback.java
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java
Log:
Fix EJB21 endpoint handler callback

Modified: branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ServiceEndpointInterceptor.java
===================================================================
--- branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ServiceEndpointInterceptor.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/ServiceEndpointInterceptor.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -71,8 +71,8 @@
          try
          {
             // call the request handlers
-            boolean handlersPass = callback.callRequestHandlerChain(HandlerType.ENDPOINT);
-            handlersPass = handlersPass && callback.callRequestHandlerChain(HandlerType.POST);
+            boolean handlersPass = callback.callRequestHandlerChain(wsInv, HandlerType.ENDPOINT);
+            handlersPass = handlersPass && callback.callRequestHandlerChain(wsInv, HandlerType.POST);
 
             // Call the next interceptor in the chain
             if (handlersPass)
@@ -90,8 +90,8 @@
             }
 
             // call the response handlers
-            handlersPass = callback.callResponseHandlerChain(HandlerType.POST);
-            handlersPass = handlersPass && callback.callResponseHandlerChain(HandlerType.ENDPOINT);
+            handlersPass = callback.callResponseHandlerChain(wsInv, HandlerType.POST);
+            handlersPass = handlersPass && callback.callResponseHandlerChain(wsInv, HandlerType.ENDPOINT);
 
             // update the return value after response handler processing
             Object resObj = wsInv.getReturnValue();
@@ -103,8 +103,8 @@
             try
             {
                // call the fault handlers
-               boolean handlersPass = callback.callFaultHandlerChain(HandlerType.POST, ex);
-               handlersPass = handlersPass && callback.callFaultHandlerChain(HandlerType.ENDPOINT, ex);
+               boolean handlersPass = callback.callFaultHandlerChain(wsInv, HandlerType.POST, ex);
+               handlersPass = handlersPass && callback.callFaultHandlerChain(wsInv, HandlerType.ENDPOINT, ex);
             }
             catch (Exception subEx)
             {

Modified: branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB21.java
===================================================================
--- branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB21.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/InvocationHandlerEJB21.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -125,40 +125,12 @@
    {
       log.debug("Invoke: " + inv.getJavaMethod().getName());
 
-      SecurityAdaptor securityAdaptor = SecurityAdaptorFactory.getSecurityAdaptor();
-      SecurityContext sc = SecurityContextAssociation.getSecurityContext();
-      Principal principal = securityAdaptor.getPrincipal();
-      Object credential = securityAdaptor.getCredential();
-
-      if (principal == null && sc != null)
-         principal = sc.getUtil().getUserPrincipal();
-
-      if (credential == null && sc != null)
-         credential = sc.getUtil().getCredential();
-
       // invoke on the container
       try
       {
          // setup the invocation
-         Method method = inv.getJavaMethod();
-         Object[] args = inv.getArgs();
-         org.jboss.invocation.Invocation jbInv = new org.jboss.invocation.Invocation(null, method, args, null, principal, credential);
+         org.jboss.invocation.Invocation jbInv = getMBeanInvocation(inv);
 
-         // EJB2.1 endpoints will only get an JAXRPC context 
-         MessageContext msgContext = inv.getInvocationContext().getAttachment(MessageContext.class);
-         if (msgContext == null)
-            throw new IllegalStateException("Cannot obtain MessageContext");
-
-         HandlerCallback callback = inv.getInvocationContext().getAttachment(HandlerCallback.class);
-         if (callback == null)
-            throw new IllegalStateException("Cannot obtain HandlerCallback");
-
-         jbInv.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
-         jbInv.setValue(InvocationKey.SOAP_MESSAGE, ((SOAPMessageContext)msgContext).getMessage());
-         jbInv.setType(InvocationType.SERVICE_ENDPOINT);
-         jbInv.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
-         jbInv.setValue(Invocation.class.getName(), inv, PayloadKey.TRANSIENT);
-
          String[] sig = { org.jboss.invocation.Invocation.class.getName() };
          Object retObj = server.invoke(objectName, "invoke", new Object[] { jbInv }, sig);
          inv.setReturnValue(retObj);
@@ -168,4 +140,39 @@
          handleInvocationException(e);
       }
    }
+
+   private org.jboss.invocation.Invocation getMBeanInvocation(Invocation inv)
+   {
+      // EJB2.1 endpoints will only get an JAXRPC context 
+      MessageContext msgContext = inv.getInvocationContext().getAttachment(MessageContext.class);
+      if (msgContext == null)
+         throw new IllegalStateException("Cannot obtain MessageContext");
+
+      SecurityAdaptor securityAdaptor = SecurityAdaptorFactory.getSecurityAdaptor();
+      SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+      Principal principal = securityAdaptor.getPrincipal();
+      Object credential = securityAdaptor.getCredential();
+
+      if (principal == null && sc != null)
+         principal = sc.getUtil().getUserPrincipal();
+
+      if (credential == null && sc != null)
+         credential = sc.getUtil().getCredential();
+      
+      Method method = inv.getJavaMethod();
+      Object[] args = inv.getArgs();
+      org.jboss.invocation.Invocation jbInv = new org.jboss.invocation.Invocation(null, method, args, null, principal, credential);
+      
+      HandlerCallback callback = inv.getInvocationContext().getAttachment(HandlerCallback.class);
+      if (callback == null)
+         throw new IllegalStateException("Cannot obtain HandlerCallback");
+      
+      jbInv.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
+      jbInv.setValue(InvocationKey.SOAP_MESSAGE, ((SOAPMessageContext)msgContext).getMessage());
+      jbInv.setType(InvocationType.SERVICE_ENDPOINT);
+      jbInv.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
+      jbInv.setValue(Invocation.class.getName(), inv, PayloadKey.TRANSIENT);
+      
+      return jbInv;
+   }
 }

Modified: branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/ServiceEndpointInterceptor.java
===================================================================
--- branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/ServiceEndpointInterceptor.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/ServiceEndpointInterceptor.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -71,8 +71,8 @@
          try
          {
             // call the request handlers
-            boolean handlersPass = callback.callRequestHandlerChain(HandlerType.ENDPOINT);
-            handlersPass = handlersPass && callback.callRequestHandlerChain(HandlerType.POST);
+            boolean handlersPass = callback.callRequestHandlerChain(wsInv, HandlerType.ENDPOINT);
+            handlersPass = handlersPass && callback.callRequestHandlerChain(wsInv, HandlerType.POST);
 
             // Call the next interceptor in the chain
             if (handlersPass)
@@ -90,8 +90,8 @@
             }
 
             // call the response handlers
-            handlersPass = callback.callResponseHandlerChain(HandlerType.POST);
-            handlersPass = handlersPass && callback.callResponseHandlerChain(HandlerType.ENDPOINT);
+            handlersPass = callback.callResponseHandlerChain(wsInv, HandlerType.POST);
+            handlersPass = handlersPass && callback.callResponseHandlerChain(wsInv, HandlerType.ENDPOINT);
 
             // update the return value after response handler processing
             Object resObj = wsInv.getReturnValue();
@@ -103,8 +103,8 @@
             try
             {
                // call the fault handlers
-               boolean handlersPass = callback.callFaultHandlerChain(HandlerType.POST, ex);
-               handlersPass = handlersPass && callback.callFaultHandlerChain(HandlerType.ENDPOINT, ex);
+               boolean handlersPass = callback.callFaultHandlerChain(wsInv, HandlerType.POST, ex);
+               handlersPass = handlersPass && callback.callFaultHandlerChain(wsInv, HandlerType.ENDPOINT, ex);
             }
             catch (Exception subEx)
             {

Modified: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/HandlerCallback.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/HandlerCallback.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/HandlerCallback.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -34,11 +34,11 @@
 public interface HandlerCallback
 {
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-   boolean callRequestHandlerChain(HandlerType type);
+   boolean callRequestHandlerChain(Invocation wsInv, HandlerType type);
 
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-   boolean callResponseHandlerChain(HandlerType type);
+   boolean callResponseHandlerChain(Invocation wsInv, HandlerType type);
 
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-   boolean callFaultHandlerChain(HandlerType type, Exception ex);
+   boolean callFaultHandlerChain(Invocation wsInv, HandlerType type, Exception ex);
 }
\ No newline at end of file

Added: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/DelegatingInvocation.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/DelegatingInvocation.java	                        (rev 0)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/DelegatingInvocation.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -0,0 +1,97 @@
+/*
+ * 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.core.server;
+
+// $Id$
+
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
+import javax.xml.soap.SOAPMessage;
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonBinding;
+import org.jboss.ws.core.CommonBindingProvider;
+import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.jaxrpc.binding.BindingException;
+import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.jboss.wsf.spi.invocation.BasicEndpointInvocation;
+
+/** An invocation that delegates to the jbossws-core EndpointInvocation
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class DelegatingInvocation extends BasicEndpointInvocation
+{
+   private EndpointInvocation getEndpointInvocation()
+   {
+      EndpointInvocation epInv = getInvocationContext().getAttachment(EndpointInvocation.class);
+      if (epInv == null)
+         throw new IllegalStateException("Cannot obtain endpoint invocation");
+      
+      return epInv;
+   }
+   
+   @Override
+   public void setReturnValue(Object value)
+   {
+      EndpointInvocation epInv = getEndpointInvocation();
+      epInv.setReturnValue(value);
+
+      SOAPMessageContext msgContext = (SOAPMessageContext)getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class);
+      if (msgContext != null && msgContext.getMessage() == null)
+      {
+         try
+         {
+            // Bind the response message
+            OperationMetaData opMetaData = epInv.getOperationMetaData();
+            CommonBindingProvider bindingProvider = new CommonBindingProvider(opMetaData.getEndpointMetaData());
+            CommonBinding binding = (CommonBinding)bindingProvider.getCommonBinding();
+            SOAPMessage resMessage = (SOAPMessage)binding.bindResponseMessage(opMetaData, epInv);
+            msgContext.setMessage(resMessage);
+         }
+         catch (BindingException ex)
+         {
+            WSException.rethrow(ex);
+         }
+      }
+   }
+
+   @Override
+   public Object[] getArgs()
+   {
+      EndpointInvocation epInv = getEndpointInvocation();
+      return epInv.getRequestPayload();
+   }
+
+   @Override
+   public Object getReturnValue()
+   {
+      EndpointInvocation epInv = getEndpointInvocation();
+      return epInv.getReturnValue();
+   }
+
+   @Override
+   public void setArgs(Object[] args)
+   {
+      throw new IllegalArgumentException("Cannot set args on this invocation");
+   }
+}


Property changes on: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/DelegatingInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -25,36 +25,30 @@
 
 import java.lang.reflect.Method;
 import java.util.HashMap;
-import java.util.Iterator;
 
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;
-import javax.xml.rpc.handler.soap.SOAPMessageContext;
 import javax.xml.rpc.server.ServiceLifecycle;
 import javax.xml.rpc.server.ServletEndpointContext;
 import javax.xml.rpc.soap.SOAPFaultException;
 import javax.xml.soap.Name;
-import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPBodyElement;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.http.HTTPBinding;
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.Constants;
-import org.jboss.ws.WSException;
 import org.jboss.ws.core.CommonBinding;
 import org.jboss.ws.core.CommonBindingProvider;
 import org.jboss.ws.core.CommonMessageContext;
 import org.jboss.ws.core.CommonSOAPBinding;
 import org.jboss.ws.core.DirectionHolder;
-import org.jboss.ws.core.MessageAbstraction;
 import org.jboss.ws.core.EndpointInvocation;
+import org.jboss.ws.core.MessageAbstraction;
 import org.jboss.ws.core.DirectionHolder.Direction;
 import org.jboss.ws.core.jaxrpc.ServletEndpointContextImpl;
-import org.jboss.ws.core.jaxrpc.binding.BindingException;
 import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
 import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
 import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
@@ -70,7 +64,6 @@
 import org.jboss.ws.metadata.umdm.OperationMetaData;
 import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
 import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.BasicEndpointInvocation;
 import org.jboss.wsf.spi.invocation.Invocation;
 import org.jboss.wsf.spi.invocation.InvocationContext;
 import org.jboss.wsf.spi.invocation.InvocationHandler;
@@ -207,6 +200,9 @@
                Invocation inv = setupInvocation(endpoint, sepInv, invContext);
                InvocationHandler invHandler = endpoint.getInvocationHandler();
                invHandler.invoke(endpoint, null, inv);
+               
+               // Handler processing might have replaced the endpoint invocation
+               sepInv = inv.getInvocationContext().getAttachment(EndpointInvocation.class);
             }
             finally
             {
@@ -279,7 +275,7 @@
       }
    }
 
-   protected Invocation setupInvocation(Endpoint ep, EndpointInvocation sepInv, InvocationContext invContext) throws Exception
+   protected Invocation setupInvocation(Endpoint ep, EndpointInvocation epInv, InvocationContext invContext) throws Exception
    {
       CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
       if (msgContext instanceof SOAPMessageContextJAXWS)
@@ -297,11 +293,13 @@
          invContext.addAttachment(ServletEndpointContext.class, servletEndpointContext);
       }
 
-      Invocation inv = new DelegatingInvocation(sepInv);
-      inv.setInvocationContext(invContext);
-      inv.setJavaMethod(getImplMethod(endpoint, sepInv));
+      invContext.addAttachment(EndpointInvocation.class, epInv);
+      
+      Invocation wsInv = new DelegatingInvocation();
+      wsInv.setInvocationContext(invContext);
+      wsInv.setJavaMethod(getImplMethod(endpoint, epInv));
 
-      return inv;
+      return wsInv;
    }
 
    protected Method getImplMethod(Endpoint endpoint, EndpointInvocation sepInv) throws ClassNotFoundException, NoSuchMethodException
@@ -397,7 +395,7 @@
          if (opMetaData == null)
          {
             String faultString;
-            
+
             SOAPBodyImpl soapBody = (SOAPBodyImpl)soapMessage.getSOAPBody();
             SOAPBodyElement soapBodyElement = soapBody.getBodyElement();
             if (soapBodyElement != null)
@@ -426,56 +424,4 @@
       }
       return opMetaData;
    }
-
-   class DelegatingInvocation extends BasicEndpointInvocation
-   {
-      private EndpointInvocation sepInv;
-
-      public DelegatingInvocation(EndpointInvocation sepInv)
-      {
-         this.sepInv = sepInv;
-      }
-
-      @Override
-      public void setReturnValue(Object value)
-      {
-         sepInv.setReturnValue(value);
-
-         SOAPMessageContext msgContext = (SOAPMessageContext)getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class);
-         if (msgContext != null && msgContext.getMessage() == null)
-         {
-            try
-            {
-               // Bind the response message
-               OperationMetaData opMetaData = sepInv.getOperationMetaData();
-               CommonBindingProvider bindingProvider = new CommonBindingProvider(opMetaData.getEndpointMetaData());
-               CommonBinding binding = (CommonBinding)bindingProvider.getCommonBinding();
-               SOAPMessage resMessage = (SOAPMessage)binding.bindResponseMessage(opMetaData, sepInv);
-               msgContext.setMessage(resMessage);
-            }
-            catch (BindingException ex)
-            {
-               WSException.rethrow(ex);
-            }
-         }
-      }
-
-      @Override
-      public Object[] getArgs()
-      {
-         return sepInv.getRequestPayload();
-      }
-
-      @Override
-      public Object getReturnValue()
-      {
-         return sepInv.getReturnValue();
-      }
-
-      @Override
-      public void setArgs(Object[] args)
-      {
-         throw new IllegalArgumentException("Cannot set args on this invocation");
-      }
-   }
 }

Modified: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java	2007-06-09 15:17:03 UTC (rev 3522)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java	2007-06-09 17:23:17 UTC (rev 3523)
@@ -23,11 +23,19 @@
 
 // $Id$
 
+import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+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.binding.BindingException;
+import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.metadata.umdm.OperationMetaData;
 import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
 import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.HandlerCallback;
 import org.jboss.wsf.spi.invocation.Invocation;
-import org.jboss.wsf.spi.invocation.HandlerCallback;
 import org.jboss.wsf.spi.invocation.InvocationContext;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
 
@@ -39,6 +47,9 @@
  */
 public class ServiceEndpointInvokerEJB21 extends ServiceEndpointInvoker
 {
+   // provide logging
+   private static final Logger log = Logger.getLogger(ServiceEndpointInvokerEJB21.class);
+   
    @Override
    protected Invocation setupInvocation(Endpoint ep, EndpointInvocation epInv, InvocationContext invContext) throws Exception
    {
@@ -89,15 +100,42 @@
       }
 
       /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-      public boolean callRequestHandlerChain(HandlerType type)
+      public boolean callRequestHandlerChain(Invocation wsInv, HandlerType type)
       {
-         if (type == HandlerType.PRE)
-            return true;
-         else return delegate.callRequestHandlerChain(sepMetaData, type);
+         boolean handlerPass = true;
+         if (type == HandlerType.ENDPOINT)
+         {
+            handlerPass = delegate.callRequestHandlerChain(sepMetaData, type);
+         }
+         else if (type == HandlerType.POST)
+         {
+            handlerPass = delegate.callRequestHandlerChain(sepMetaData, type);
+            
+            // Verify that the the message has not been mofified
+            CommonMessageContext messageContext = MessageContextAssociation.peekMessageContext();
+            if(handlerPass && messageContext.isModified())
+            {
+               try
+               {
+                  OperationMetaData opMetaData = messageContext.getOperationMetaData();
+                  CommonBindingProvider bindingProvider = new CommonBindingProvider(opMetaData.getEndpointMetaData());
+                  CommonBinding binding = bindingProvider.getCommonBinding();
+                  
+                  log.debug("Handler modified payload, unbind message and update invocation args");
+                  EndpointInvocation epInv = binding.unbindRequestMessage(opMetaData, messageContext.getMessageAbstraction());
+                  wsInv.getInvocationContext().addAttachment(EndpointInvocation.class, epInv);
+               }
+               catch (BindingException ex)
+               {
+                  throw new WSException(ex);
+               }
+            }
+         }
+         return handlerPass;
       }
 
       /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-      public boolean callResponseHandlerChain(HandlerType type)
+      public boolean callResponseHandlerChain(Invocation wsInv, HandlerType type)
       {
          if (type == HandlerType.PRE)
             return true;
@@ -105,7 +143,7 @@
       }
 
       /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
-      public boolean callFaultHandlerChain(HandlerType type, Exception ex)
+      public boolean callFaultHandlerChain(Invocation wsInv, HandlerType type, Exception ex)
       {
          if (type == HandlerType.PRE)
             return true;




More information about the jbossws-commits mailing list