cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r559741 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/feature/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ rt/f...
Date Thu, 26 Jul 2007 08:06:39 GMT
Author: ffang
Date: Thu Jul 26 01:06:33 2007
New Revision: 559741

URL: http://svn.apache.org/viewvc?view=rev&rev=559741
Log:
[CXF-803] apply patch provided by Jeff Yu, add support for Feature annotation

Added:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/SayHiInterface.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java

Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java?view=auto&rev=559741
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java (added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java Thu Jul 26
01:06:33 2007
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.feature;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Features {
+    String[] features();
+}

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/Features.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Thu
Jul 26 01:06:33 2007
@@ -73,7 +73,7 @@
     protected Bus bus;
     protected ConduitSelector conduitSelector;
     protected ClientOutFaultObserver outFaultObserver; 
-    protected int synchronousTimeout = 1000000; // default 10 second timeout
+    protected int synchronousTimeout = 10000; // default 10 second timeout
     
     protected PhaseChainCache outboundChainCache = new PhaseChainCache();
     protected PhaseChainCache inboundChainCache = new PhaseChainCache();

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
Thu Jul 26 01:06:33 2007
@@ -30,7 +30,9 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.feature.Features;
+import org.apache.cxf.helpers.CastUtils;
 
 public class AnnotationInterceptors {
     
@@ -42,16 +44,14 @@
         clazz = clz;
     }
     
-    public List<Interceptor> getInFaultInterceptors() throws EndpointException {
-        return getInterceptors(InFaultInterceptors.class);
+    public List<Interceptor> getInFaultInterceptors() {
+        return CastUtils.cast(getAnnotationObject(InFaultInterceptors.class), Interceptor.class);
     }
     
-    @SuppressWarnings (value = "unchecked")
-    private List<Interceptor> getInterceptors(Class clz) throws EndpointException {
-        Annotation  annotation = clazz.getAnnotation(clz);
-        if (annotation != null) {
-            return initializeInterceptors(getInterceptorNames(annotation));
-        } else {
+    @SuppressWarnings ("unchecked")
+    private List getAnnotationObject(Class annotationClazz) {
+        Annotation  annotation = clazz.getAnnotation(annotationClazz);
+        if (annotation == null) {
             WebService ws = clazz.getAnnotation(WebService.class);
             if (ws != null && !StringUtils.isEmpty(ws.endpointInterface())) {
                 String seiClassName = ws.endpointInterface().trim();
@@ -59,18 +59,20 @@
                 try {
                     seiClass = ClassLoaderUtils.loadClass(seiClassName, this.getClass());
                 } catch (ClassNotFoundException e) {
-                    throw new RuntimeException("couldnt find class :" + seiClass, e);
+                    throw new Fault(new Message("COULD_NOT_FIND_SEICLASS", BUNDLE, seiClass),
e);
                 }
-                annotation = seiClass.getAnnotation(clz);
+                annotation = seiClass.getAnnotation(annotationClazz);
                 if (annotation != null) {
-                    return initializeInterceptors(getInterceptorNames(annotation));
+                    return initializeAnnotationObjects(getAnnotationObjectNames(annotation));
                 }
-            }           
+            }
+        } else {
+            return initializeAnnotationObjects(getAnnotationObjectNames(annotation));
         }
-        return new ArrayList<Interceptor>();
+        return null;
     }
     
-    private String[] getInterceptorNames(Annotation ann) {
+    private String[] getAnnotationObjectNames(Annotation ann) {
         if (ann instanceof InFaultInterceptors) {
             return ((InFaultInterceptors)ann).interceptors();
         } else if (ann instanceof InInterceptors) {
@@ -79,49 +81,54 @@
             return ((OutFaultInterceptors)ann).interceptors();
         } else if (ann instanceof OutInterceptors) {
             return ((OutInterceptors)ann).interceptors();
+        } else if (ann instanceof Features) {
+            return ((Features)ann).features();
         }
-        throw new UnsupportedOperationException("Doesn't support other annotation for interceptor:
" + ann);
+        
+        throw new UnsupportedOperationException("Doesn't support the annotation: " + ann);
     }
     
-    
-    private List<Interceptor> initializeInterceptors(String[] interceptors) throws
EndpointException {
-        List<Interceptor> theInterceptors = new ArrayList<Interceptor>();
-        if (interceptors != null && interceptors.length > 0) {
-            for (String interceptorName : interceptors) {
-                Interceptor interceptor = null;
+    @SuppressWarnings("unchecked")
+    private List initializeAnnotationObjects(String[] annotationObjects) {
+        List theAnnotationObjects = new ArrayList();
+        if (annotationObjects != null && annotationObjects.length > 0) {
+            for (String annObjectName : annotationObjects) {
+                Object object = null;
                 try {
-                    interceptor = (Interceptor)ClassLoaderUtils.loadClass(interceptorName,

-                                                                          this.getClass()).newInstance();
+                    object = ClassLoaderUtils.loadClass(annObjectName, this.getClass()).newInstance();
                 } catch (ClassNotFoundException e) {
-                    throw new EndpointException(new Message("COULD_NOT_CREATE_ANNOTATION_INTERCEPOTR",

-                                                    BUNDLE, interceptorName), e);
+                    throw new Fault(new Message("COULD_NOT_CREATE_ANNOTATION_OBJECT", 
+                                                    BUNDLE, annObjectName), e);
                 } catch (InstantiationException ie) {
-                    throw new EndpointException(new Message("COULD_NOT_CREATE_ANNOTATION_INTERCEPOTR",

-                                                    BUNDLE, interceptorName), ie);
+                    throw new Fault(new Message("COULD_NOT_CREATE_ANNOTATION_OBJECT", 
+                                                    BUNDLE, annObjectName), ie);
                 } catch (IllegalAccessException iae) {
-                    throw new EndpointException(new Message("COULD_NOT_CREATE_ANNOTATION_INTERCEPOTR",

-                                                    BUNDLE, interceptorName), iae);
+                    throw new Fault(new Message("COULD_NOT_CREATE_ANNOTATION_OBJECT", 
+                                                    BUNDLE, annObjectName), iae);
                 }
-                if (interceptor != null) {
-                    theInterceptors.add(interceptor);
+                if (object != null) {
+                    theAnnotationObjects.add(object);
                 }
             }
         }
-        return theInterceptors;
+        return theAnnotationObjects;
     }
 
 
-    public List<Interceptor> getInInterceptors() throws EndpointException {
-        return getInterceptors(InInterceptors.class);
+    public List<Interceptor> getInInterceptors() {
+        return CastUtils.cast(getAnnotationObject(InInterceptors.class), Interceptor.class);
     }
 
-    public List<Interceptor> getOutFaultInterceptors() throws EndpointException {
-        return getInterceptors(OutFaultInterceptors.class);
+    public List<Interceptor> getOutFaultInterceptors() {
+        return CastUtils.cast(getAnnotationObject(OutFaultInterceptors.class), Interceptor.class);
     }
 
-
-    public List<Interceptor> getOutInterceptors() throws EndpointException {
-        return getInterceptors(OutInterceptors.class);
+    public List<Interceptor> getOutInterceptors() {
+        return CastUtils.cast(getAnnotationObject(OutInterceptors.class), Interceptor.class);
+    }
+        
+    public List<AbstractFeature> getFeatures() {
+        return CastUtils.cast(getAnnotationObject(Features.class), AbstractFeature.class);
     }
 
 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
Thu Jul 26 01:06:33 2007
@@ -33,4 +33,5 @@
 INVOKE_FAULT_INFO=Couldn't invoke getFaultInfo method.
 NO_FAULT_INFO_METHOD=Custom faults need a getFaultInfo method.
 NO_ACCCESS_FAULT_INFO=Couldn't access getFaultInfo method.
-COULD_NOT_CREATE_ANNOTATION_INTERCEPOTR=Could not create annotation interceptor: {0}
\ No newline at end of file
+COULD_NOT_CREATE_ANNOTATION_OBJECT=Could not create annotation object: {0}
+COULD_NOT_FIND_SEICLASS=Could not find the class: {0}
\ No newline at end of file

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java?view=auto&rev=559741
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
(added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
Thu Jul 26 01:06:33 2007
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxws.service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class AnnotationFeature extends AbstractFeature {
+    
+    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
+        provider.getInInterceptors().add(new AnnotationFeatureInterceptor());
+        provider.getOutInterceptors().add(new AnnotationFeatureInterceptor());
+    }
+    
+    public static class AnnotationFeatureInterceptor extends AbstractPhaseInterceptor {
+        
+        public AnnotationFeatureInterceptor() {
+            super(Phase.SEND);
+        }
+        
+        public void handleMessage(Message message) {
+            System.out.println("Handle Message in AnnotationFeatureInterceptor");
+        }
+        
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationFeature.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
Thu Jul 26 01:06:33 2007
@@ -23,11 +23,16 @@
 
 import javax.jws.WebService;
 
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.feature.Features;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.interceptor.InFaultInterceptors;
 import org.apache.cxf.interceptor.InInterceptors;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.OutFaultInterceptors;
 import org.apache.cxf.jaxws.AbstractJaxWsTest;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.jaxws.service.AnnotationFeature.AnnotationFeatureInterceptor;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -57,10 +62,26 @@
         
         List<Interceptor> interceptors = fb.getServer().getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
+        assertFalse(hasTest2Interceptor(interceptors));
+        
+        List<Interceptor> outFaultInterceptors = fb.getServer().getEndpoint().getOutFaultInterceptors();
+        assertTrue(hasTestInterceptor(outFaultInterceptors));
+        assertTrue(hasTest2Interceptor(outFaultInterceptors));
     }
     
     @Test
-    public void testSimpleFrontendWithNoInterceptor() throws Exception {
+    public void testSimpleFrontendWithFeature() throws Exception {
+        fb.setServiceClass(HelloService.class);
+        HelloService hello = new HelloServiceImpl();
+        fb.setServiceBean(hello);
+        fb.create();
+        
+        List<AbstractFeature> features = fb.getFeatures();
+        assertTrue(hasAnnotationFeature(features));
+    }
+    
+    @Test
+    public void testSimpleFrontendWithNoAnnotation() throws Exception {
         fb.setServiceClass(HelloService.class);        
         HelloService hello = new HelloServiceImplNoAnnotation();
         fb.setServiceBean(hello);
@@ -68,21 +89,27 @@
         
         List<Interceptor> interceptors = fb.getServer().getEndpoint().getInInterceptors();
         assertFalse(hasTestInterceptor(interceptors));
+        
+        List<AbstractFeature> features = fb.getFeatures();
+        assertFalse(hasAnnotationFeature(features));
     }
     
     
     @Test
-    public void testJaxwsFrontendWithNoInterceptor() throws Exception {
+    public void testJaxwsFrontendWithNoAnnotation() throws Exception {
         jfb.setServiceClass(SayHi.class);
         jfb.setServiceBean(new SayHiNoInterceptor());
         
         jfb.create();
         List<Interceptor> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
         assertFalse(hasTestInterceptor(interceptors));
+        
+        List<AbstractFeature> features = fb.getFeatures();
+        assertFalse(hasAnnotationFeature(features));
     }
     
     @Test
-    public void testJaxwsFrontendWithImpl() throws Exception {
+    public void testJaxwsFrontendWithAnnotationInImpl() throws Exception {
         jfb.setServiceClass(SayHi.class);
         SayHi implementor = new SayHiImplementation();
         jfb.setServiceBean(implementor);
@@ -90,20 +117,44 @@
         jfb.create();
         List<Interceptor> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
+        
+        List<Interceptor> inFaultInterceptors = jfb.getServer().getEndpoint().getInFaultInterceptors();
+        assertFalse(hasTestInterceptor(inFaultInterceptors));
+        assertTrue(hasTest2Interceptor(inFaultInterceptors));
+        
+        List<AbstractFeature> features = jfb.getFeatures();
+        assertTrue(hasAnnotationFeature(features));
     }
     
     @Test
-    public void testJaxWsFrontendWithInterceptorInSEI() throws Exception {
+    public void testJaxwsFrontendWithFeatureAnnotation() throws Exception {
+        jfb.setServiceClass(SayHi.class);
+        SayHi implementor = new SayHiImplementation();
+        jfb.setServiceBean(implementor);
+        
+        jfb.create();
+        List<Interceptor> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
+        assertTrue(hasAnnotationFeatureInterceptor(interceptors));
+        
+        List<Interceptor> outInterceptors = jfb.getServer().getEndpoint().getOutInterceptors();
+        assertTrue(hasAnnotationFeatureInterceptor(outInterceptors));
+    }
+    
+    @Test
+    public void testJaxWsFrontendWithAnnotationInSEI() throws Exception {
         jfb.setServiceClass(SayHiInterface.class);
         jfb.setServiceBean(new SayHiInterfaceImpl());
         jfb.create();
         
         List<Interceptor> interceptors = jfb.getServer().getEndpoint().getInInterceptors();
         assertTrue(hasTestInterceptor(interceptors));
+        
+        List<AbstractFeature> features = jfb.getFeatures();
+        assertTrue(hasAnnotationFeature(features));
     }
     
     @Test
-    public void testJaxWsFrontend() throws Exception {
+    public void testJaxWsFrontendWithAnnotationInSEIAndImpl() throws Exception {
         jfb.setServiceClass(SayHiInterface.class);
         jfb.setServiceBean(new SayHiInterfaceImpl2());
         jfb.create();
@@ -123,7 +174,7 @@
         }
         return flag;
     }
-    
+        
     private boolean hasTest2Interceptor(List<Interceptor> interceptors) {
         boolean flag = false;
         for (Interceptor it : interceptors) {
@@ -134,7 +185,30 @@
         return flag;
     }
     
+    private boolean hasAnnotationFeature(List<AbstractFeature> features) {
+        boolean flag = false;
+        for (AbstractFeature af : features) {
+            if (af instanceof AnnotationFeature) {
+                flag = true;
+            }
+        }
+        return flag;
+    }
+    
+    private boolean hasAnnotationFeatureInterceptor(List<Interceptor> interceptors)
{
+        boolean flag = false;
+        for (Interceptor it : interceptors) {
+            if (it instanceof AnnotationFeatureInterceptor) {
+                flag = true;
+            }
+        }
+        return flag;
+    }
+    
     @InInterceptors(interceptors = "org.apache.cxf.jaxws.service.TestInterceptor")
+    @OutFaultInterceptors (interceptors = {"org.apache.cxf.jaxws.service.TestInterceptor"
, 
+                                           "org.apache.cxf.jaxws.service.Test2Interceptor"
})
+    @Features (features = "org.apache.cxf.jaxws.service.AnnotationFeature")
     public class HelloServiceImpl implements HelloService {
         public String sayHi() {
             return "HI";
@@ -152,6 +226,8 @@
                 targetNamespace = "http://mynamespace.com/",
                 endpointInterface = "org.apache.cxf.jaxws.service.SayHi")
     @InInterceptors (interceptors = {"org.apache.cxf.jaxws.service.TestInterceptor" })
+    @InFaultInterceptors (interceptors = {"org.apache.cxf.jaxws.service.Test2Interceptor"
})
+    @Features (features = "org.apache.cxf.jaxws.service.AnnotationFeature")
     public class SayHiImplementation implements SayHi {
         public long sayHi(long arg) {
             return arg;
@@ -197,6 +273,7 @@
             return ret;
         }        
     }
+    
     
     @WebService(endpointInterface = "org.apache.cxf.jaxws.service.SayHiInterface")
     public class SayHiInterfaceImpl implements SayHiInterface {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/SayHiInterface.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/SayHiInterface.java?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/SayHiInterface.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/SayHiInterface.java
Thu Jul 26 01:06:33 2007
@@ -22,11 +22,13 @@
 import javax.jws.WebService;
 import javax.jws.soap.SOAPBinding;
 
+import org.apache.cxf.feature.Features;
 import org.apache.cxf.interceptor.InInterceptors;
 
 @SOAPBinding(style = SOAPBinding.Style.RPC, use = SOAPBinding.Use.LITERAL)
 @WebService(name = "Hello", targetNamespace = "http://mynamespace.com/")
 @InInterceptors (interceptors = "org.apache.cxf.jaxws.service.TestInterceptor")
+@Features (features = "org.apache.cxf.jaxws.service.AnnotationFeature")
 public interface SayHiInterface {
 
     @WebMethod(operationName = "sayHi", exclude = false)

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?view=diff&rev=559741&r1=559740&r2=559741
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
Thu Jul 26 01:06:33 2007
@@ -119,10 +119,6 @@
                 ep.getService().setInvoker(invoker);
             }
             
-            if (getServiceBean() != null) {
-                initializeAnnotationInterceptors(ep);
-            }
-            
             if (start) {
                 server.start();
             }
@@ -134,6 +130,10 @@
             throw new ServiceConstructionException(e);
         }
         
+        if (getServiceBean() != null) {
+            initializeAnnotationInterceptors(server.getEndpoint());
+        }
+        
         applyFeatures();
         return server;
     }
@@ -197,29 +197,36 @@
         }
     }
     
-    protected void initializeAnnotationInterceptors(Endpoint ep) throws EndpointException
{
-        Object implementor = getServiceBean();
-        if (initializeAnnotationInterceptors(ep, implementor.getClass())) {
-            LOG.fine("added annotation based interceptors");
+    /**
+     * Add annotationed Interceptors and Features to the Endpoint
+     * @param ep
+     */
+    protected void initializeAnnotationInterceptors(Endpoint ep) {
+        AnnotationInterceptors provider = new AnnotationInterceptors(getServiceBean().getClass());
+        if (initializeAnnotationInterceptors(provider, ep)) {
+            LOG.fine("Added annotation based interceptors");
+        }
+        if (provider.getFeatures() != null) {
+            getFeatures().addAll(provider.getFeatures());
+            LOG.fine("Added annotation based features");
         }
     }
     
-    protected boolean initializeAnnotationInterceptors(Endpoint ep, Class<?> clazz)
throws EndpointException {
+    protected boolean initializeAnnotationInterceptors(AnnotationInterceptors provider, Endpoint
ep) {
         boolean hasAnnotation = false;
-        AnnotationInterceptors provider = new AnnotationInterceptors(clazz);
-        if (provider.getInFaultInterceptors().size() > 0) {
+        if (provider.getInFaultInterceptors() != null) {
             ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
             hasAnnotation = true;
         }
-        if (provider.getInInterceptors().size() > 0) {
+        if (provider.getInInterceptors() != null) {
             ep.getInInterceptors().addAll(provider.getInInterceptors());
             hasAnnotation = true;
         }
-        if (provider.getOutFaultInterceptors().size() > 0) {
+        if (provider.getOutFaultInterceptors() != null) {
             ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
             hasAnnotation = true;
         }
-        if (provider.getOutInterceptors().size() > 0) {
+        if (provider.getOutInterceptors() != null) {
             ep.getOutInterceptors().addAll(provider.getOutInterceptors());
             hasAnnotation = true;
         }



Mime
View raw message