[jboss-svn-commits] JBossWS SVN: r697 - in trunk/src/main/java/org/jboss/ws: integration/jboss jaxrpc jaxws metadata metadata/j2ee server

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 7 04:44:51 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-08-07 04:44:39 -0400 (Mon, 07 Aug 2006)
New Revision: 697

Modified:
   trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInterceptor.java
   trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInvokerEJB21.java
   trunk/src/main/java/org/jboss/ws/jaxrpc/HandlerDelegateJAXRPC.java
   trunk/src/main/java/org/jboss/ws/jaxws/HandlerDelegateJAXWS.java
   trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
   trunk/src/main/java/org/jboss/ws/metadata/j2ee/UnifiedHandlerMetaData.java
   trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java
Log:
Simplify HandlerType
Fix UsernametestCase
ALL GOOD


Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInterceptor.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInterceptor.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInterceptor.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -77,7 +77,7 @@
          try
          {
             // call the request handlers
-            boolean handlersPass = callback.callRequestHandlerChain(HandlerType.JAXRPC);
+            boolean handlersPass = callback.callRequestHandlerChain(HandlerType.ENDPOINT);
             handlersPass = handlersPass && callback.callRequestHandlerChain(HandlerType.POST);
 
             // Call the next interceptor in the chain
@@ -99,7 +99,7 @@
             
             // call the response handlers
             handlersPass = callback.callResponseHandlerChain(HandlerType.POST);
-            handlersPass = handlersPass && callback.callResponseHandlerChain(HandlerType.JAXRPC);
+            handlersPass = handlersPass && callback.callResponseHandlerChain(HandlerType.ENDPOINT);
             
             // update the return value after response handler processing
             Object resObj = epInv.getReturnValue();
@@ -110,7 +110,7 @@
          {
             // call the fault handlers
             boolean handlersPass = callback.callFaultHandlerChain(HandlerType.POST, ex);
-            handlersPass = handlersPass && callback.callFaultHandlerChain(HandlerType.JAXRPC, ex);
+            handlersPass = handlersPass && callback.callFaultHandlerChain(HandlerType.ENDPOINT, ex);
             
             throw ex;
          }

Modified: trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInvokerEJB21.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInvokerEJB21.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss/ServiceEndpointInvokerEJB21.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -199,19 +199,28 @@
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
    public boolean callRequestHandlerChain(ServiceEndpointInfo seInfo, HandlerType type)
    {
-      return true;
+      if (type == HandlerType.PRE)
+         return handlerDelegate.callRequestHandlerChain(seInfo, type);
+      else
+         return true;
    }
 
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
    public boolean callResponseHandlerChain(ServiceEndpointInfo seInfo, HandlerType type)
    {
-      return true;
+      if (type == HandlerType.PRE)
+         return handlerDelegate.callResponseHandlerChain(seInfo, type);
+      else
+         return true;
    }
    
    /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
    public boolean callFaultHandlerChain(ServiceEndpointInfo seInfo, HandlerType type, Exception ex)
    {
-      return true;
+      if (type == HandlerType.PRE)
+         return handlerDelegate.callFaultHandlerChain(seInfo, type, ex);
+      else
+         return true;
    }
    
    // The ServiceEndpointInterceptor calls the methods in this callback
@@ -224,19 +233,32 @@
          this.seInfo = seInfo;
       }
 
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
       public boolean callRequestHandlerChain(HandlerType type)
       {
-         return handlerDelegate.callRequestHandlerChain(seInfo, type);
+         if (type != HandlerType.PRE)
+            return handlerDelegate.callRequestHandlerChain(seInfo, type);
+         else
+            return true;
       }
 
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
       public boolean callResponseHandlerChain(HandlerType type)
       {
-         return handlerDelegate.callResponseHandlerChain(seInfo, type);
+         if (type != HandlerType.PRE)
+            return handlerDelegate.callResponseHandlerChain(seInfo, type);
+         else
+            return true;
       }
-
+      
+      /** Handlers are beeing called through the HandlerCallback from the EJB interceptor */
       public boolean callFaultHandlerChain(HandlerType type, Exception ex)
       {
-         return handlerDelegate.callFaultHandlerChain(seInfo, type, ex);
+         if (type != HandlerType.PRE)
+            return handlerDelegate.callFaultHandlerChain(seInfo, type, ex);
+         else
+            return true;
       }
+      
    }
 }

Modified: trunk/src/main/java/org/jboss/ws/jaxrpc/HandlerDelegateJAXRPC.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxrpc/HandlerDelegateJAXRPC.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/jaxrpc/HandlerDelegateJAXRPC.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -77,7 +77,7 @@
       if (sepMetaData.isHandlersInitialized() == false)
       {
          initHandlerChain(seInfo, HandlerType.PRE);
-         initHandlerChain(seInfo, HandlerType.JAXRPC);
+         initHandlerChain(seInfo, HandlerType.ENDPOINT);
          initHandlerChain(seInfo, HandlerType.POST);
          sepMetaData.setHandlersInitialized(true);
       }
@@ -88,7 +88,7 @@
       HandlerChain handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXRPC)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxrpcHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -113,7 +113,7 @@
       HandlerChain handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXRPC)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxrpcHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -128,7 +128,7 @@
       HandlerChain handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXRPC)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxrpcHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -186,7 +186,7 @@
       ServerHandlerChain handlerChain = new ServerHandlerChain(hInfos, handlerRoles, type);
       if (type == HandlerType.PRE)
          preHandlerChain = handlerChain;
-      else if (type == HandlerType.JAXRPC)
+      else if (type == HandlerType.ENDPOINT)
          jaxrpcHandlerChain = handlerChain;
       else if (type == HandlerType.POST)
          postHandlerChain = handlerChain;

Modified: trunk/src/main/java/org/jboss/ws/jaxws/HandlerDelegateJAXWS.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/HandlerDelegateJAXWS.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/jaxws/HandlerDelegateJAXWS.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -124,7 +124,7 @@
       if (sepMetaData.isHandlersInitialized() == false)
       {
          initHandlerChain(seInfo, HandlerType.PRE);
-         initHandlerChain(seInfo, HandlerType.JAXWS);
+         initHandlerChain(seInfo, HandlerType.ENDPOINT);
          initHandlerChain(seInfo, HandlerType.POST);
          sepMetaData.setHandlersInitialized(true);
       }
@@ -135,7 +135,7 @@
       HandlerChainBaseImpl handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXWS)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxwsHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -160,7 +160,7 @@
       HandlerChainBaseImpl handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXWS)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxwsHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -175,7 +175,7 @@
       HandlerChainBaseImpl handlerChain = null;
       if (type == HandlerType.PRE)
          handlerChain = preHandlerChain;
-      else if (type == HandlerType.JAXWS)
+      else if (type == HandlerType.ENDPOINT)
          handlerChain = jaxwsHandlerChain;
       else if (type == HandlerType.POST)
          handlerChain = postHandlerChain;
@@ -232,7 +232,7 @@
       ServerHandlerChain handlerChain = new ServerHandlerChain(hInfos, handlerRoles, type);
       if (type == HandlerType.PRE)
          preHandlerChain = handlerChain;
-      else if (type == HandlerType.JAXWS)
+      else if (type == HandlerType.ENDPOINT)
          jaxwsHandlerChain = handlerChain;
       else if (type == HandlerType.POST)
          postHandlerChain = handlerChain;

Modified: trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/metadata/ClientEndpointMetaData.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -94,7 +94,7 @@
          }
 
          // Add endpoint handlers
-         if (type == HandlerType.JAXRPC || type == HandlerType.ALL)
+         if (type == HandlerType.ENDPOINT || type == HandlerType.ALL)
          {
             handlers.addAll(super.getHandlers(type));
          }
@@ -129,7 +129,7 @@
          }
 
          // Add endpoint handlers
-         if (type == HandlerType.JAXWS || type == HandlerType.ALL)
+         if (type == HandlerType.ENDPOINT || type == HandlerType.ALL)
          {
             handlers.addAll(super.getHandlers(type));
          }

Modified: trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/metadata/ServerEndpointMetaData.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -188,7 +188,7 @@
          }
 
          // Add endpoint handlers
-         if (type == HandlerType.JAXRPC || type == HandlerType.ALL)
+         if (type == HandlerType.ENDPOINT || type == HandlerType.ALL)
          {
             handlers.addAll(super.getHandlers(type));
          }
@@ -223,7 +223,7 @@
          }
 
          // Add endpoint handlers
-         if (type == HandlerType.JAXWS || type == HandlerType.ALL)
+         if (type == HandlerType.ENDPOINT || type == HandlerType.ALL)
          {
             handlers.addAll(super.getHandlers(type));
          }

Modified: trunk/src/main/java/org/jboss/ws/metadata/j2ee/UnifiedHandlerMetaData.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/metadata/j2ee/UnifiedHandlerMetaData.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/metadata/j2ee/UnifiedHandlerMetaData.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -38,7 +38,7 @@
 {
    private static final long serialVersionUID = 8000854586742278995L;
 
-   public enum HandlerType {PRE, JAXRPC, JAXWS, POST, ALL};
+   public enum HandlerType {PRE, ENDPOINT, POST, ALL};
    
    // The required <handler-name> element
    private String handlerName;

Modified: trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java	2006-08-04 20:41:06 UTC (rev 696)
+++ trunk/src/main/java/org/jboss/ws/server/AbstractServiceEndpointInvoker.java	2006-08-07 08:44:39 UTC (rev 697)
@@ -49,6 +49,7 @@
 import org.jboss.ws.jaxws.HandlerDelegateJAXWS;
 import org.jboss.ws.metadata.EndpointMetaData;
 import org.jboss.ws.metadata.OperationMetaData;
+import org.jboss.ws.metadata.ServerEndpointMetaData;
 import org.jboss.ws.metadata.EndpointMetaData.Type;
 import org.jboss.ws.metadata.j2ee.UnifiedHandlerMetaData.HandlerType;
 import org.jboss.ws.soap.MessageContextAssociation;
@@ -60,14 +61,13 @@
  * @author Thomas.Diesler at jboss.org
  * @since 19-Jan-2005
  */
-public abstract class AbstractServiceEndpointInvoker implements ServiceEndpointInvoker, HandlerDelegate 
+public abstract class AbstractServiceEndpointInvoker implements ServiceEndpointInvoker, HandlerDelegate
 {
    // provide logging
    private static Logger log = Logger.getLogger(AbstractServiceEndpointInvoker.class);
-   
+
    protected HandlerDelegate handlerDelegate;
-   private HandlerType handlerType;
-   
+
    /** Initialize the service endpoint */
    public void initServiceEndpoint(ServiceEndpointInfo seInfo)
    {
@@ -75,12 +75,10 @@
       if (type == EndpointMetaData.Type.JAXRPC)
       {
          handlerDelegate = new HandlerDelegateJAXRPC();
-         handlerType = HandlerType.JAXRPC;
       }
       else
       {
          handlerDelegate = new HandlerDelegateJAXWS();
-         handlerType = HandlerType.JAXWS;
       }
    }
 
@@ -88,7 +86,8 @@
    protected abstract Class loadServiceEndpoint(ServiceEndpointInfo seInfo) throws ClassNotFoundException;
 
    /** Create the instance of the SEI implementation bean if necessary */
-   protected abstract Object createServiceEndpoint(ServiceEndpointInfo seInfo, Object context, Class seiImplClass) throws IllegalAccessException, InstantiationException;
+   protected abstract Object createServiceEndpoint(ServiceEndpointInfo seInfo, Object context, Class seiImplClass) throws IllegalAccessException,
+         InstantiationException;
 
    /** Invoke the instance of the SEI implementation bean */
    protected abstract void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl, EndpointInvocation epInv);
@@ -105,16 +104,108 @@
    {
       return handlerDelegate.callResponseHandlerChain(seInfo, type);
    }
-   
+
    public boolean callFaultHandlerChain(ServiceEndpointInfo seInfo, HandlerType type, Exception ex)
    {
       return handlerDelegate.callFaultHandlerChain(seInfo, type, ex);
    }
-   
+
    /** Invoke the the service endpoint */
    public SOAPMessage invoke(ServiceEndpointInfo seInfo, Object context) throws Exception
    {
+      ServerEndpointMetaData epMetaData = seInfo.getServerEndpointMetaData();
+      if (epMetaData.getType() == EndpointMetaData.Type.JAXRPC)
+      {
+         return invokeJAXRPC(seInfo, context);
+      }
+      else
+      {
+         return invokeJAXWS(seInfo, context);
+      }
+   }
+
+   /** Invoke a JAXRPC service endpoint */
+   private SOAPMessage invokeJAXRPC(ServiceEndpointInfo seInfo, Object context) throws Exception
+   {
       SOAPMessageContextBase msgContext = MessageContextAssociation.peekMessageContext();
+      ServerEndpointMetaData epMetaData = seInfo.getServerEndpointMetaData();
+      SOAPMessageImpl reqMessage = (SOAPMessageImpl)msgContext.getMessage();
+
+      // Load the endpoint implementation bean
+      Class seImpl = loadServiceEndpoint(seInfo);
+
+      // Create an instance of the endpoint implementation bean
+      Object seInstance = createServiceEndpoint(seInfo, context, seImpl);
+
+      try
+      {
+         boolean oneway = false;
+
+         // call the handler chain
+         boolean handlersPass = callRequestHandlerChain(seInfo, HandlerType.PRE);
+         handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.ENDPOINT);
+         handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.POST);
+
+         if (handlersPass)
+         {
+            // Get the binding provider for the given bindingURI
+            BindingProvider bindingProvider = BindingProviderRegistry.getDefaultProvider();
+
+            // Get the operation meta data from the SOAP message
+            OperationMetaData opMetaData = getDispatchDestination(epMetaData, reqMessage);
+            msgContext.setOperationMetaData(opMetaData);
+            oneway = opMetaData.isOneWayOperation();
+
+            // Unbind the request message
+            EndpointInvocation epInv = bindingProvider.unbindRequestMessage(opMetaData, reqMessage);
+
+            // Invoke the service endpoint
+            invokeServiceEndpoint(seInfo, seInstance, epInv);
+
+            // Bind the response message
+            SOAPMessage resMessage = bindingProvider.bindResponseMessage(opMetaData, epInv);
+            msgContext.setMessage(resMessage);
+         }
+
+         // call the handler chain
+         if (oneway == false)
+         {
+            handlersPass = callResponseHandlerChain(seInfo, HandlerType.POST);
+            handlersPass = handlersPass && callResponseHandlerChain(seInfo, HandlerType.ENDPOINT);
+            handlersPass = handlersPass && callResponseHandlerChain(seInfo, HandlerType.PRE);
+         }
+
+         SOAPMessage resMessage = msgContext.getMessage();
+         return resMessage;
+      }
+      catch (Exception ex)
+      {
+         try
+         {
+            SOAPMessage faultMessage = SOAPFaultExceptionHelper.exceptionToFaultMessage(ex);
+            msgContext.setMessage(faultMessage);
+
+            // call the handler chain
+            boolean handlersPass = handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.POST, ex);
+            handlersPass = handlersPass && handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.ENDPOINT, ex);
+            handlersPass = handlersPass && handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.PRE, ex);
+         }
+         catch (Exception subEx)
+         {
+            log.warn("Cannot process handlerChain.handleFault, ignoring: ", subEx);
+         }
+         throw ex;
+      }
+      finally
+      {
+         destroyServiceEndpoint(seInfo, seInstance);
+      }
+   }
+
+   /** Invoke a JAXWS service endpoint */
+   private SOAPMessage invokeJAXWS(ServiceEndpointInfo seInfo, Object context) throws Exception
+   {
+      SOAPMessageContextBase msgContext = MessageContextAssociation.peekMessageContext();
       EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
       SOAPMessageImpl reqMessage = (SOAPMessageImpl)msgContext.getMessage();
 
@@ -130,9 +221,9 @@
 
          // call the handler chain
          boolean handlersPass = callRequestHandlerChain(seInfo, HandlerType.PRE);
-         handlersPass = handlersPass && callRequestHandlerChain(seInfo, handlerType);
+         handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.ENDPOINT);
          handlersPass = handlersPass && callRequestHandlerChain(seInfo, HandlerType.POST);
-         
+
          if (handlersPass)
          {
             // Get the binding provider for the given bindingURI
@@ -160,10 +251,9 @@
 
             // Invoke the service endpoint
             invokeServiceEndpoint(seInfo, seInstance, epInv);
-            
+
             // Set the outbound property
-            if (epMetaData.getType() == EndpointMetaData.Type.JAXWS)
-               msgContext.setProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY, new Boolean(true));
+            msgContext.setProperty(MessageContext.MESSAGE_OUTBOUND_PROPERTY, new Boolean(true));
 
             // Bind the response message
             SOAPMessage resMessage = bindingProvider.bindResponseMessage(opMetaData, epInv);
@@ -174,7 +264,7 @@
          if (oneway == false)
          {
             handlersPass = callResponseHandlerChain(seInfo, HandlerType.POST);
-            handlersPass = handlersPass && callResponseHandlerChain(seInfo, handlerType);
+            handlersPass = handlersPass && callResponseHandlerChain(seInfo, HandlerType.ENDPOINT);
             handlersPass = handlersPass && callResponseHandlerChain(seInfo, HandlerType.PRE);
          }
 
@@ -187,10 +277,10 @@
          {
             SOAPMessage faultMessage = SOAPFaultExceptionHelper.exceptionToFaultMessage(ex);
             msgContext.setMessage(faultMessage);
-            
+
             // call the handler chain
             boolean handlersPass = handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.POST, ex);
-            handlersPass = handlersPass && handlerDelegate.callFaultHandlerChain(seInfo, handlerType, ex);
+            handlersPass = handlersPass && handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.ENDPOINT, ex);
             handlersPass = handlersPass && handlerDelegate.callFaultHandlerChain(seInfo, HandlerType.PRE, ex);
          }
          catch (Exception subEx)
@@ -253,7 +343,7 @@
       Method implMethod = implClass.getMethod(methodName, paramTypes);
       return implMethod;
    }
-   
+
    /** handle invokation exceptions */
    public void handleInvocationException(Throwable th) throws SOAPFaultException
    {




More information about the jboss-svn-commits mailing list