cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r540184 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/feature/AbstractFeature.java systests/src/test/java/org/apache/cxf/systest/clustering/Server.java
Date Mon, 21 May 2007 16:08:01 GMT
Author: eglynn
Date: Mon May 21 09:08:00 2007
New Revision: 540184

URL: http://svn.apache.org/viewvc?view=rev&rev=540184
Log:
Added AbstractFeature.getActive() convenience method.


Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/clustering/Server.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java?view=diff&rev=540184&r1=540183&r2=540184
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/feature/AbstractFeature.java Mon
May 21 09:08:00 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.feature;
 
+import java.util.List;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
@@ -47,5 +49,26 @@
     
     protected void initializeProvider(InterceptorProvider provider, Bus bus) {
         
+    }
+
+    /**
+     * Convenience method to extract a feature by type from an active list.
+     * 
+     * @param features the given feature list
+     * @param type the feature type required
+     * @return the feature of the specified type if active
+     */
+    public static <T> T getActive(List<AbstractFeature> features,
+                                  Class<T> type) {
+        T active = null;
+        if (features != null) {
+            for (AbstractFeature feature : features) {
+                if (type.isInstance(feature)) {
+                    active = type.cast(feature);
+                    break;
+                }
+            }
+        }
+        return active;
     }
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/clustering/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/clustering/Server.java?view=diff&rev=540184&r1=540183&r2=540184
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/clustering/Server.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/clustering/Server.java
Mon May 21 09:08:00 2007
@@ -65,12 +65,19 @@
                         
                         List<AbstractFeature> active = endpoint.getActiveFeatures();
                         if (!(active.size() == 1
-                              && active.get(0) instanceof WSAddressingFeature)) {
+                              && active.get(0) instanceof WSAddressingFeature)
+                              && AbstractFeature.getActive(active,
+                                                           WSAddressingFeature.class)
+                                 == active.get(0)) {
                             verified = "unexpected active features: " + active;
                         }
                     } else {
                         List<AbstractFeature> active = endpoint.getActiveFeatures();
-                        if (!(active == null || active.size() == 0)) {
+                        if (!(active == null 
+                              || active.size() == 0
+                              || AbstractFeature.getActive(active,
+                                                           WSAddressingFeature.class)
+                                 == null)) {
                             verified = "unexpected active features: " + active;
                         }                        
                     }



Mime
View raw message