cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r600799 - in /incubator/cxf/trunk/rt/core/src: main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java test/java/org/apache/cxf/bus/extension/MySetterService.java
Date Tue, 04 Dec 2007 06:17:12 GMT
Author: ningjiang
Date: Mon Dec  3 22:17:10 2007
New Revision: 600799

URL: http://svn.apache.org/viewvc?rev=600799&view=rev
Log:
Fixed the extensionManagerTest testActivateViaNS

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=600799&r1=600798&r2=600799&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Mon Dec  3 22:17:10 2007
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -40,6 +41,7 @@
 
     public static final String EXTENSIONMANAGER_PROPERTY_NAME = "extensionManager";
     public static final String ACTIVATION_NAMESPACES_PROPERTY_NAME = "activationNamespaces";
+    public static final String ACTIVATION_NAMESPACES_SETTER_METHOD_NAME = "setActivationNamespaces";
     public static final String BUS_EXTENSION_RESOURCE = "META-INF/bus-extensions.xml";
     
     private final ClassLoader loader;
@@ -153,9 +155,13 @@
             resourceManager.addResourceResolver(namespacesResolver);
         }
         
+        // Since we need to support spring2.5 by removing @Resource("activationNamespaces")
+        // Now we call the setActivationNamespaces method directly here
+        invockSetterActivationNSMethod(obj, e.getNamespaces());
+        
         ResourceInjector injector = new ResourceInjector(resourceManager);
         
-        try {
+        try {            
             injector.inject(obj);
             injector.construct(obj);
         } finally {
@@ -195,6 +201,28 @@
         return null;
     }
     
-    
+    private void invockSetterActivationNSMethod(Object target, Object value) {
+        Class clazz = target.getClass();
+        String methodName = ACTIVATION_NAMESPACES_SETTER_METHOD_NAME;
+        while (clazz != Object.class) {
+            Method[] methods = clazz.getMethods();
+            for (int i = 0; i < methods.length; i++) {
+                Method method = methods[i];
+                Class params[] = method.getParameterTypes();
+                if (method.getName().equals(methodName) && params.length == 1) {
+                    Class paramType = params[0];
+                    if (paramType.isInstance(value)) {
+                        try {
+                            method.invoke(target, new Object[] {value});
+                        } catch (Exception e) {
+                            // do nothing here
+                        }
+                        return;
+                    }
+                }
+            }
+            clazz = clazz.getSuperclass();
+        }        
+    }
 
 }

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java?rev=600799&r1=600798&r2=600799&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/ExtensionManagerTest.java
Mon Dec  3 22:17:10 2007
@@ -85,7 +85,7 @@
     public void verifyActivateViaNS(String extensionClass, String ns) {        
         
         Extension e = new Extension();
-        e.setClassname(MyResourceService.class.getName());       
+        e.setClassname(extensionClass);       
         e.getNamespaces().add(ns);
         e.setDeferred(true);
         manager.processExtension(e);
@@ -97,7 +97,7 @@
         
         // second activation should be a no-op
         
-        MyService first = myService;
+        MyService first = myService;        
         manager.activateViaNS(ns);
         assertSame(first, myService);
         myService = null;

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java?rev=600799&r1=600798&r2=600799&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/bus/extension/MySetterService.java
Mon Dec  3 22:17:10 2007
@@ -34,6 +34,7 @@
     public MySetterService() {
     }
     
+    
     public void setActivationNamespaces(Collection<String> avNamespaces) {
         activationNamespaces = avNamespaces;
     }



Mime
View raw message