cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1232094 - in /cxf/branches/2.5.x-fixes: ./ api/src/main/java/org/apache/cxf/feature/ api/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/servi...
Date Mon, 16 Jan 2012 18:21:24 GMT
Author: dkulp
Date: Mon Jan 16 18:21:24 2012
New Revision: 1232094

URL: http://svn.apache.org/viewvc?rev=1232094&view=rev
Log:
Merged revisions 1232089 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1232089 | dkulp | 2012-01-16 13:12:04 -0500 (Mon, 16 Jan 2012) | 2 lines
  
  [CXF-4033] Allow interceptors to be added via the annotations using
  Class objects instead of just strings of classnames.
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/feature/Features.java
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InFaultInterceptors.java
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InInterceptors.java
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutFaultInterceptors.java
    cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutInterceptors.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
    cxf/branches/2.5.x-fixes/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/transformation/DoubleItPortTypeImpl.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/feature/Features.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/feature/Features.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/feature/Features.java (original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/feature/Features.java Mon Jan
16 18:21:24 2012
@@ -26,5 +26,7 @@ import java.lang.annotation.Target;
 @Target(ElementType.TYPE)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Features {
-    String[] features();
+    String[] features() default { };
+    
+    Class<? extends Feature>[] classes() default { };
 }

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InFaultInterceptors.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InFaultInterceptors.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InFaultInterceptors.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InFaultInterceptors.java
Mon Jan 16 18:21:24 2012
@@ -23,6 +23,8 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+
+import org.apache.cxf.message.Message;
 /**
  * Specifies a list of classes that are added to the inbound fault 
  * interceptor chain. This annotation effects SEI classes and service 
@@ -32,5 +34,7 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface InFaultInterceptors {
     
-    String[] interceptors();
+    String[] interceptors() default { };
+    
+    Class<? extends Interceptor<? extends Message>>[] classes() default { };
 }

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InInterceptors.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InInterceptors.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InInterceptors.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/InInterceptors.java
Mon Jan 16 18:21:24 2012
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.cxf.message.Message;
+
 
 /**
  * Specifies a list of classes that are added to the inbound interceptor 
@@ -34,6 +36,7 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface InInterceptors {
     
-    String[] interceptors();
+    String[] interceptors() default { };
     
+    Class<? extends Interceptor<? extends Message>>[] classes() default { };
 }

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutFaultInterceptors.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutFaultInterceptors.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutFaultInterceptors.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutFaultInterceptors.java
Mon Jan 16 18:21:24 2012
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.cxf.message.Message;
+
 /**
  * Specifies a list of classes that are added to the outbound fault 
  * interceptor chain. This annotation effects SEI classes and service 
@@ -33,5 +35,8 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface OutFaultInterceptors {
     
-    String[] interceptors();
+    String[] interceptors() default { };
+    
+    Class<? extends Interceptor<? extends Message>>[] classes() default { };
+
 }

Modified: cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutInterceptors.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutInterceptors.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutInterceptors.java
(original)
+++ cxf/branches/2.5.x-fixes/api/src/main/java/org/apache/cxf/interceptor/OutInterceptors.java
Mon Jan 16 18:21:24 2012
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.cxf.message.Message;
+
 
 /**
  * Specifies a list of classes that are added to the outbound 
@@ -34,6 +36,8 @@ import java.lang.annotation.Target;
 @Retention(RetentionPolicy.RUNTIME)
 public @interface OutInterceptors {
     
-    String[] interceptors();
+    String[] interceptors() default { };
+    
+    Class<? extends Interceptor<? extends Message>>[] classes() default { };
     
 }

Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AnnotationInterceptors.java
Mon Jan 16 18:21:24 2012
@@ -45,12 +45,40 @@ public class AnnotationInterceptors {
         for (Class<?> cls : clazzes) {
             Annotation  annotation = cls.getAnnotation(annotationClazz);
             if (annotation != null) {
-                return initializeAnnotationObjects(getAnnotationObjectNames(annotation),
type);
+                return initializeAnnotationObjects(annotation, type);
             }
         }
         return null;
     }
     
+    private <T> List<T> initializeAnnotationObjects(Annotation annotation,
+                                             Class<T> type) {
+        List<T> list = new ArrayList<T>();
+        for (String cn : getAnnotationObjectNames(annotation)) {
+            list.add(initializeAnnotationObject(cn, type));
+        }
+        for (Class<? extends T> cn : getAnnotationObjectClasses(annotation, type))
{
+            list.add(initializeAnnotationObject(cn));
+        }
+        return list;   
+    }
+    
+    @SuppressWarnings("unchecked")
+    private <T> Class<? extends T>[] getAnnotationObjectClasses(Annotation ann,
Class<T> type) {
+        if (ann instanceof InFaultInterceptors) {
+            return (Class<? extends T>[])((InFaultInterceptors)ann).classes();
+        } else if (ann instanceof InInterceptors) {
+            return (Class<? extends T>[])((InInterceptors)ann).classes();
+        } else if (ann instanceof OutFaultInterceptors) {
+            return (Class<? extends T>[])((OutFaultInterceptors)ann).classes();
+        } else if (ann instanceof OutInterceptors) {
+            return (Class<? extends T>[])((OutInterceptors)ann).classes();
+        } else if (ann instanceof Features) {
+            return (Class<? extends T>[])((Features)ann).classes();
+        }
+        throw new UnsupportedOperationException("Doesn't support the annotation: " + ann);
+    }
+
     private String[] getAnnotationObjectNames(Annotation ann) {
         if (ann instanceof InFaultInterceptors) {
             return ((InFaultInterceptors)ann).interceptors();
@@ -67,34 +95,27 @@ public class AnnotationInterceptors {
         throw new UnsupportedOperationException("Doesn't support the annotation: " + ann);
     }
     
-    private <T> List<T> initializeAnnotationObjects(String[] annotationObjects,
Class<T> type) {
-        List<T> theAnnotationObjects = new ArrayList<T>();
-        if (annotationObjects != null && annotationObjects.length > 0) {
-            for (String annObjectName : annotationObjects) {
-                Object object = null;
-                try {
-                    object = ClassLoaderUtils.loadClass(annObjectName, this.getClass()).newInstance();
-                    theAnnotationObjects.add(type.cast(object));
-                } catch (ClassNotFoundException e) {
-                    throw new Fault(new org.apache.cxf.common.i18n.Message(
-                                                    "COULD_NOT_CREATE_ANNOTATION_OBJECT",

-                                                    BUNDLE, annObjectName), e);
-                } catch (InstantiationException ie) {
-                    throw new Fault(new org.apache.cxf.common.i18n.Message(
-                                                    "COULD_NOT_CREATE_ANNOTATION_OBJECT",

-                                                    BUNDLE, annObjectName), ie);
-                } catch (IllegalAccessException iae) {
-                    throw new Fault(new org.apache.cxf.common.i18n.Message(
-                                                    "COULD_NOT_CREATE_ANNOTATION_OBJECT",

-                                                    BUNDLE, annObjectName), iae);
-                } catch (ClassCastException ex) {
-                    throw new Fault(new org.apache.cxf.common.i18n.Message(
-                                                "COULD_NOT_CREATE_ANNOTATION_OBJECT", 
-                                                BUNDLE, annObjectName), ex);
-                }
-            }
+    private <T> T initializeAnnotationObject(String annObjectName, Class<T> type)
{
+        Object object = null;
+        try {
+            object = ClassLoaderUtils.loadClass(annObjectName, this.getClass()).newInstance();
+            return type.cast(object);
+        } catch (Throwable e) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message(
+                                            "COULD_NOT_CREATE_ANNOTATION_OBJECT", 
+                                            BUNDLE, annObjectName), e);
+        }
+    }
+    private <T> T initializeAnnotationObject(Class<T> type) {
+        Object object = null;
+        try {
+            object = type.newInstance();
+            return type.cast(object);
+        } catch (Throwable e) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message(
+                                            "COULD_NOT_CREATE_ANNOTATION_OBJECT", 
+                                            BUNDLE, type.getName()), e);
         }
-        return theAnnotationObjects;
     }
     
     @SuppressWarnings("unchecked")

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AnnotationInterceptorTest.java
Mon Jan 16 18:21:24 2012
@@ -212,10 +212,10 @@ public class AnnotationInterceptorTest e
         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")
+    @InInterceptors(classes = org.apache.cxf.jaxws.service.TestInterceptor.class)
+    @OutFaultInterceptors (classes = {org.apache.cxf.jaxws.service.TestInterceptor.class
, 
+                                      org.apache.cxf.jaxws.service.Test2Interceptor.class
})
+    @Features (classes = org.apache.cxf.jaxws.service.AnnotationFeature.class)
     public class HelloServiceImpl implements HelloService {
         public String sayHi() {
             return "HI";
@@ -290,7 +290,7 @@ public class AnnotationInterceptorTest e
     }
     
     @WebService(endpointInterface = "org.apache.cxf.jaxws.service.SayHiInterface")
-    @InInterceptors (interceptors = "org.apache.cxf.jaxws.service.Test2Interceptor")
+    @InInterceptors (classes = org.apache.cxf.jaxws.service.Test2Interceptor.class)
     public class SayHiInterfaceImpl2 implements SayHiInterface {
         public String sayHi(String s) {
             return "HI";

Modified: cxf/branches/2.5.x-fixes/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/transformation/DoubleItPortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/transformation/DoubleItPortTypeImpl.java?rev=1232094&r1=1232093&r2=1232094&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/transformation/DoubleItPortTypeImpl.java
(original)
+++ cxf/branches/2.5.x-fixes/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/transformation/DoubleItPortTypeImpl.java
Mon Jan 16 18:21:24 2012
@@ -40,7 +40,7 @@ import org.example.contract.doubleit.Dou
 @WebService(targetNamespace = "http://www.example.org/contract/DoubleIt", 
             serviceName = "DoubleItService", 
             endpointInterface = "org.example.contract.doubleit.DoubleItPortType")
-@Features(features = "org.apache.cxf.feature.LoggingFeature")              
+@Features(classes = org.apache.cxf.feature.LoggingFeature.class)              
 public class DoubleItPortTypeImpl implements DoubleItPortType {
     
     @Resource



Mime
View raw message