geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r550865 - in /geronimo/server/trunk/modules/geronimo-axis2/src: main/java/org/apache/geronimo/axis2/ test/java/org/apache/geronimo/axis2/
Date Tue, 26 Jun 2007 17:19:33 GMT
Author: gawor
Date: Tue Jun 26 10:19:32 2007
New Revision: 550865

URL: http://svn.apache.org/viewvc?view=rev&rev=550865
Log:
updated handler processing

Modified:
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
    geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java
    geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java?view=diff&rev=550865&r1=550864&r2=550865
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AnnotationHandlerChainBuilder.java
Tue Jun 26 10:19:32 2007
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import javax.jws.HandlerChain;
+import javax.jws.WebService;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.LogicalHandler;
@@ -50,7 +51,7 @@
      */
     public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler>
existingHandlers) {
         log.debug("building handler chain");
-        HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz);
+        HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz, true);
         List<Handler> chain = null;
         if (hcAnn == null) {
             log.debug("no HandlerChain annotation on " + clz);
@@ -58,7 +59,6 @@
         } else {
             hcAnn.validate();
 
-            HandlerChainType hc = null;
             try {
                 URL handlerFileURL = clz.getResource(hcAnn.getFileName());
                 HandlerChainsType handlerChainsType = HandlerChainsDocument.Factory.parse(handlerFileURL).getHandlerChains();
@@ -66,15 +66,17 @@
                 if (null == handlerChainsType || handlerChainsType.getHandlerChainArray()
== null) {
                     throw new WebServiceException("Chain not specified");
                 }
-                //We expect only one HandlerChainType here
-                hc = handlerChainsType.getHandlerChainArray()[0];
+                
+                chain = new ArrayList<Handler>();
+                for (HandlerChainType hc : handlerChainsType.getHandlerChainArray()) {
+                    chain.addAll(buildHandlerChain(hc, clz.getClassLoader()));
+                }
+
             } catch (Exception e) {
-                log.debug(e.getMessage(), e);
                 throw new WebServiceException("Chain not specified", e);
             }
-
-            chain = buildHandlerChain(hc, clz.getClassLoader());
         }
+        
         assert chain != null;
         if (existingHandlers != null) {
             chain.addAll(existingHandlers);
@@ -86,30 +88,53 @@
         return buildHandlerChainFromClass(clz, null);
     }
 
-    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz) {
-
+    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean
searchSEI) {        
+        if (log.isDebugEnabled()) {
+            log.debug("Checking for HandlerChain annotation on " + clz.getName());
+        }
+        HandlerChainAnnotation hcAnn = null;
         HandlerChain ann = clz.getAnnotation(HandlerChain.class);
-        Class<?> declaringClass = clz;
-
         if (ann == null) {
-            for (Class<?> iface : clz.getInterfaces()) {
-                if (log.isDebugEnabled()) {
-                    log.debug("checking for HandlerChain annotation on " + iface.getName());
+            if (searchSEI) {
+                /* HandlerChain annotation can be specified on the SEI
+                 * but the implementation bean might not implement the SEI.          
+                 */
+                WebService ws = clz.getAnnotation(WebService.class);
+                if (ws != null 
+                    && ws.endpointInterface() != null 
+                    && ws.endpointInterface().trim().length() > 0) {
+                    String seiClassName = ws.endpointInterface().trim();
+                    Class seiClass = null;
+                    try {
+                        seiClass = clz.getClassLoader().loadClass(seiClassName);
+                    } catch (ClassNotFoundException e) {                       
+                        throw new WebServiceException("Failed to load SEI class: " + seiClassName,
e);
+                    }
+
+                    // check SEI class and its interfaces for HandlerChain annotation
+                    hcAnn = findHandlerChainAnnotation(seiClass, false);
                 }
-                ann = iface.getAnnotation(HandlerChain.class);
-                if (ann != null) {
-                    declaringClass = iface;
-                    break;
+            }
+            if (hcAnn == null) {
+                // check interfaces for HandlerChain annotation
+                for (Class<?> iface : clz.getInterfaces()) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Checking for HandlerChain annotation on " + iface.getName());
+                    }
+                    ann = iface.getAnnotation(HandlerChain.class);
+                    if (ann != null) {
+                        hcAnn = new HandlerChainAnnotation(ann, iface);
+                        break;
+                    }
                 }
             }
-        }
-        if (ann != null) {
-            return new HandlerChainAnnotation(ann, declaringClass);
         } else {
-            return null;
+            hcAnn = new HandlerChainAnnotation(ann, clz);
         }
+        
+        return hcAnn;
     }
-
+    
     protected List<Handler> buildHandlerChain(HandlerChainType hc, ClassLoader classLoader)
{
         List<Handler> handlerChain = new ArrayList<Handler>();
         for (PortComponentHandlerType ht : hc.getHandlerArray()) {

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java?view=diff&rev=550865&r1=550864&r2=550865
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/GeronimoHandlerChainBuilder.java
Tue Jun 26 10:19:32 2007
@@ -19,12 +19,14 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.xbeans.javaee.HandlerChainType;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.PortInfo;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -73,10 +75,23 @@
         if (binding == null) {
             return (bindings == null || bindings.isEmpty());
         } else {
-            return (bindings == null || bindings.isEmpty()) ? true : bindings.contains(binding);
+            if (bindings == null || bindings.isEmpty()) {
+                return true;
+            } else {
+                String actualBindingURI = JAXWSUtils.getBindingURI(binding);
+                Iterator iter = bindings.iterator();
+                while (iter.hasNext()) {
+                    String bindingToken = (String) iter.next();
+                    String bindingURI = JAXWSUtils.getBindingURI(bindingToken);
+                    if (actualBindingURI.equals(bindingURI)) {
+                        return true;
+                    }
+                }
+                return false;               
+            }
         }
     }
-
+    
     public List<Handler> buildHandlerChainFromConfiguration(HandlerChainType hc) {
         if (null == hc) {
             return null;

Modified: geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java?view=diff&rev=550865&r1=550864&r2=550865
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2HandlerResolverTest.java
Tue Jun 26 10:19:32 2007
@@ -88,7 +88,7 @@
         handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null)); 
         assertEquals(0, handlers.size());
         
-        handlers = resolver.getHandlerChain(new TestPortInfo("##FOO_BAR", null, null)); 
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP12_HTTP", null, null));

         assertEquals(0, handlers.size());
         
         handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));




Mime
View raw message