Author: dkulp
Date: Thu May 23 15:48:19 2013
New Revision: 1485757
URL: http://svn.apache.org/r1485757
Log:
Remove some of the blueprint 0.3 hacks
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
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/BlueprintBeanLocator.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java?rev=1485757&r1=1485756&r2=1485757&view=diff
==============================================================================
---
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
(original)
+++
cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBeanLocator.java
Thu May 23 15:48:19 2013
@@ -19,7 +19,6 @@
package org.apache.cxf.bus.blueprint;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -29,9 +28,9 @@ import java.util.Set;
import java.util.logging.Logger;
import org.apache.aries.blueprint.ExtendedBeanMetadata;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
import org.apache.cxf.bus.extension.ExtensionManagerImpl;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.configuration.ConfiguredBeanLocator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -69,11 +68,10 @@ public class BlueprintBeanLocator implem
if (bm instanceof ExtendedBeanMetadata) {
cls = ((ExtendedBeanMetadata)bm).getRuntimeClass();
}
- if (cls == null) {
+ if (cls == null && container instanceof
ExtendedBlueprintContainer) {
try {
- Method m = ReflectionUtil.findMethod(container.getClass(),
"loadClass", String.class);
- cls =
(Class<?>)ReflectionUtil.setAccessible(m).invoke(container, bm.getClassName());
- } catch (Exception e) {
+ cls =
((ExtendedBlueprintContainer)container).loadClass(bm.getClassName());
+ } catch (ClassNotFoundException cnfe) {
//ignore
}
}
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=1485757&r1=1485756&r2=1485757&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
Thu May 23 15:48:19 2013
@@ -19,7 +19,6 @@
package org.apache.cxf.bus.blueprint;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
@@ -30,8 +29,8 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.configuration.Configurable;
import org.apache.cxf.configuration.Configurer;
import org.osgi.service.blueprint.container.BlueprintContainer;
@@ -111,67 +110,17 @@ public class ConfigurerImpl implements C
configureWithWildCard(bn, beanInstance);
}
-
- Method m = ReflectionUtil.findMethod(container.getClass(),
"injectBeanInstance",
- BeanMetadata.class, Object.class);
- try {
- if (m != null) {
- //Aries blueprint 0.4.1+
- ComponentMetadata cm = null;
- try {
- cm = container.getComponentMetadata(bn);
- } catch (NoSuchComponentException nsce) {
- cm = null;
- }
- if (cm instanceof BeanMetadata) {
- ReflectionUtil.setAccessible(m);
- m.invoke(container, cm, beanInstance);
- }
- } else {
- //Aries blueprint 0.3.x
- 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) {
- 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);
- }
- }
- }
- }
+ if (container instanceof ExtendedBlueprintContainer) {
+ ComponentMetadata cm = null;
+ try {
+ cm = container.getComponentMetadata(bn);
+ } catch (NoSuchComponentException nsce) {
+ cm = null;
}
- } catch (InvocationTargetException ite) {
- Throwable t = ite.getCause();
- if (t instanceof RuntimeException) {
- throw (RuntimeException)t;
- } else {
- throw new RuntimeException(t);
+ if (cm instanceof BeanMetadata) {
+
((ExtendedBlueprintContainer)container).injectBeanInstance((BeanMetadata)cm,
beanInstance);
}
- } catch (Exception ex) {
- 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) {