[jboss-svn-commits] JBossWS SVN: r734 - in branches/tdiesler/trunk/src: main/java/org/jboss/ws/addressing/jaxws main/java/org/jboss/ws/jaxws/handler main/java/org/jboss/ws/wsse/jaxws test/java/org/jboss/test/ws/addressing/action test/java/org/jboss/test/ws/jaxws/binding test/java/org/jboss/test/ws/jsr181/handlerchain test/java/org/jboss/test/ws/samples/wsaddressing

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Aug 13 07:10:27 EDT 2006


Author: thomas.diesler at jboss.com
Date: 2006-08-13 07:10:17 -0400 (Sun, 13 Aug 2006)
New Revision: 734

Modified:
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingClientHandler.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingServerHandler.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/HandlerResolverImpl.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/PortInfoImpl.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandler.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerInbound.java
   branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerOutbound.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientDocHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientRpcHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/AuthorizationHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/LogHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/RoutingHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/AddressingHandler.java
   branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/ServerHandler.java
Log:
handler scoping

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingClientHandler.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingClientHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingClientHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -21,10 +21,6 @@
  */
 package org.jboss.ws.addressing.jaxws;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.addressing.AddressingBuilder;
@@ -33,11 +29,11 @@
 import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
 import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.addressing.soap.SOAPAddressingPropertiesImpl;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A client side handler that reads/writes the addressing properties
@@ -46,7 +42,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 24-Nov-2005
  */
-public class WSAddressingClientHandler implements SOAPHandler
+public class WSAddressingClientHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(WSAddressingClientHandler.class);
@@ -62,29 +58,8 @@
       addrBuilder = AddressingBuilder.getAddressingBuilder();
    }
 
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
+   protected boolean handleOutbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   public boolean handleOutbound(MessageContext msgContext)
-   {
       log.debug("handleOutbound");
 
       SOAPAddressingProperties addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
@@ -109,14 +84,8 @@
       return true;
    }
 
-   /* supply the default addressing properties in case elements are missing */
-   private void normalizeRequest(MessageContext msgContext, SOAPAddressingProperties addrProps)
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      // TODO: supply default header
-   }
-
-   public boolean handleInbound(MessageContext msgContext)
-   {
       log.debug("handleInbound");
 
       try
@@ -137,16 +106,10 @@
 
       return true;
    }
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      // do nothing
-      return true;
-   }
    
-   public void close(MessageContext messagecontext)
+   /* supply the default addressing properties in case elements are missing */
+   private void normalizeRequest(MessageContext msgContext, SOAPAddressingProperties addrProps)
    {
-      // do nothing
+      // TODO: supply default header
    }
-
 }

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingServerHandler.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingServerHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/addressing/jaxws/WSAddressingServerHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -39,6 +39,7 @@
 import org.jboss.ws.addressing.AddressingConstantsImpl;
 import org.jboss.ws.addressing.metadata.AddressingOpMetaExt;
 import org.jboss.ws.common.SOAPMessageContextBase;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 import org.jboss.ws.metadata.OperationMetaData;
 
 /**
@@ -48,7 +49,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 24-Nov-2005
  */
-public class WSAddressingServerHandler implements SOAPHandler
+public class WSAddressingServerHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(WSAddressingServerHandler.class);
@@ -64,29 +65,8 @@
    // should the request be validated?
    private boolean validate = true;
 
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   private boolean handleInbound(MessageContext msgContext)
-   {
       log.debug("handleInbound");
 
       SOAPAddressingProperties addrProps = (SOAPAddressingProperties)ADDR_BUILDER.newAddressingProperties();
@@ -100,7 +80,7 @@
       return true;
    }
 
-   private boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       log.debug("handleOutbound");
       handleResponseOrFault(msgContext, false);
@@ -118,11 +98,6 @@
       return true;
    }
 
-   public void close(MessageContext messagecontext)
-   {
-      // nothig to do
-   }
-
    private void handleResponseOrFault(MessageContext msgContext, boolean isFault)
    {
       SOAPAddressingBuilder builder = (SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/HandlerResolverImpl.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/HandlerResolverImpl.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/HandlerResolverImpl.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -24,12 +24,18 @@
 // $Id$
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import javax.xml.namespace.QName;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.HandlerResolver;
 import javax.xml.ws.handler.PortInfo;
 
+import org.jboss.logging.Logger;
+
 /**
  * HandlerResolver is an interface implemented by an application to get control over 
  * the handler chain set on proxy/dispatch objects at the time of their creation.
@@ -44,11 +50,43 @@
  */
 public class HandlerResolverImpl implements HandlerResolver
 {
-   private List<Handler> handlerChain = new ArrayList<Handler>();
+   private static Logger log = Logger.getLogger(HandlerResolverImpl.class);
+   
+   private Map<QName, List<Handler>> serviceMap = new HashMap<QName, List<Handler>>();
+   private Map<QName, List<Handler>> portMap = new HashMap<QName, List<Handler>>();
+   private Map<String, List<Handler>> bindingMap = new HashMap<String, List<Handler>>();
 
-   public List<Handler> getHandlerChain(PortInfo portinfo)
+   public List<Handler> getHandlerChain(PortInfo info)
    {
-      return handlerChain;
+      List<Handler> handlerChain = new ArrayList<Handler>();
+      
+      QName serviceName = info.getServiceName();
+      QName portName = info.getPortName();
+      String bindingID = info.getBindingID();
+      
+      handlerChain.addAll(serviceMap.get(serviceName));
+      handlerChain.addAll(portMap.get(portName));
+      handlerChain.addAll(bindingMap.get(bindingID));
+      
+      return Collections.unmodifiableList(handlerChain);
    }
 
+   public boolean addHandler(Handler handler)
+   {
+      return addHandler(new PortInfoImpl(), handler);
+   }
+   
+   public boolean addHandler(PortInfo info, Handler handler)
+   {
+      log.debug("addHandler: " + info + ":" + handler.getClass().getName());
+      
+      QName serviceName = info.getServiceName();
+      QName portName = info.getPortName();
+      String bindingID = info.getBindingID();
+      
+      serviceMap.get(serviceName).add(handler);
+      portMap.get(portName).add(handler);
+      bindingMap.get(bindingID).add(handler);
+      return true;
+   }
 }

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/PortInfoImpl.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/PortInfoImpl.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/jaxws/handler/PortInfoImpl.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -39,6 +39,10 @@
    private QName portName;
    private String bindingID;
    
+   public PortInfoImpl()
+   {
+   }
+
    public PortInfoImpl(EndpointMetaData epMetaData)
    {
       this.serviceName = epMetaData.getServiceMetaData().getQName();
@@ -67,4 +71,20 @@
    {
       return serviceName;
    }
+   
+   public int hashCode()
+   {
+      return toString().hashCode();
+   }
+   
+   public boolean equals(Object obj)
+   {
+      if (!(obj instanceof PortInfoImpl)) return false;
+      return (obj != null ? toString().equals(obj.toString()) : false);
+   }
+   
+   public String toString()
+   {
+      return "[service=" + serviceName + ",port=" + portName + ",binding=" + bindingID + "]";
+   }
 }
\ No newline at end of file

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandler.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -23,16 +23,12 @@
 
 // $Id$
 
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
 import javax.xml.soap.SOAPException;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 
 import org.jboss.logging.Logger;
 import org.jboss.ws.common.SOAPMessageContextBase;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 import org.jboss.ws.metadata.EndpointMetaData;
 import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
 import org.jboss.ws.wsse.WSSecurityDispatcher;
@@ -43,19 +39,11 @@
  * @author Thomas.Diesler at jboss.org
  * @since 12-Nov-2005
  */
-public abstract class WSSecurityHandler implements SOAPHandler
+public abstract class WSSecurityHandler extends GenericSOAPHandler
 {
    // provide logging
    private static Logger log = Logger.getLogger(WSSecurityHandler.class);
    
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
-   {
-      return new HashSet<QName>();
-   }
-
    protected boolean handleInboundSecurity(MessageContext msgContext)
    {
       try
@@ -99,13 +87,4 @@
       
       return securityConfiguration;
    }
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      return true;
-   }
-   
-   public void close(MessageContext messagecontext)
-   {
-   }
 }

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerInbound.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerInbound.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerInbound.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -34,22 +34,12 @@
  */
 public class WSSecurityHandlerInbound extends WSSecurityHandler
 {
-
-   public boolean handleMessage(MessageContext msgContext)
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   private boolean handleInbound(MessageContext msgContext)
-   {
       return handleInboundSecurity(msgContext);
    }
 
-   private boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       return handleOutboundSecurity(msgContext);
    }

Modified: branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerOutbound.java
===================================================================
--- branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerOutbound.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/main/java/org/jboss/ws/wsse/jaxws/WSSecurityHandlerOutbound.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -33,22 +33,12 @@
  */
 public class WSSecurityHandlerOutbound extends WSSecurityHandler
 {
-
-   public boolean handleMessage(MessageContext msgContext)
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   public boolean handleInbound(MessageContext msgContext)
-   {
       return handleOutboundSecurity(msgContext);
    }
 
-   public boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       return handleInboundSecurity(msgContext);
    }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientDocHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientDocHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientDocHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -22,17 +22,14 @@
 package org.jboss.test.ws.addressing.action;
 
 import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
 
-import javax.xml.namespace.QName;
 import javax.xml.ws.addressing.AddressingBuilder;
 import javax.xml.ws.addressing.AddressingProperties;
 import javax.xml.ws.addressing.JAXWSAConstants;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 
 import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A client side handler for the ws-addressing
@@ -40,35 +37,14 @@
  * @author Thomas.Diesler at jboss.org
  * @since 29-Nov-2005
  */
-public class ClientDocHandler implements SOAPHandler
+public class ClientDocHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(ClientDocHandler.class);
    
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
+   protected boolean handleOutbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : true;
-   }
-
-   private boolean handleOutbound(MessageContext msgContext)
-   {
-      log.info("handleRequest" + this);
+      log.info("handleOutbound: " + this);
       try
       {
          AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
@@ -79,19 +55,9 @@
       }
       catch (URISyntaxException ex)
       {
-         throw new IllegalStateException("Cannot handle request", ex);
+         throw new IllegalStateException("Cannot handle outbound msg", ex);
       }
       return true;
    }
 
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      // do nothing
-      return true;
-   }
-   
-   public void close(MessageContext messagecontext)
-   {
-      // do nothing
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientRpcHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientRpcHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/addressing/action/ClientRpcHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -22,17 +22,14 @@
 package org.jboss.test.ws.addressing.action;
 
 import java.net.URISyntaxException;
-import java.util.HashSet;
-import java.util.Set;
 
-import javax.xml.namespace.QName;
 import javax.xml.ws.addressing.AddressingBuilder;
 import javax.xml.ws.addressing.AddressingProperties;
 import javax.xml.ws.addressing.JAXWSAConstants;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 
 import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A client side handler for the ws-addressing
@@ -40,35 +37,14 @@
  * @author Thomas.Diesler at jboss.org
  * @since 29-Nov-2005
  */
-public class ClientRpcHandler implements SOAPHandler
+public class ClientRpcHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(ClientRpcHandler.class);
    
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
+   protected boolean handleOutbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : true;
-   }
-
-   private boolean handleOutbound(MessageContext msgContext)
-   {
-      log.info("handleRequest" + this);
+      log.info("handleOutbound: " + this);
       try
       {
          AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
@@ -79,19 +55,8 @@
       }
       catch (URISyntaxException ex)
       {
-         throw new IllegalStateException("Cannot handle request", ex);
+         throw new IllegalStateException("Cannot handle outbound msg", ex);
       }
       return true;
    }
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      // do nothing
-      return true;
-   }
-   
-   public void close(MessageContext messagecontext)
-   {
-      // do nothing
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jaxws/binding/ClientHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -35,6 +35,7 @@
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
 import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A client side handler for the ws-addressing
@@ -42,33 +43,8 @@
  * @author Thomas.Diesler at jboss.org
  * @since 24-Nov-2005
  */
-public class ClientHandler implements SOAPHandler
+public class ClientHandler extends GenericSOAPHandler
 {
-   // Provide logging
-   private static Logger log = Logger.getLogger(ClientHandler.class);
-
-   /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
-   {
-      return new HashSet<QName>();
-   }
-
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   public boolean handleOutbound(MessageContext msgContext)
-   {
-      return true;
-   }
-
    public boolean handleInbound(MessageContext msgContext)
    {
       try
@@ -89,13 +65,4 @@
          throw new WebServiceException(ex);
       }
    }
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      return true;
-   }
-
-   public void close(MessageContext messagecontext)
-   {
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/AuthorizationHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/AuthorizationHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/AuthorizationHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -21,12 +21,6 @@
   */
 package org.jboss.test.ws.jsr181.handlerchain;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.logging.Logger;
-
-import javax.xml.namespace.QName;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPBodyElement;
@@ -38,37 +32,24 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
+import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
+
 /**
  * A server side handler
  *
  * @author Thomas.Diesler at jboss.org
  * @since 08-Oct-2005
  */
-public class AuthorizationHandler implements SOAPHandler
+public class AuthorizationHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(AuthorizationHandler.class);
 
-   public Set<QName> getHeaders()
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-   
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-   
-
-   private boolean handleInbound(MessageContext msgContext)
-   {
       log.info("handleInbound");
 
       try
@@ -95,7 +76,7 @@
       return true;
    }
 
-   private boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       log.info("handleOutbound");
 
@@ -122,13 +103,4 @@
 
       return true;
    }
-
-   public boolean handleFault(MessageContext context)
-   {
-      return true;
-   }
-
-   public void close(MessageContext context)
-   {
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/LogHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/LogHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/LogHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -21,10 +21,6 @@
   */
 package org.jboss.test.ws.jsr181.handlerchain;
 
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPBodyElement;
@@ -36,10 +32,10 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
 import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A server side handler
@@ -47,27 +43,13 @@
  * @author Thomas.Diesler at jboss.org
  * @since 08-Oct-2005
  */
-public class LogHandler implements SOAPHandler
+public class LogHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(LogHandler.class);
 
-   public Set<QName> getHeaders()
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-   
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-   
-   private boolean handleInbound(MessageContext msgContext)
-   {
       log.info("handleInbound");
 
       try
@@ -94,7 +76,7 @@
       return true;
    }
 
-   private boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       log.info("handleOutbound");
 
@@ -121,13 +103,4 @@
 
       return true;
    }
-
-   public boolean handleFault(MessageContext context)
-   {
-      return true;
-   }
-
-   public void close(MessageContext context)
-   {
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/RoutingHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/RoutingHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/jsr181/handlerchain/RoutingHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -24,8 +24,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.jboss.logging.Logger;
-
 import javax.xml.namespace.QName;
 import javax.xml.soap.Name;
 import javax.xml.soap.SOAPBody;
@@ -38,37 +36,24 @@
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
+import org.jboss.logging.Logger;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
+
 /**
  * A server side handler
  *
  * @author Thomas.Diesler at jboss.org
  * @since 08-Oct-2005
  */
-public class RoutingHandler implements SOAPHandler
+public class RoutingHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(RoutingHandler.class);
 
-   public Set<QName> getHeaders()
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      return new HashSet<QName>();
-   }
-   
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-   
-
-   private boolean handleInbound(MessageContext msgContext)
-   {
       log.info("handleInbound");
 
       try
@@ -95,7 +80,7 @@
       return true;
    }
 
-   private boolean handleOutbound(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
       log.info("handleOutbound");
 
@@ -122,13 +107,4 @@
 
       return true;
    }
-
-   public boolean handleFault(MessageContext context)
-   {
-      return true;
-   }
-
-   public void close(MessageContext context)
-   {
-   }
 }

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/AddressingHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/AddressingHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/AddressingHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -21,57 +21,18 @@
  */
 package org.jboss.test.ws.samples.wsaddressing;
 
-import java.util.HashSet;
-import java.util.Set;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
-import javax.xml.namespace.QName;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 
-
 /**
  * An abstract handler for the ws-addressing
  *
  * @author Thomas.Diesler at jboss.org
  * @since 29-Nov-2005
  */
-public abstract class AddressingHandler implements SOAPHandler
+public abstract class AddressingHandler extends GenericSOAPHandler
 {
    /**
-    * Gets the header blocks that can be processed by this Handler instance.
-    */
-   public Set<QName> getHeaders()
-   {
-      return new HashSet<QName>();
-   }
-
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
-   {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-
-      return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
-   }
-
-   public abstract boolean handleOutbound(MessageContext msgContext);
-
-   public abstract boolean handleInbound(MessageContext msgContext);
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      return true;
-   }
-
-   public void close(MessageContext messagecontext)
-   {
-   }
-
-   /**
     * Get the JBoss server host from system property "jbosstest.server.host"
     * This defaults to "" + getServerHost() + ""
     */

Modified: branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/ServerHandler.java
===================================================================
--- branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/ServerHandler.java	2006-08-13 11:09:42 UTC (rev 733)
+++ branches/tdiesler/trunk/src/test/java/org/jboss/test/ws/samples/wsaddressing/ServerHandler.java	2006-08-13 11:10:17 UTC (rev 734)
@@ -33,10 +33,10 @@
 import javax.xml.ws.addressing.JAXWSAConstants;
 import javax.xml.ws.addressing.ReferenceParameters;
 import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.soap.SOAPHandler;
 
 import org.jboss.logging.Logger;
 import org.jboss.util.xml.DOMUtils;
+import org.jboss.ws.jaxws.handler.GenericSOAPHandler;
 
 /**
  * A server side handler for the ws-addressing
@@ -44,7 +44,7 @@
  * @author Thomas.Diesler at jboss.org
  * @since 24-Nov-2005
  */
-public class ServerHandler implements SOAPHandler
+public class ServerHandler extends GenericSOAPHandler
 {
    // Provide logging
    private static Logger log = Logger.getLogger(ServerHandler.class);
@@ -59,23 +59,10 @@
       return new HashSet<QName>();
    }
 
-   /**
-    * Read the addressing headers from the incomming message and put a
-    * SOAPAddressingProperties object into the message context
-    */
-   public boolean handleMessage(MessageContext msgContext)
+   protected boolean handleInbound(MessageContext msgContext)
    {
-      Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
-      if (outbound == null)
-         throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+      log.info("handleInbound");
 
-      return outbound ? handleResponse(msgContext) : handleRequest(msgContext);
-   }
-
-   private boolean handleRequest(MessageContext msgContext)
-   {
-      log.info("handleRequest");
-
       AddressingProperties addrProps = (AddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
       if (addrProps == null)
          throw new IllegalStateException("Cannot obtain AddressingProperties");
@@ -104,9 +91,9 @@
       return true;
    }
 
-   private boolean handleResponse(MessageContext msgContext)
+   protected boolean handleOutbound(MessageContext msgContext)
    {
-      log.info("handleResponse");
+      log.info("handleOutbound");
 
       try
       {
@@ -127,13 +114,4 @@
 
       return true;
    }
-
-   public boolean handleFault(MessageContext messagecontext)
-   {
-      return true;
-   }
-
-   public void close(MessageContext messagecontext)
-   {
-   }
 }




More information about the jboss-svn-commits mailing list