Author: ay
Date: Wed May 23 14:52:05 2012
New Revision: 1341880

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

........
  r1341877 | ay | 2012-05-23 16:44:54 +0200 (Wed, 23 May 2012) | 1 line
  
  [CXF-4336] org.apache.cxf.bus.blueprint.ConfigurerImpl may get 
IllegalStateException
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java

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

Modified: 
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
URL: 
http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java?rev=1341880&r1=1341879&r2=1341880&view=diff
==============================================================================
--- 
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
 (original)
+++ 
cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/blueprint/ConfigurerImpl.java
 Wed May 23 14:52:05 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();            


Reply via email to