incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1001515 - in /incubator/aries/trunk/blueprint: ./ blueprint-annotation-itest/ blueprint-bundle/ blueprint-core/ blueprint-core/src/main/java/org/apache/aries/blueprint/container/ blueprint-core/src/main/java/org/apache/aries/blueprint/prox...
Date Sun, 26 Sep 2010 21:05:53 GMT
Author: gnodet
Date: Sun Sep 26 21:05:52 2010
New Revision: 1001515

URL: http://svn.apache.org/viewvc?rev=1001515&view=rev
Log:
[ARIES-427] get rid of cglib

Removed:
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/CgLibInterceptorWrapper.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/WrapperedObject.java
    incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AbstractServiceReferenceTest.java
    incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithCgLibTest.java
Modified:
    incubator/aries/trunk/blueprint/blueprint-annotation-itest/pom.xml
    incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
    incubator/aries/trunk/blueprint/blueprint-core/pom.xml
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/AsmInterceptorWrapper.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java
    incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
    incubator/aries/trunk/blueprint/blueprint-itests/pom.xml
    incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
    incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java
    incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
    incubator/aries/trunk/blueprint/blueprint-sample/src/main/java/org/apache/aries/blueprint/sample/Foo.java
    incubator/aries/trunk/blueprint/pom.xml

Modified: incubator/aries/trunk/blueprint/blueprint-annotation-itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-annotation-itest/pom.xml?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-annotation-itest/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-annotation-itest/pom.xml Sun Sep 26 21:05:52
2010
@@ -128,11 +128,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>asm</groupId>
             <artifactId>asm-all</artifactId>
             <scope>test</scope>

Modified: incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml Sun Sep 26 21:05:52 2010
@@ -40,10 +40,9 @@
         <aries.osgi.import>
             !org.apache.aries.blueprint*,
             !org.osgi.service.blueprint*,
+            !org.objectweb.asm*;version="[3.1,4)";resolution:=optional,
             org.osgi.service.event*;resolution:=optional,
             org.osgi.service.framework;resolution:=optional,
-            net.sf.cglib*;resolution:=optional,
-            org.objectweb.asm*;version="[3.1,4)";resolution:=optional,
             org.osgi.service.cm;version="[1.2.0,2.0.0)",
             org.apache.aries.blueprint.annotation.service;resolution:=optional,
             org.apache.aries.quiesce.manager;version="[0.2,1.0)";resolution:=optional,
@@ -59,6 +58,8 @@
         </aries.osgi.export>
         <aries.osgi.private.pkg>
             org.apache.aries.util.tracker,
+            org.objectweb.asm,
+            org.objectweb.asm.commons,
             OSGI-INF*
         </aries.osgi.private.pkg>
         <aries.osgi.export.service>
@@ -90,11 +91,6 @@
             <artifactId>org.apache.aries.blueprint.cm</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
             <groupId>asm</groupId>
             <artifactId>asm-all</artifactId>
             <optional>true</optional>

Modified: incubator/aries/trunk/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/pom.xml?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-core/pom.xml Sun Sep 26 21:05:52 2010
@@ -85,11 +85,6 @@
           <scope>provided</scope>
       </dependency>
       <dependency>
-          <groupId>org.apache.servicemix.bundles</groupId>
-          <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-          <optional>true</optional>
-      </dependency>
-      <dependency>
           <groupId>org.slf4j</groupId>
           <artifactId>slf4j-api</artifactId>
       </dependency>

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
Sun Sep 26 21:05:52 2010
@@ -37,9 +37,6 @@ import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import net.sf.cglib.proxy.Dispatcher;
-import net.sf.cglib.proxy.Enhancer;
-
 import org.apache.aries.blueprint.BlueprintConstants;
 import org.apache.aries.blueprint.ExtendedBlueprintContainer;
 import org.apache.aries.blueprint.ExtendedReferenceListMetadata;
@@ -47,6 +44,7 @@ import org.apache.aries.blueprint.Extend
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.CollectionRecipe;
 import org.apache.aries.blueprint.di.Recipe;
+import org.apache.aries.blueprint.proxy.AsmInterceptorWrapper;
 import org.apache.aries.blueprint.utils.BundleDelegatingClassLoader;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.osgi.framework.Bundle;
@@ -327,10 +325,10 @@ public abstract class AbstractServiceRef
                 }
             }
             try {
-                // Try load load a cglib class (to make sure it's actually available
-                // then create the cglib factory
-                getClass().getClassLoader().loadClass("net.sf.cglib.proxy.Enhancer");
-                proxyFactory = new CgLibProxyFactory();
+                // Try load load a asm class (to make sure it's actually available
+                // then create the asm factory
+                getClass().getClassLoader().loadClass("org.objectweb.asm.ClassVisitor");
+                proxyFactory = new AsmProxyFactory();
             } catch (Throwable t) {
                 if (proxyClass) {
                     throw new ComponentDefinitionException("Class proxying has been enabled
but cglib can not be used", t);
@@ -639,38 +637,10 @@ public abstract class AbstractServiceRef
 
     }
 
-    public static class CgLibProxyFactory implements ProxyFactory {
+    public static class AsmProxyFactory implements ProxyFactory {
 
         public Object createProxy(final ClassLoader classLoader, final Class[] classes, final
Callable<Object> dispatcher) {
-            Enhancer e = new Enhancer();
-            e.setClassLoader(classLoader);
-            e.setSuperclass(getTargetClass(classes));
-            e.setInterfaces(getInterfaces(classes));
-            e.setInterceptDuringConstruction(false);
-            e.setCallback(new Dispatcher() {
-                public Object loadObject() throws Exception {
-                    return dispatcher.call();
-                }
-            });
-            e.setUseFactory(false);
-            return e.create();
-        }
-
-        protected Class<?> getTargetClass(Class<?>[] interfaceNames) {
-            // Only allow class proxying if specifically asked to
-            Class<?> root = Object.class;
-            for (Class<?> clazz : interfaceNames) {
-                if (!clazz.isInterface()) {
-                    if (root.isAssignableFrom(clazz)) {
-                        root = clazz;
-                    } else if (clazz.isAssignableFrom(root)) {
-                        //nothing to do, root is correct
-                    } else {
-                        throw new ComponentDefinitionException("Classes " + root.getClass().getName()
+ " and " + clazz.getName() + " are not in the same hierarchy");
-                    }
-                }
-            }
-            return root;
+            return AsmInterceptorWrapper.createProxyObject(classLoader, null, null, dispatcher,
classes);
         }
 
     }

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
Sun Sep 26 21:05:52 2010
@@ -32,6 +32,7 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.apache.aries.blueprint.BeanProcessor;
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
@@ -40,7 +41,6 @@ import org.apache.aries.blueprint.Interc
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.Recipe;
 import org.apache.aries.blueprint.proxy.AsmInterceptorWrapper;
-import org.apache.aries.blueprint.proxy.CgLibInterceptorWrapper;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.apache.aries.blueprint.utils.ReflectionUtils.PropertyDescriptor;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -676,42 +676,22 @@ public class BeanRecipe extends Abstract
                 .getComponentDefinitionRegistry();
         List<Interceptor> interceptors = reg.getInterceptors(interceptorLookupKey);
         if (interceptors != null && interceptors.size() > 0) {
-            boolean asmAvailable = false;
             try {
                 // Try load load an asm class (to make sure it's actually
                 // available)
                 getClass().getClassLoader().loadClass(
                         "org.objectweb.asm.ClassVisitor");
                 LOGGER.debug("asm available for interceptors");
-                asmAvailable = true;
             } catch (Throwable t) {
-                try {
-                    // Try load load a cglib class (to make sure it's actually
-                    // available)
-                    getClass().getClassLoader().loadClass(
-                            "net.sf.cglib.proxy.Enhancer");
-                } catch (Throwable u) {
-                    throw new ComponentDefinitionException(
-                            "Interceptors have been configured but neither asm nor cglib
are available",
-                            u);
-                }
-            }
-            if (asmAvailable) {
-                // if asm is available we can proxy the original object with the
-                // AsmInterceptorWrapper
-                intercepted = AsmInterceptorWrapper.createProxyObject(original
-                        .getClass().getClassLoader(), interceptorLookupKey, interceptors,
-                        original, original.getClass());
-            } else {
-                LOGGER.debug("cglib available for interceptors");
-                // otherwise we're using cglib and need to use the interfaces
-                // with the CgLibInterceptorWrapper
-                intercepted = CgLibInterceptorWrapper.createProxyObject(
-                        original.getClass().getClassLoader(), interceptorLookupKey,
-                        interceptors, original, original.getClass()
-                                .getInterfaces());
-            }
-
+                throw new ComponentDefinitionException(
+                        "Interceptors have been configured but asm is not available",
+                        t);
+            }
+            // if asm is available we can proxy the original object with the
+            // AsmInterceptorWrapper
+            intercepted = AsmInterceptorWrapper.createProxyObject(original
+                    .getClass().getClassLoader(), interceptorLookupKey, interceptors,
+                    AsmInterceptorWrapper.passThrough(original), original.getClass());
         } else {
             intercepted = original;
         }

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
Sun Sep 26 21:05:52 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.aries.blueprint.container;
 
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.ArrayList;

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
Sun Sep 26 21:05:52 2010
@@ -22,9 +22,11 @@ import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -38,7 +40,6 @@ import org.apache.aries.blueprint.di.Map
 import org.apache.aries.blueprint.di.Recipe;
 import org.apache.aries.blueprint.di.Repository;
 import org.apache.aries.blueprint.proxy.AsmInterceptorWrapper;
-import org.apache.aries.blueprint.proxy.CgLibInterceptorWrapper;
 import org.apache.aries.blueprint.utils.JavaUtils;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.osgi.framework.Bundle;
@@ -421,9 +422,7 @@ public class ServiceRecipe extends Abstr
             Object original = ServiceRecipe.this.getService(bundle,
                     registration);
             LOGGER.debug(LOG_ENTRY, "getService", original);
-            Object intercepted = null;
-            boolean asmAvailable = false;
-            boolean cglibAvailable = false;
+            Object intercepted;
 
             if (interceptor == null) {
                 interceptor = new QuiesceInterceptor(serviceRecipe);
@@ -438,59 +437,38 @@ public class ServiceRecipe extends Abstr
                 getClass().getClassLoader().loadClass(
                         "org.objectweb.asm.ClassVisitor");
                 LOGGER.debug("asm available for interceptors");
-                asmAvailable = true;
             } catch (Throwable t) {
-                try {
-                    // Try load load a cglib class (to make sure it's actually
-                    // available)
-                    getClass().getClassLoader().loadClass(
-                            "net.sf.cglib.proxy.Enhancer");
-                    cglibAvailable = true;
-                } catch (Throwable u) {
-                    LOGGER
-                            .info("A problem occurred trying to create a proxy object. Returning
the original object instead.");
-                    LOGGER.debug(LOG_EXIT, "getService", original);
-                    return original;
-                }
+                LOGGER
+                        .info("A problem occurred trying to create a proxy object. Returning
the original object instead.");
+                LOGGER.debug(LOG_EXIT, "getService", original);
+                return original;
             }
 
             try {
-                if (asmAvailable) {
-                    List<String> interfaces = sm.getInterfaces();
-
-                    // check for the case where interfaces is null or empty
-                    if (interfaces == null || interfaces.isEmpty()) {
-                        intercepted = AsmInterceptorWrapper.createProxyObject(
-                                original.getClass().getClassLoader(), cm,
-                                interceptors, original, original.getClass());
-                        LOGGER.debug(LOG_EXIT, "getService", intercepted);
-                        return intercepted;
-                    }
-                    Class[] classesToProxy = new Class[interfaces.size()];
-                    for (int i = 0; i < interfaces.size(); i++) {
-                        classesToProxy[i] = Class.forName(interfaces.get(i),
-                                true, original.getClass().getClassLoader());
-                    }
+                Set<String> interfaces = getClasses();
 
-                    // if asm is available we can proxy the original object with
-                    // the
-                    // AsmInterceptorWrapper
+                // check for the case where interfaces is null or empty
+                if (interfaces == null || interfaces.isEmpty()) {
                     intercepted = AsmInterceptorWrapper.createProxyObject(
                             original.getClass().getClassLoader(), cm,
-                            interceptors, original, classesToProxy);
-                } else if (cglibAvailable) {
-                    LOGGER.debug("cglib available for interceptors");
-                    // otherwise we're using cglib and need to use the
-                    // interfaces
-                    // with the CgLibInterceptorWrapper
-                    intercepted = CgLibInterceptorWrapper.createProxyObject(
-                            original.getClass().getClassLoader(), cm,
-                            interceptors, original, original.getClass()
-                                    .getInterfaces());
-                } else {
-                    LOGGER.debug(LOG_EXIT, "getService", original);
-                    return original;
+                            interceptors, AsmInterceptorWrapper.passThrough(original),
+                            original.getClass());
+                    LOGGER.debug(LOG_EXIT, "getService", intercepted);
+                    return intercepted;
+                }
+                Class[] classesToProxy = new Class[interfaces.size()];
+                Iterator<String> it = interfaces.iterator();
+                for (int i = 0; i < interfaces.size(); i++) {
+                    classesToProxy[i] = Class.forName(it.next(),
+                            true, original.getClass().getClassLoader());
                 }
+
+                // if asm is available we can proxy the original object with
+                // the AsmInterceptorWrapper
+                intercepted = AsmInterceptorWrapper.createProxyObject(
+                        original.getClass().getClassLoader(), cm,
+                        interceptors, AsmInterceptorWrapper.passThrough(original),
+                        classesToProxy);
             } catch (Throwable u) {
                 LOGGER
                         .info("A problem occurred trying to create a proxy object. Returning
the original object instead.");

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/AsmInterceptorWrapper.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/AsmInterceptorWrapper.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/AsmInterceptorWrapper.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/AsmInterceptorWrapper.java
Sun Sep 26 21:05:52 2010
@@ -24,6 +24,7 @@ import java.lang.reflect.Proxy;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.Callable;
 
 import org.apache.aries.blueprint.Interceptor;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -39,7 +40,7 @@ public class AsmInterceptorWrapper
   final static String LOG_EXCEPTION = "Caught exception";
 
   public static Object createProxyObject(ClassLoader cl, ComponentMetadata cm,
-      List<Interceptor> interceptors, Object delegate, Class<?>... classesToProxy)
+      List<Interceptor> interceptors, Callable<Object> delegate, Class<?>...
classesToProxy)
   {
 
     LOGGER.debug(LOG_ENTRY, "createProxyObject", new Object[] { cl, cm, interceptors, delegate,
@@ -148,13 +149,13 @@ public class AsmInterceptorWrapper
       throw new ComponentDefinitionException("Unable to proxy bean for interceptors: " +
e);
     }
 
-    LOGGER.debug(LOG_EXIT, "createProxyObject", proxyObject);
+//    LOGGER.debug(LOG_EXIT, "createProxyObject", proxyObject);
 
     return proxyObject;
   }
 
   private static Object createSubclassProxy(Class<?> classToProxy, ComponentMetadata
cm,
-      List<Interceptor> interceptors, Object delegate) throws UnableToProxyException
+      List<Interceptor> interceptors, Callable<Object> delegate) throws UnableToProxyException
   {
     LOGGER.debug(LOG_ENTRY, "createSubclassProxy", new Object[] { classToProxy, cm, interceptors,
         delegate });
@@ -163,8 +164,8 @@ public class AsmInterceptorWrapper
       Object proxyObject = ProxySubclassGenerator.newProxySubclassInstance(classToProxy,
           new Collaborator(cm, interceptors, delegate));
 
-      LOGGER.debug("Generated subclass proxy object: {}", proxyObject);
-      LOGGER.debug(LOG_EXIT, "createSubclassProxy", proxyObject);
+//      LOGGER.debug("Generated subclass proxy object: {}", proxyObject);
+//      LOGGER.debug(LOG_EXIT, "createSubclassProxy", proxyObject);
       return proxyObject;
     } catch (UnableToProxyException e) {
       LOGGER.debug(LOG_EXCEPTION, e);
@@ -182,7 +183,7 @@ public class AsmInterceptorWrapper
     return isProxyObject;
   }
 
-  static Object unwrapObject(Object o)
+  static Object unwrapObject(Object o) throws Exception
   {
     LOGGER.debug(LOG_ENTRY, "unwrapObject", new Object[] { o });
     InvocationHandler ih = null;
@@ -193,10 +194,23 @@ public class AsmInterceptorWrapper
       ih = Proxy.getInvocationHandler(o);
     }
     if (ih instanceof Collaborator) {
-      unwrappedObject = ((Collaborator) ih).object;
+      unwrappedObject = ((Collaborator) ih).object.call();
     }
-    LOGGER.debug(LOG_EXIT, "unwrapObject", unwrappedObject);
+//    LOGGER.debug(LOG_EXIT, "unwrapObject", unwrappedObject);
     return unwrappedObject;
   }
 
+    public static <T> Callable<T> passThrough(T t) {
+        return new PassThrough<T>(t);
+    }
+
+    public static class PassThrough<T> implements Callable<T> {
+        private final T t;
+        public PassThrough(T t) {
+            this.t = t;
+        }
+        public T call() throws Exception {
+            return t;
+        }
+    }
 }

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/proxy/Collaborator.java
Sun Sep 26 21:05:52 2010
@@ -24,6 +24,7 @@ import java.lang.reflect.InvocationTarge
 import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Stack;
+import java.util.concurrent.Callable;
 
 import org.apache.aries.blueprint.Interceptor;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
@@ -44,14 +45,14 @@ class Collaborator implements Invocation
 
     /** The invocation handler to call */
     final InvocationHandler delegate;
-    final Object object;
+    final Callable<?> object;
 
     private transient List<Interceptor> interceptors = null;
     private transient ComponentMetadata cm = null;
     private transient boolean sorted = false;
 
     Collaborator(ComponentMetadata cm, List<Interceptor> interceptors,
-            final Object delegateObj) {
+            final Callable<?> delegateObj) {
         this.cm = cm;
         this.object = delegateObj;
         this.delegate = new InvocationHandler() {
@@ -63,7 +64,7 @@ class Collaborator implements Invocation
                     throws Throwable {
                 Object result;
                 try {
-                    result = method.invoke(object, args);
+                    result = method.invoke(object.call(), args);
                 } catch (InvocationTargetException ite) {
                     // We are invisible, so unwrap and throw the cause as
                     // though we called the method directly.
@@ -117,20 +118,10 @@ class Collaborator implements Invocation
             throws Throwable {
         Object toReturn = null;
         
-        // Added method to unwrap from the collaborator.
-        if (method.getName().equals("unwrapObject")
-                && method.getDeclaringClass() == WrapperedObject.class) {
-            toReturn = object;
-        } else
         // Unwrap calls for equals
         if (method.getName().equals("equals")
                 && method.getDeclaringClass() == Object.class) {
-            // replace the wrapper with the unwrapped object, to
-            // enable object identity etc to function.
-            if (args[0] instanceof WrapperedObject) {
-                // unwrap in the WrapperedObject case
-                args[0] = ((WrapperedObject) args[0]).unwrapObject();
-            } else if (AsmInterceptorWrapper.isProxyClass(args[0].getClass())) {
+            if (AsmInterceptorWrapper.isProxyClass(args[0].getClass())) {
                 // unwrap in the asm case
                 args[0] = AsmInterceptorWrapper.unwrapObject(args[0]);
             }
@@ -282,4 +273,5 @@ class Collaborator implements Invocation
         }
 
     }
+
 }
\ No newline at end of file

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
Sun Sep 26 21:05:52 2010
@@ -319,11 +319,11 @@ public class ProxySubclassGeneratorTest
   public void testObjectEquality() throws Exception
   {
     Object delegate = TEST_CLASS.newInstance();
-    InvocationHandler collaborator = new Collaborator(null, null, delegate);
+    InvocationHandler collaborator = new Collaborator(null, null, AsmInterceptorWrapper.passThrough(delegate));
     Object o = ProxySubclassGenerator.newProxySubclassInstance(TEST_CLASS, collaborator);
     //Calling equals on the proxy with an arg of the unwrapped object should be true
     assertTrue("The proxy object should be equal to its delegate",o.equals(delegate));
-    InvocationHandler collaborator2 = new Collaborator(null, null, delegate);
+    InvocationHandler collaborator2 = new Collaborator(null, null, AsmInterceptorWrapper.passThrough(delegate));
     Object o2 = ProxySubclassGenerator.newProxySubclassInstance(TEST_CLASS, collaborator2);
     //The proxy of a delegate should equal another proxy of the same delegate
     assertTrue("The proxy object should be equal to another proxy instance of the same delegate",
o2.equals(o));
@@ -341,7 +341,7 @@ public class ProxySubclassGeneratorTest
   @Test
   public void testFinalizeNotCalled() throws Exception {
       ProxyTestOverridesFinalize testObj = new ProxyTestOverridesFinalize();
-      InvocationHandler ih = new Collaborator(null, null, testObj);
+      InvocationHandler ih = new Collaborator(null, null, AsmInterceptorWrapper.passThrough(testObj));
       Object o = ProxySubclassGenerator.newProxySubclassInstance(ProxyTestOverridesFinalize.class,
ih);
       
       Method m = o.getClass().getDeclaredMethod("finalize");

Modified: incubator/aries/trunk/blueprint/blueprint-itests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/pom.xml?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/pom.xml Sun Sep 26 21:05:52 2010
@@ -122,11 +122,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.servicemix.bundles</groupId>
-            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>asm</groupId>
             <artifactId>asm-all</artifactId>
             <scope>test</scope>

Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
Sun Sep 26 21:05:52 2010
@@ -259,7 +259,7 @@ public abstract class AbstractIntegratio
 
         obj = getOsgiService(bc == null ? bundleContext : bc, Foo.class, null, 5000);
         assertNotNull(obj);
-        assertSame(foo, obj);
+        assertEquals(obj, foo);
         
         obj = blueprintContainer.getComponentInstance("accountOne");
         assertNotNull(obj);

Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/MultiBundleWithAsmTest.java
Sun Sep 26 21:05:52 2010
@@ -50,7 +50,6 @@ public class MultiBundleWithAsmTest exte
 
             // Bundles
             mavenBundle("org.apache.aries", "org.apache.aries.util"),
-            mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"),
             mavenBundle("asm","asm-all"),
             mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
             mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.testbundlea").noStart(),

Modified: incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
Sun Sep 26 21:05:52 2010
@@ -110,7 +110,6 @@ public class QuiesceBlueprintTest extend
 
         // Bundles
         mavenBundle("asm","asm-all"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"),
         
         mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api"),
         mavenBundle("org.apache.aries", "org.apache.aries.util"),

Modified: incubator/aries/trunk/blueprint/blueprint-sample/src/main/java/org/apache/aries/blueprint/sample/Foo.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-sample/src/main/java/org/apache/aries/blueprint/sample/Foo.java?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-sample/src/main/java/org/apache/aries/blueprint/sample/Foo.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-sample/src/main/java/org/apache/aries/blueprint/sample/Foo.java
Sun Sep 26 21:05:52 2010
@@ -102,5 +102,6 @@ public class Foo implements Serializable
     public Map<String, Object> getProps() {
         return props;
     }
+
 }
 

Modified: incubator/aries/trunk/blueprint/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/pom.xml?rev=1001515&r1=1001514&r2=1001515&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/pom.xml (original)
+++ incubator/aries/trunk/blueprint/pom.xml Sun Sep 26 21:05:52 2010
@@ -106,13 +106,6 @@
                 <artifactId>org.apache.aries.util</artifactId>
                 <version>0.3-incubating-SNAPSHOT</version> 
             </dependency>
-            <!-- Use an OSGi enabled cglib version, so that BND can find the version information
-                 and we can use it in integration tests -->
-            <dependency>
-                <groupId>org.apache.servicemix.bundles</groupId>
-                <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
-                <version>2.1_3_4</version>
-            </dependency>
             <!-- TODO: We need felix 2.0.0 which is not supported by pax exam yet,
                  so tests are only enabled on equinox for now
             <dependency>



Mime
View raw message