cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1341877 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
Date Wed, 23 May 2012 14:44:54 GMT
Author: ay
Date: Wed May 23 14:44:54 2012
New Revision: 1341877

URL: http://svn.apache.org/viewvc?rev=1341877&view=rev
Log:
[CXF-4336] org.apache.cxf.bus.blueprint.ConfigurerImpl may get IllegalStateException

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java?rev=1341877&r1=1341876&r2=1341877&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java Wed May
23 14:44:54 2012
@@ -132,11 +132,20 @@ public class ConfigurerImpl implements C
                 m = ReflectionUtil.findMethod(container.getClass(), "getRepository");
                 Object o = ReflectionUtil.setAccessible(m).invoke(container);
                 m = ReflectionUtil.findMethod(o.getClass(), "getRecipe", String.class);
+                Object xc = o;
                 o = ReflectionUtil.setAccessible(m).invoke(o, bn);  //returns the recipe
                 if (o != null) {
                     m = ReflectionUtil.findMethod(o.getClass(), "setProperties", Object.class);
                     if (m != null) {
-                        ReflectionUtil.setAccessible(m).invoke(o, beanInstance);
+                        Method xcm = findSetExecutionContextMethod(o.getClass().getClassLoader());
+                        if (xcm != null) {
+                            Object oxc = xcm.invoke(null, xc);
+                            try {
+                                ReflectionUtil.setAccessible(m).invoke(o, beanInstance);
+                            } finally {
+                                xcm.invoke(null, oxc);
+                            }
+                        }
                     }
                 }
             }
@@ -151,6 +160,20 @@ public class ConfigurerImpl implements C
             LOG.log(Level.FINE, "Could not configure object " + bn, ex);
         }
     }
+    
+    // for Aries blueprint 0.3.1
+    private Method findSetExecutionContextMethod(ClassLoader cl) {
+        Method m = null;
+        try {
+            m = Class.forName("org.apache.aries.blueprint.di.ExecutionContext$Holder", false,
cl).
+                getDeclaredMethod("setContext", 
+                                  Class.forName("org.apache.aries.blueprint.di.ExecutionContext",
false, cl));
+        } catch (Exception e) {
+            LOG.log(Level.FINE, "Could not find the ExecutionContext$Holder.setContext method",
e);
+        }
+        return m;
+    }
+    
     private void configureWithWildCard(String bn, Object beanInstance) {
         if (!wildCardBeanDefinitions.isEmpty()) {
             Class<?> clazz = beanInstance.getClass();            



Mime
View raw message