cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r534170 - in /incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler: AnnotationHandlerChainBuilder.java Messages.properties
Date Tue, 01 May 2007 17:49:31 GMT
Author: gawor
Date: Tue May  1 10:49:30 2007
New Revision: 534170

URL: http://svn.apache.org/viewvc?view=rev&rev=534170
Log:
check SEI for HandlerChain annotation

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/Messages.properties

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java?view=diff&rev=534170&r1=534169&r2=534170
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
Tue May  1 10:49:30 2007
@@ -27,6 +27,7 @@
 import java.util.logging.Logger;
 
 import javax.jws.HandlerChain;
+import javax.jws.WebService;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.Unmarshaller;
@@ -35,6 +36,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxws.javaee.HandlerChainType;
 import org.apache.cxf.jaxws.javaee.HandlerChainsType;
 
@@ -57,7 +59,7 @@
      */
     public List<Handler> buildHandlerChainFromClass(Class<?> clz, List<Handler>
existingHandlers) {
         LOG.fine("building handler chain");
-        HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz);
+        HandlerChainAnnotation hcAnn = findHandlerChainAnnotation(clz, true);
         List<Handler> chain = null;
         if (hcAnn == null) {
             LOG.fine("no HandlerChain annotation on " + clz);
@@ -103,30 +105,51 @@
         return buildHandlerChainFromClass(clz, null);
     }
 
-    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz) {
-
+    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean
searchSEI) {        
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("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.isLoggable(Level.FINE)) {
-                    LOG.fine("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 && !StringUtils.isEmpty(ws.endpointInterface())) {
+                    String seiClassName = ws.endpointInterface().trim();
+                    Class seiClass = null;
+                    try {
+                        seiClass = clz.getClassLoader().loadClass(seiClassName);
+                    } catch (ClassNotFoundException e) {
+                        throw new WebServiceException(BUNDLE.getString("SEI_LOAD_FAILURE_EXC"),
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.isLoggable(Level.FINE)) {
+                        LOG.fine("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;
     }
-
+    
     private static class HandlerChainAnnotation {
         private final Class<?> declaringClass;
         private final HandlerChain ann;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/Messages.properties?view=diff&rev=534170&r1=534169&r2=534170
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/Messages.properties
Tue May  1 10:49:30 2007
@@ -24,5 +24,6 @@
 HANDLER_CFG_FILE_NOT_FOUND_EXC = Unable to load handler configuration {0} specified by annotation,
file not found."
 HANDLER_INSTANTIATION_EXC = Failed to instantiate handler
 CHAIN_NOT_SPECIFIED_EXC = Chain not specified
+SEI_LOAD_FAILURE_EXC = Failed to load service endpoint interface.
 
 



Mime
View raw message