You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/08/03 20:31:00 UTC

svn commit: r562541 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ frontend/simple/src/main/java/org/apache/cxf/...

Author: dkulp
Date: Fri Aug  3 11:30:59 2007
New Revision: 562541

URL: http://svn.apache.org/viewvc?view=rev&rev=562541
Log:
[CXF-882] Move @Feature processing stuff to AbstractFactoryBean to be shared for client and server
* Remove reference to WebService annotation from rt-core.  Move to JAX-WS frontend.


Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java

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=562541&r1=562540&r2=562541
==============================================================================
--- 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 Fri Aug  3 11:30:59 2007
@@ -24,12 +24,9 @@
 import java.util.List;
 import java.util.ResourceBundle;
 
-import javax.jws.WebService;
-
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 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.feature.AbstractFeature;
 import org.apache.cxf.feature.Features;
 
@@ -37,10 +34,10 @@
     
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AnnotationInterceptors.class);
     
-    private Class<?> clazz;
+    private Class<?> clazzes[];
     
-    public AnnotationInterceptors(Class<?> clz) {
-        clazz = clz;
+    public AnnotationInterceptors(Class<?> ... clz) {
+        clazzes = clz;
     }
     
     public List<Interceptor> getInFaultInterceptors() {
@@ -48,24 +45,12 @@
     }
     
     private <T> List<T> getAnnotationObject(Class<? extends Annotation> annotationClazz, Class<T> type) {
-        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();
-                Class<?> seiClass = null;
-                try {
-                    seiClass = ClassLoaderUtils.loadClass(seiClassName, this.getClass());
-                } catch (ClassNotFoundException e) {
-                    throw new Fault(new Message("COULD_NOT_FIND_SEICLASS", BUNDLE, seiClass), e);
-                }
-                annotation = seiClass.getAnnotation(annotationClazz);
-                if (annotation != null) {
-                    return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
-                }
+        
+        for (Class<?> cls : clazzes) {
+            Annotation  annotation = cls.getAnnotation(annotationClazz);
+            if (annotation != null) {
+                return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
             }
-        } else {
-            return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
         }
         return null;
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Fri Aug  3 11:30:59 2007
@@ -29,8 +29,10 @@
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.common.injection.ResourceInjector;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.interceptor.AnnotationInterceptors;
 import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
 import org.apache.cxf.jaxws.context.WebServiceContextResourceResolver;
 import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
@@ -70,6 +72,22 @@
         doInit = true;
     }
 
+    /**
+     * Add annotationed Interceptors and Features to the Endpoint
+     * @param ep
+     */
+    protected void initializeAnnotationInterceptors(Endpoint ep, Class<?> cls) {
+        Class<?> seiClass = ((JaxWsServiceFactoryBean)getServiceFactory())
+            .getJaxWsImplementorInfo().getSEIClass();
+        AnnotationInterceptors provider;
+        if (seiClass != null) {
+            provider = new AnnotationInterceptors(cls, seiClass);
+        } else {
+            provider = new AnnotationInterceptors(cls);
+        }
+        initializeAnnotationInterceptors(provider, ep);
+    }      
+    
     @Override
     protected Invoker createInvoker() {
         return new JAXWSMethodInvoker(getServiceBean());

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=562541&r1=562540&r2=562541
==============================================================================
--- 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 Fri Aug  3 11:30:59 2007
@@ -142,7 +142,7 @@
     
     @Test
     public void testJaxWsFrontendWithAnnotationInSEI() throws Exception {
-        jfb.setServiceClass(SayHiInterface.class);
+        jfb.setServiceClass(SayHiInterfaceImpl.class);
         jfb.setServiceBean(new SayHiInterfaceImpl());
         jfb.create();
         

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?view=diff&rev=562541&r1=562540&r2=562541
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java Fri Aug  3 11:30:59 2007
@@ -42,6 +42,7 @@
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
+import org.apache.cxf.interceptor.AnnotationInterceptors;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServiceConstructionException;
@@ -226,6 +227,43 @@
         }
         service.getServiceInfos().get(0).addEndpoint(ei);
         return ei;
+    }
+
+    /**
+     * Add annotationed Interceptors and Features to the Endpoint
+     * @param ep
+     */
+    protected void initializeAnnotationInterceptors(Endpoint ep, Class<?> cls) {
+        AnnotationInterceptors provider = new AnnotationInterceptors(cls);
+        if (initializeAnnotationInterceptors(provider, ep)) {
+            LOG.fine("Added annotation based interceptors and features");
+        }
+    }    
+    
+    protected boolean initializeAnnotationInterceptors(AnnotationInterceptors provider, Endpoint ep) {
+        boolean hasAnnotation = false;
+        if (provider.getInFaultInterceptors() != null) {
+            ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
+            hasAnnotation = true;
+        }
+        if (provider.getInInterceptors() != null) {
+            ep.getInInterceptors().addAll(provider.getInInterceptors());
+            hasAnnotation = true;
+        }
+        if (provider.getOutFaultInterceptors() != null) {
+            ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
+            hasAnnotation = true;
+        }
+        if (provider.getOutInterceptors() != null) {
+            ep.getOutInterceptors().addAll(provider.getOutInterceptors());
+            hasAnnotation = true;
+        }
+        if (provider.getFeatures() != null) {
+            getFeatures().addAll(provider.getFeatures());
+            hasAnnotation = true;
+        }
+        
+        return hasAnnotation;
     }
 
     protected BindingInfo createBindingInfo() {

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java Fri Aug  3 11:30:59 2007
@@ -50,12 +50,12 @@
             Endpoint ep = createEndpoint();
             
             createClient(ep);
+            initializeAnnotationInterceptors(ep, getServiceClass());
         } catch (EndpointException e) {
             throw new ServiceConstructionException(e);
         } catch (BusException e) {
             throw new ServiceConstructionException(e);
         }
-        
         applyFeatures();
         return client;
     }

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=562541&r1=562540&r2=562541
==============================================================================
--- 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 Fri Aug  3 11:30:59 2007
@@ -39,7 +39,6 @@
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.interceptor.AnnotationInterceptors;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.resource.URIResolver;
@@ -131,7 +130,7 @@
         }
         
         if (getServiceBean() != null) {
-            initializeAnnotationInterceptors(server.getEndpoint());
+            initializeAnnotationInterceptors(server.getEndpoint(), this.getServiceBean().getClass());
         }
         
         applyFeatures();
@@ -196,42 +195,7 @@
             }
         }
     }
-    
-    /**
-     * 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(AnnotationInterceptors provider, Endpoint ep) {
-        boolean hasAnnotation = false;
-        if (provider.getInFaultInterceptors() != null) {
-            ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
-            hasAnnotation = true;
-        }
-        if (provider.getInInterceptors() != null) {
-            ep.getInInterceptors().addAll(provider.getInInterceptors());
-            hasAnnotation = true;
-        }
-        if (provider.getOutFaultInterceptors() != null) {
-            ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
-            hasAnnotation = true;
-        }
-        if (provider.getOutInterceptors() != null) {
-            ep.getOutInterceptors().addAll(provider.getOutInterceptors());
-            hasAnnotation = true;
-        }
-        return hasAnnotation;
-    }
+      
     
     protected Invoker createInvoker() {
         return new BeanInvoker(serviceBean);



Re: svn commit: r562541 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ frontend/simple/src/main/java/org/apache/cxf/...

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 06 August 2007 04:34, Jeff.Yu wrote:
> sorry, just know it from your commit comment, you don't want the
> "rt-core" get polluted with the @Webservice annotation, which is
> JAX-WS stuff. That makes sense, now I am concern why we can't get the
> SEI class from the "
> ((JaxWsServiceFactoryBean)getServiceFactory()).getJaxWsImplementorInfo
>().getSEIClass(); " if we set the serviceClass() as our SEI class.

Because the service class and the SEI class are two completely different 
things.    The serviceClass should be the class of the Impl that 
actually implements the service.   The SEI is the interface.   


Dan


>
> -Jeff
>
> Jeff.Yu wrote:
> > Hi, Dan
> >
> > I just reviewed these changes, all seems good, but I have a question
> > about the finding SEI class logic.
> >
> > With your change, we passed the SEI to the AnnotationInterceptors
> > class instead of finding the accordingly SEI through "WebService
> > endpointInterface" annotation's attribute, but I also found in the
> > AnnotationInterceptorTest class, we set the ServiceImpl to the
> > setServiceClass() method, which I thought we set the SEI class in
> > most of cases.. I am not sure why we made this change? and with this
> > change, we won't find the SEI class in the "Simple Frontend"
> > scenario, I know for most of simple frontend, we won't specify the
> > @WebService endpointInterface="...." annotation, but we can find the
> > SEI in simple front-end with adding this annotation.
> >
> > Thanks
> > Jeff
> >
> > dkulp@apache.org wrote:
> >> Author: dkulp
> >> Date: Fri Aug  3 11:30:59 2007
> >> New Revision: 562541
> >>
> >> URL: http://svn.apache.org/viewvc?view=rev&rev=562541
> >> Log:
> >> [CXF-882] Move @Feature processing stuff to AbstractFactoryBean to
> >> be shared for client and server
> >> * Remove reference to WebService annotation from rt-core.  Move to
> >> JAX-WS frontend.
> >>
> >>
> >> Modified:
> >>
> >> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/intercepto
> >>r/AnnotationInterceptors.java
> >>
> >>
> >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/
> >>jaxws/JaxWsServerFactoryBean.java
> >>
> >>
> >> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/
> >>jaxws/service/AnnotationInterceptorTest.java
> >>
> >>
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/AbstractEndpointFactory.java
> >>
> >>
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/ClientFactoryBean.java
> >>
> >>
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/ServerFactoryBean.java
> >>
> >>
> >> Modified:
> >> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/intercepto
> >>r/AnnotationInterceptors.java
> >>
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/j
> >>ava/org/apache/cxf/interceptor/AnnotationInterceptors.java?view=diff
> >>&rev=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/intercepto
> >>r/AnnotationInterceptors.java (original)
> >> +++
> >> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/intercepto
> >>r/AnnotationInterceptors.java Fri Aug  3 11:30:59 2007
> >> @@ -24,12 +24,9 @@
> >>  import java.util.List;
> >>  import java.util.ResourceBundle;
> >>
> >> -import javax.jws.WebService;
> >> -
> >>  import org.apache.cxf.common.classloader.ClassLoaderUtils;
> >>  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.feature.AbstractFeature;
> >>  import org.apache.cxf.feature.Features;
> >>
> >> @@ -37,10 +34,10 @@
> >>           private static final ResourceBundle BUNDLE =
> >> BundleUtils.getBundle(AnnotationInterceptors.class);
> >>      -    private Class<?> clazz;
> >> +    private Class<?> clazzes[];
> >>      -    public AnnotationInterceptors(Class<?> clz) {
> >> -        clazz = clz;
> >> +    public AnnotationInterceptors(Class<?> ... clz) {
> >> +        clazzes = clz;
> >>      }
> >>           public List<Interceptor> getInFaultInterceptors() {
> >> @@ -48,24 +45,12 @@
> >>      }
> >>           private <T> List<T> getAnnotationObject(Class<? extends
> >> Annotation> annotationClazz, Class<T> type) {
> >> -        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(); -                Class<?> seiClass =
> >> null;
> >> -                try {
> >> -                    seiClass =
> >> ClassLoaderUtils.loadClass(seiClassName, this.getClass());
> >> -                } catch (ClassNotFoundException e) {
> >> -                    throw new Fault(new
> >> Message("COULD_NOT_FIND_SEICLASS", BUNDLE, seiClass), e);
> >> -                }
> >> -                annotation =
> >> seiClass.getAnnotation(annotationClazz); -                if
> >> (annotation != null) {
> >> -                    return
> >> initializeAnnotationObjects(getAnnotationObjectNames(annotation),
> >> type); -                }
> >> +        +        for (Class<?> cls : clazzes) {
> >> +            Annotation  annotation =
> >> cls.getAnnotation(annotationClazz);
> >> +            if (annotation != null) {
> >> +                return
> >> initializeAnnotationObjects(getAnnotationObjectNames(annotation),
> >> type); }
> >> -        } else {
> >> -            return
> >> initializeAnnotationObjects(getAnnotationObjectNames(annotation),
> >> type); }
> >>          return null;
> >>      }
> >>
> >> Modified:
> >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/
> >>jaxws/JaxWsServerFactoryBean.java
> >>
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/
> >>src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?view=
> >>diff&rev=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/
> >>jaxws/JaxWsServerFactoryBean.java (original)
> >> +++
> >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/
> >>jaxws/JaxWsServerFactoryBean.java Fri Aug  3 11:30:59 2007
> >> @@ -29,8 +29,10 @@
> >>  import org.apache.cxf.binding.AbstractBindingFactory;
> >>  import org.apache.cxf.binding.soap.Soap12;
> >>  import org.apache.cxf.common.injection.ResourceInjector;
> >> +import org.apache.cxf.endpoint.Endpoint;
> >>  import org.apache.cxf.endpoint.Server;
> >>  import org.apache.cxf.frontend.ServerFactoryBean;
> >> +import org.apache.cxf.interceptor.AnnotationInterceptors;
> >>  import
> >> org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
> >> import
> >> org.apache.cxf.jaxws.context.WebServiceContextResourceResolver;
> >> import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
> >> @@ -70,6 +72,22 @@
> >>          doInit = true;
> >>      }
> >>
> >> +    /**
> >> +     * Add annotationed Interceptors and Features to the Endpoint
> >> +     * @param ep
> >> +     */
> >> +    protected void initializeAnnotationInterceptors(Endpoint ep,
> >> Class<?> cls) {
> >> +        Class<?> seiClass =
> >> ((JaxWsServiceFactoryBean)getServiceFactory())
> >> +            .getJaxWsImplementorInfo().getSEIClass();
> >> +        AnnotationInterceptors provider;
> >> +        if (seiClass != null) {
> >> +            provider = new AnnotationInterceptors(cls, seiClass);
> >> +        } else {
> >> +            provider = new AnnotationInterceptors(cls);
> >> +        }
> >> +        initializeAnnotationInterceptors(provider, ep);
> >> +    }      +         @Override
> >>      protected Invoker createInvoker() {
> >>          return new JAXWSMethodInvoker(getServiceBean());
> >>
> >> 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=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> 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 Fri Aug  3 11:30:59
> >> 2007
> >> @@ -142,7 +142,7 @@
> >>           @Test
> >>      public void testJaxWsFrontendWithAnnotationInSEI() throws
> >> Exception {
> >> -        jfb.setServiceClass(SayHiInterface.class);
> >> +        jfb.setServiceClass(SayHiInterfaceImpl.class);
> >>          jfb.setServiceBean(new SayHiInterfaceImpl());
> >>          jfb.create();
> >>
> >> Modified:
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/AbstractEndpointFactory.java
> >>
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple
> >>/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?
> >>view=diff&rev=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/AbstractEndpointFactory.java (original)
> >> +++
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/AbstractEndpointFactory.java Fri Aug  3 11:30:59 2007
> >> @@ -42,6 +42,7 @@
> >>  import org.apache.cxf.endpoint.EndpointImpl;
> >>  import org.apache.cxf.feature.AbstractFeature;
> >>  import
> >> org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
> >> +import org.apache.cxf.interceptor.AnnotationInterceptors; import
> >> org.apache.cxf.service.Service;
> >>  import
> >> org.apache.cxf.service.factory.ReflectionServiceFactoryBean; import
> >> org.apache.cxf.service.factory.ServiceConstructionException; @@
> >> -226,6 +227,43 @@
> >>          }
> >>          service.getServiceInfos().get(0).addEndpoint(ei);
> >>          return ei;
> >> +    }
> >> +
> >> +    /**
> >> +     * Add annotationed Interceptors and Features to the Endpoint
> >> +     * @param ep
> >> +     */
> >> +    protected void initializeAnnotationInterceptors(Endpoint ep,
> >> Class<?> cls) {
> >> +        AnnotationInterceptors provider = new
> >> AnnotationInterceptors(cls);
> >> +        if (initializeAnnotationInterceptors(provider, ep)) {
> >> +            LOG.fine("Added annotation based interceptors and
> >> features");
> >> +        }
> >> +    }    +    +    protected boolean
> >> initializeAnnotationInterceptors(AnnotationInterceptors provider,
> >> Endpoint ep) {
> >> +        boolean hasAnnotation = false;
> >> +        if (provider.getInFaultInterceptors() != null) {
> >> +
> >> ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors(
> >>)); +            hasAnnotation = true;
> >> +        }
> >> +        if (provider.getInInterceptors() != null) {
> >> +
> >> ep.getInInterceptors().addAll(provider.getInInterceptors());
> >> +            hasAnnotation = true;
> >> +        }
> >> +        if (provider.getOutFaultInterceptors() != null) {
> >> +
> >> ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptor
> >>s()); +            hasAnnotation = true;
> >> +        }
> >> +        if (provider.getOutInterceptors() != null) {
> >> +
> >> ep.getOutInterceptors().addAll(provider.getOutInterceptors());
> >> +            hasAnnotation = true;
> >> +        }
> >> +        if (provider.getFeatures() != null) {
> >> +            getFeatures().addAll(provider.getFeatures());
> >> +            hasAnnotation = true;
> >> +        }
> >> +        +        return hasAnnotation;
> >>      }
> >>
> >>      protected BindingInfo createBindingInfo() {
> >>
> >> Modified:
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/ClientFactoryBean.java
> >>
> >> URL:
> >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple
> >>/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java?view=d
> >>iff&rev=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/ClientFactoryBean.java (original)
> >> +++
> >> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf
> >>/frontend/ClientFactoryBean.java Fri Aug  3 11:30:59 2007
> >> @@ -50,12 +50,12 @@
> >>              Endpoint ep = createEndpoint();
> >>                           createClient(ep);
> >> +            initializeAnnotationInterceptors(ep,
> >> getServiceClass()); } catch (EndpointException e) {
> >>              throw new ServiceConstructionException(e);
> >>          } catch (BusException e) {
> >>              throw new ServiceConstructionException(e);
> >>          }
> >> -                 applyFeatures();
> >>          return client;
> >>      }
> >>
> >> 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=d
> >>iff&rev=562541&r1=562540&r2=562541
> >>
> >> ===================================================================
> >>===========
> >>
> >> ---
> >> 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 Fri Aug  3 11:30:59 2007
> >> @@ -39,7 +39,6 @@
> >>  import org.apache.cxf.endpoint.ServerImpl;
> >>  import org.apache.cxf.feature.AbstractFeature;
> >>  import org.apache.cxf.helpers.DOMUtils;
> >> -import org.apache.cxf.interceptor.AnnotationInterceptors;
> >>  import org.apache.cxf.jaxb.JAXBDataBinding;
> >>  import org.apache.cxf.resource.ResourceManager;
> >>  import org.apache.cxf.resource.URIResolver;
> >> @@ -131,7 +130,7 @@
> >>          }
> >>                   if (getServiceBean() != null) {
> >> -           
> >> initializeAnnotationInterceptors(server.getEndpoint()); +          
> >>  initializeAnnotationInterceptors(server.getEndpoint(),
> >> this.getServiceBean().getClass());
> >>          }
> >>                   applyFeatures();
> >> @@ -196,42 +195,7 @@
> >>              }
> >>          }
> >>      }
> >> -    -    /**
> >> -     * 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(AnnotationInterceptors provider,
> >> Endpoint ep) {
> >> -        boolean hasAnnotation = false;
> >> -        if (provider.getInFaultInterceptors() != null) {
> >> -
> >> ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors(
> >>)); -            hasAnnotation = true;
> >> -        }
> >> -        if (provider.getInInterceptors() != null) {
> >> -
> >> ep.getInInterceptors().addAll(provider.getInInterceptors());
> >> -            hasAnnotation = true;
> >> -        }
> >> -        if (provider.getOutFaultInterceptors() != null) {
> >> -
> >> ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptor
> >>s()); -            hasAnnotation = true;
> >> -        }
> >> -        if (provider.getOutInterceptors() != null) {
> >> -
> >> ep.getOutInterceptors().addAll(provider.getOutInterceptors());
> >> -            hasAnnotation = true;
> >> -        }
> >> -        return hasAnnotation;
> >> -    }
> >> +                protected Invoker createInvoker() {
> >>          return new BeanInvoker(serviceBean);

-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog

Re: svn commit: r562541 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ frontend/simple/src/main/java/org/apache/cxf/...

Posted by "Jeff.Yu" <je...@iona.com>.
sorry, just know it from your commit comment, you don't want the 
"rt-core" get polluted with the @Webservice annotation, which is JAX-WS 
stuff. That makes sense, now I am concern why we can't get the SEI class 
from the " 
((JaxWsServiceFactoryBean)getServiceFactory()).getJaxWsImplementorInfo().getSEIClass(); 
" if we set the serviceClass() as our SEI class.

-Jeff


Jeff.Yu wrote:
> Hi, Dan
>
> I just reviewed these changes, all seems good, but I have a question 
> about the finding SEI class logic.
>
> With your change, we passed the SEI to the AnnotationInterceptors 
> class instead of finding the accordingly SEI through "WebService 
> endpointInterface" annotation's attribute, but I also found in the 
> AnnotationInterceptorTest class, we set the ServiceImpl to the 
> setServiceClass() method, which I thought we set the SEI class in most 
> of cases.. I am not sure why we made this change? and with this 
> change, we won't find the SEI class in the "Simple Frontend" scenario, 
> I know for most of simple frontend, we won't specify the @WebService 
> endpointInterface="...." annotation, but we can find the SEI in simple 
> front-end with adding this annotation.
>
> Thanks
> Jeff
>
> dkulp@apache.org wrote:
>> Author: dkulp
>> Date: Fri Aug  3 11:30:59 2007
>> New Revision: 562541
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=562541
>> Log:
>> [CXF-882] Move @Feature processing stuff to AbstractFactoryBean to be 
>> shared for client and server
>> * Remove reference to WebService annotation from rt-core.  Move to 
>> JAX-WS frontend.
>>
>>
>> Modified:
>>     
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java 
>>
>>     
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java 
>>
>>     
>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java 
>>
>>     
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java 
>>
>>     
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java 
>>
>>     
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java 
>>
>>
>> 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=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> 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 
>> Fri Aug  3 11:30:59 2007
>> @@ -24,12 +24,9 @@
>>  import java.util.List;
>>  import java.util.ResourceBundle;
>>  
>> -import javax.jws.WebService;
>> -
>>  import org.apache.cxf.common.classloader.ClassLoaderUtils;
>>  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.feature.AbstractFeature;
>>  import org.apache.cxf.feature.Features;
>>  
>> @@ -37,10 +34,10 @@
>>           private static final ResourceBundle BUNDLE = 
>> BundleUtils.getBundle(AnnotationInterceptors.class);
>>      -    private Class<?> clazz;
>> +    private Class<?> clazzes[];
>>      -    public AnnotationInterceptors(Class<?> clz) {
>> -        clazz = clz;
>> +    public AnnotationInterceptors(Class<?> ... clz) {
>> +        clazzes = clz;
>>      }
>>           public List<Interceptor> getInFaultInterceptors() {
>> @@ -48,24 +45,12 @@
>>      }
>>           private <T> List<T> getAnnotationObject(Class<? extends 
>> Annotation> annotationClazz, Class<T> type) {
>> -        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();
>> -                Class<?> seiClass = null;
>> -                try {
>> -                    seiClass = 
>> ClassLoaderUtils.loadClass(seiClassName, this.getClass());
>> -                } catch (ClassNotFoundException e) {
>> -                    throw new Fault(new 
>> Message("COULD_NOT_FIND_SEICLASS", BUNDLE, seiClass), e);
>> -                }
>> -                annotation = seiClass.getAnnotation(annotationClazz);
>> -                if (annotation != null) {
>> -                    return 
>> initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
>> -                }
>> +        +        for (Class<?> cls : clazzes) {
>> +            Annotation  annotation = 
>> cls.getAnnotation(annotationClazz);
>> +            if (annotation != null) {
>> +                return 
>> initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
>>              }
>> -        } else {
>> -            return 
>> initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
>>          }
>>          return null;
>>      }
>>
>> Modified: 
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java 
>> (original)
>> +++ 
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java 
>> Fri Aug  3 11:30:59 2007
>> @@ -29,8 +29,10 @@
>>  import org.apache.cxf.binding.AbstractBindingFactory;
>>  import org.apache.cxf.binding.soap.Soap12;
>>  import org.apache.cxf.common.injection.ResourceInjector;
>> +import org.apache.cxf.endpoint.Endpoint;
>>  import org.apache.cxf.endpoint.Server;
>>  import org.apache.cxf.frontend.ServerFactoryBean;
>> +import org.apache.cxf.interceptor.AnnotationInterceptors;
>>  import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
>>  import org.apache.cxf.jaxws.context.WebServiceContextResourceResolver;
>>  import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
>> @@ -70,6 +72,22 @@
>>          doInit = true;
>>      }
>>  
>> +    /**
>> +     * Add annotationed Interceptors and Features to the Endpoint
>> +     * @param ep
>> +     */
>> +    protected void initializeAnnotationInterceptors(Endpoint ep, 
>> Class<?> cls) {
>> +        Class<?> seiClass = 
>> ((JaxWsServiceFactoryBean)getServiceFactory())
>> +            .getJaxWsImplementorInfo().getSEIClass();
>> +        AnnotationInterceptors provider;
>> +        if (seiClass != null) {
>> +            provider = new AnnotationInterceptors(cls, seiClass);
>> +        } else {
>> +            provider = new AnnotationInterceptors(cls);
>> +        }
>> +        initializeAnnotationInterceptors(provider, ep);
>> +    }      +         @Override
>>      protected Invoker createInvoker() {
>>          return new JAXWSMethodInvoker(getServiceBean());
>>
>> 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=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> 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 
>> Fri Aug  3 11:30:59 2007
>> @@ -142,7 +142,7 @@
>>           @Test
>>      public void testJaxWsFrontendWithAnnotationInSEI() throws 
>> Exception {
>> -        jfb.setServiceClass(SayHiInterface.class);
>> +        jfb.setServiceClass(SayHiInterfaceImpl.class);
>>          jfb.setServiceBean(new SayHiInterfaceImpl());
>>          jfb.create();
>>         
>> Modified: 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?view=diff&rev=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java 
>> (original)
>> +++ 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java 
>> Fri Aug  3 11:30:59 2007
>> @@ -42,6 +42,7 @@
>>  import org.apache.cxf.endpoint.EndpointImpl;
>>  import org.apache.cxf.feature.AbstractFeature;
>>  import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
>> +import org.apache.cxf.interceptor.AnnotationInterceptors;
>>  import org.apache.cxf.service.Service;
>>  import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
>>  import org.apache.cxf.service.factory.ServiceConstructionException;
>> @@ -226,6 +227,43 @@
>>          }
>>          service.getServiceInfos().get(0).addEndpoint(ei);
>>          return ei;
>> +    }
>> +
>> +    /**
>> +     * Add annotationed Interceptors and Features to the Endpoint
>> +     * @param ep
>> +     */
>> +    protected void initializeAnnotationInterceptors(Endpoint ep, 
>> Class<?> cls) {
>> +        AnnotationInterceptors provider = new 
>> AnnotationInterceptors(cls);
>> +        if (initializeAnnotationInterceptors(provider, ep)) {
>> +            LOG.fine("Added annotation based interceptors and 
>> features");
>> +        }
>> +    }    +    +    protected boolean 
>> initializeAnnotationInterceptors(AnnotationInterceptors provider, 
>> Endpoint ep) {
>> +        boolean hasAnnotation = false;
>> +        if (provider.getInFaultInterceptors() != null) {
>> +            
>> ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
>> +            hasAnnotation = true;
>> +        }
>> +        if (provider.getInInterceptors() != null) {
>> +            
>> ep.getInInterceptors().addAll(provider.getInInterceptors());
>> +            hasAnnotation = true;
>> +        }
>> +        if (provider.getOutFaultInterceptors() != null) {
>> +            
>> ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
>> +            hasAnnotation = true;
>> +        }
>> +        if (provider.getOutInterceptors() != null) {
>> +            
>> ep.getOutInterceptors().addAll(provider.getOutInterceptors());
>> +            hasAnnotation = true;
>> +        }
>> +        if (provider.getFeatures() != null) {
>> +            getFeatures().addAll(provider.getFeatures());
>> +            hasAnnotation = true;
>> +        }
>> +        +        return hasAnnotation;
>>      }
>>  
>>      protected BindingInfo createBindingInfo() {
>>
>> Modified: 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java 
>>
>> URL: 
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java 
>> (original)
>> +++ 
>> incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java 
>> Fri Aug  3 11:30:59 2007
>> @@ -50,12 +50,12 @@
>>              Endpoint ep = createEndpoint();
>>                           createClient(ep);
>> +            initializeAnnotationInterceptors(ep, getServiceClass());
>>          } catch (EndpointException e) {
>>              throw new ServiceConstructionException(e);
>>          } catch (BusException e) {
>>              throw new ServiceConstructionException(e);
>>          }
>> -                 applyFeatures();
>>          return client;
>>      }
>>
>> 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=562541&r1=562540&r2=562541 
>>
>> ============================================================================== 
>>
>> --- 
>> 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 
>> Fri Aug  3 11:30:59 2007
>> @@ -39,7 +39,6 @@
>>  import org.apache.cxf.endpoint.ServerImpl;
>>  import org.apache.cxf.feature.AbstractFeature;
>>  import org.apache.cxf.helpers.DOMUtils;
>> -import org.apache.cxf.interceptor.AnnotationInterceptors;
>>  import org.apache.cxf.jaxb.JAXBDataBinding;
>>  import org.apache.cxf.resource.ResourceManager;
>>  import org.apache.cxf.resource.URIResolver;
>> @@ -131,7 +130,7 @@
>>          }
>>                   if (getServiceBean() != null) {
>> -            initializeAnnotationInterceptors(server.getEndpoint());
>> +            initializeAnnotationInterceptors(server.getEndpoint(), 
>> this.getServiceBean().getClass());
>>          }
>>                   applyFeatures();
>> @@ -196,42 +195,7 @@
>>              }
>>          }
>>      }
>> -    -    /**
>> -     * 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(AnnotationInterceptors provider, 
>> Endpoint ep) {
>> -        boolean hasAnnotation = false;
>> -        if (provider.getInFaultInterceptors() != null) {
>> -            
>> ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
>> -            hasAnnotation = true;
>> -        }
>> -        if (provider.getInInterceptors() != null) {
>> -            
>> ep.getInInterceptors().addAll(provider.getInInterceptors());
>> -            hasAnnotation = true;
>> -        }
>> -        if (provider.getOutFaultInterceptors() != null) {
>> -            
>> ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
>> -            hasAnnotation = true;
>> -        }
>> -        if (provider.getOutInterceptors() != null) {
>> -            
>> ep.getOutInterceptors().addAll(provider.getOutInterceptors());
>> -            hasAnnotation = true;
>> -        }
>> -        return hasAnnotation;
>> -    }
>> +                protected Invoker createInvoker() {
>>          return new BeanInvoker(serviceBean);
>>
>>
>>   
>

Re: svn commit: r562541 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ frontend/simple/src/main/java/org/apache/cxf/...

Posted by "Jeff.Yu" <je...@iona.com>.
Hi, Dan

I just reviewed these changes, all seems good, but I have a question 
about the finding SEI class logic.

With your change, we passed the SEI to the AnnotationInterceptors class 
instead of finding the accordingly SEI through "WebService 
endpointInterface" annotation's attribute, but I also found in the 
AnnotationInterceptorTest class, we set the ServiceImpl to the 
setServiceClass() method, which I thought we set the SEI class in most 
of cases.. I am not sure why we made this change? and with this change, 
we won't find the SEI class in the "Simple Frontend" scenario, I know 
for most of simple frontend, we won't specify the @WebService 
endpointInterface="...." annotation, but we can find the SEI in simple 
front-end with adding this annotation.

Thanks
Jeff

dkulp@apache.org wrote:
> Author: dkulp
> Date: Fri Aug  3 11:30:59 2007
> New Revision: 562541
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=562541
> Log:
> [CXF-882] Move @Feature processing stuff to AbstractFactoryBean to be shared for client and server
> * Remove reference to WebService annotation from rt-core.  Move to JAX-WS frontend.
>
>
> Modified:
>     incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
>     incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
>     incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
>     incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
>     incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
>     incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
>
> 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=562541&r1=562540&r2=562541
> ==============================================================================
> --- 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 Fri Aug  3 11:30:59 2007
> @@ -24,12 +24,9 @@
>  import java.util.List;
>  import java.util.ResourceBundle;
>  
> -import javax.jws.WebService;
> -
>  import org.apache.cxf.common.classloader.ClassLoaderUtils;
>  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.feature.AbstractFeature;
>  import org.apache.cxf.feature.Features;
>  
> @@ -37,10 +34,10 @@
>      
>      private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AnnotationInterceptors.class);
>      
> -    private Class<?> clazz;
> +    private Class<?> clazzes[];
>      
> -    public AnnotationInterceptors(Class<?> clz) {
> -        clazz = clz;
> +    public AnnotationInterceptors(Class<?> ... clz) {
> +        clazzes = clz;
>      }
>      
>      public List<Interceptor> getInFaultInterceptors() {
> @@ -48,24 +45,12 @@
>      }
>      
>      private <T> List<T> getAnnotationObject(Class<? extends Annotation> annotationClazz, Class<T> type) {
> -        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();
> -                Class<?> seiClass = null;
> -                try {
> -                    seiClass = ClassLoaderUtils.loadClass(seiClassName, this.getClass());
> -                } catch (ClassNotFoundException e) {
> -                    throw new Fault(new Message("COULD_NOT_FIND_SEICLASS", BUNDLE, seiClass), e);
> -                }
> -                annotation = seiClass.getAnnotation(annotationClazz);
> -                if (annotation != null) {
> -                    return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
> -                }
> +        
> +        for (Class<?> cls : clazzes) {
> +            Annotation  annotation = cls.getAnnotation(annotationClazz);
> +            if (annotation != null) {
> +                return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
>              }
> -        } else {
> -            return initializeAnnotationObjects(getAnnotationObjectNames(annotation), type);
>          }
>          return null;
>      }
>
> Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541
> ==============================================================================
> --- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original)
> +++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Fri Aug  3 11:30:59 2007
> @@ -29,8 +29,10 @@
>  import org.apache.cxf.binding.AbstractBindingFactory;
>  import org.apache.cxf.binding.soap.Soap12;
>  import org.apache.cxf.common.injection.ResourceInjector;
> +import org.apache.cxf.endpoint.Endpoint;
>  import org.apache.cxf.endpoint.Server;
>  import org.apache.cxf.frontend.ServerFactoryBean;
> +import org.apache.cxf.interceptor.AnnotationInterceptors;
>  import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
>  import org.apache.cxf.jaxws.context.WebServiceContextResourceResolver;
>  import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder;
> @@ -70,6 +72,22 @@
>          doInit = true;
>      }
>  
> +    /**
> +     * Add annotationed Interceptors and Features to the Endpoint
> +     * @param ep
> +     */
> +    protected void initializeAnnotationInterceptors(Endpoint ep, Class<?> cls) {
> +        Class<?> seiClass = ((JaxWsServiceFactoryBean)getServiceFactory())
> +            .getJaxWsImplementorInfo().getSEIClass();
> +        AnnotationInterceptors provider;
> +        if (seiClass != null) {
> +            provider = new AnnotationInterceptors(cls, seiClass);
> +        } else {
> +            provider = new AnnotationInterceptors(cls);
> +        }
> +        initializeAnnotationInterceptors(provider, ep);
> +    }      
> +    
>      @Override
>      protected Invoker createInvoker() {
>          return new JAXWSMethodInvoker(getServiceBean());
>
> 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=562541&r1=562540&r2=562541
> ==============================================================================
> --- 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 Fri Aug  3 11:30:59 2007
> @@ -142,7 +142,7 @@
>      
>      @Test
>      public void testJaxWsFrontendWithAnnotationInSEI() throws Exception {
> -        jfb.setServiceClass(SayHiInterface.class);
> +        jfb.setServiceClass(SayHiInterfaceImpl.class);
>          jfb.setServiceBean(new SayHiInterfaceImpl());
>          jfb.create();
>          
>
> Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java?view=diff&rev=562541&r1=562540&r2=562541
> ==============================================================================
> --- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java (original)
> +++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/AbstractEndpointFactory.java Fri Aug  3 11:30:59 2007
> @@ -42,6 +42,7 @@
>  import org.apache.cxf.endpoint.EndpointImpl;
>  import org.apache.cxf.feature.AbstractFeature;
>  import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
> +import org.apache.cxf.interceptor.AnnotationInterceptors;
>  import org.apache.cxf.service.Service;
>  import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
>  import org.apache.cxf.service.factory.ServiceConstructionException;
> @@ -226,6 +227,43 @@
>          }
>          service.getServiceInfos().get(0).addEndpoint(ei);
>          return ei;
> +    }
> +
> +    /**
> +     * Add annotationed Interceptors and Features to the Endpoint
> +     * @param ep
> +     */
> +    protected void initializeAnnotationInterceptors(Endpoint ep, Class<?> cls) {
> +        AnnotationInterceptors provider = new AnnotationInterceptors(cls);
> +        if (initializeAnnotationInterceptors(provider, ep)) {
> +            LOG.fine("Added annotation based interceptors and features");
> +        }
> +    }    
> +    
> +    protected boolean initializeAnnotationInterceptors(AnnotationInterceptors provider, Endpoint ep) {
> +        boolean hasAnnotation = false;
> +        if (provider.getInFaultInterceptors() != null) {
> +            ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
> +            hasAnnotation = true;
> +        }
> +        if (provider.getInInterceptors() != null) {
> +            ep.getInInterceptors().addAll(provider.getInInterceptors());
> +            hasAnnotation = true;
> +        }
> +        if (provider.getOutFaultInterceptors() != null) {
> +            ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
> +            hasAnnotation = true;
> +        }
> +        if (provider.getOutInterceptors() != null) {
> +            ep.getOutInterceptors().addAll(provider.getOutInterceptors());
> +            hasAnnotation = true;
> +        }
> +        if (provider.getFeatures() != null) {
> +            getFeatures().addAll(provider.getFeatures());
> +            hasAnnotation = true;
> +        }
> +        
> +        return hasAnnotation;
>      }
>  
>      protected BindingInfo createBindingInfo() {
>
> Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java?view=diff&rev=562541&r1=562540&r2=562541
> ==============================================================================
> --- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java (original)
> +++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientFactoryBean.java Fri Aug  3 11:30:59 2007
> @@ -50,12 +50,12 @@
>              Endpoint ep = createEndpoint();
>              
>              createClient(ep);
> +            initializeAnnotationInterceptors(ep, getServiceClass());
>          } catch (EndpointException e) {
>              throw new ServiceConstructionException(e);
>          } catch (BusException e) {
>              throw new ServiceConstructionException(e);
>          }
> -        
>          applyFeatures();
>          return client;
>      }
>
> 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=562541&r1=562540&r2=562541
> ==============================================================================
> --- 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 Fri Aug  3 11:30:59 2007
> @@ -39,7 +39,6 @@
>  import org.apache.cxf.endpoint.ServerImpl;
>  import org.apache.cxf.feature.AbstractFeature;
>  import org.apache.cxf.helpers.DOMUtils;
> -import org.apache.cxf.interceptor.AnnotationInterceptors;
>  import org.apache.cxf.jaxb.JAXBDataBinding;
>  import org.apache.cxf.resource.ResourceManager;
>  import org.apache.cxf.resource.URIResolver;
> @@ -131,7 +130,7 @@
>          }
>          
>          if (getServiceBean() != null) {
> -            initializeAnnotationInterceptors(server.getEndpoint());
> +            initializeAnnotationInterceptors(server.getEndpoint(), this.getServiceBean().getClass());
>          }
>          
>          applyFeatures();
> @@ -196,42 +195,7 @@
>              }
>          }
>      }
> -    
> -    /**
> -     * 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(AnnotationInterceptors provider, Endpoint ep) {
> -        boolean hasAnnotation = false;
> -        if (provider.getInFaultInterceptors() != null) {
> -            ep.getInFaultInterceptors().addAll(provider.getInFaultInterceptors());
> -            hasAnnotation = true;
> -        }
> -        if (provider.getInInterceptors() != null) {
> -            ep.getInInterceptors().addAll(provider.getInInterceptors());
> -            hasAnnotation = true;
> -        }
> -        if (provider.getOutFaultInterceptors() != null) {
> -            ep.getOutFaultInterceptors().addAll(provider.getOutFaultInterceptors());
> -            hasAnnotation = true;
> -        }
> -        if (provider.getOutInterceptors() != null) {
> -            ep.getOutInterceptors().addAll(provider.getOutInterceptors());
> -            hasAnnotation = true;
> -        }
> -        return hasAnnotation;
> -    }
> +      
>      
>      protected Invoker createInvoker() {
>          return new BeanInvoker(serviceBean);
>
>
>