You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2012/02/03 15:56:59 UTC

svn commit: r1240203 - in /aries/trunk/blueprint/blueprint-core/src: main/java/org/apache/aries/blueprint/container/ main/java/org/apache/aries/blueprint/di/ test/java/org/apache/aries/blueprint/ test/java/org/apache/aries/blueprint/container/ test/jav...

Author: timothyjward
Date: Fri Feb  3 14:56:58 2012
New Revision: 1240203

URL: http://svn.apache.org/viewvc?rev=1240203&view=rev
Log:
ARIES-703: Proxy as few bean classes as possible to improve support when using the JdkProxyManager (also make better use of ARIES-821 where available)

Modified:
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AggregateConverter.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintRepository.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/RefRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/Repository.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java
    aries/trunk/blueprint/blueprint-core/src/test/resources/test-wiring.xml

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AggregateConverter.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AggregateConverter.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AggregateConverter.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AggregateConverter.java Fri Feb  3 14:56:58 2012
@@ -42,6 +42,7 @@ import java.math.BigInteger;
 import java.math.BigDecimal;
 
 import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.apache.aries.blueprint.container.BeanRecipe.UnwrapperedBeanHolder;
 import org.apache.aries.blueprint.di.CollectionRecipe;
 import org.apache.aries.blueprint.di.MapRecipe;
 import org.apache.aries.blueprint.utils.ReflectionUtils;
@@ -99,22 +100,25 @@ public class AggregateConverter implemen
         converters.remove(converter);
     }
 
-    public boolean canConvert(final Object fromValue, final ReifiedType toType) {
+    public boolean canConvert(Object fromValue, final ReifiedType toType) {
         if (fromValue == null) {
             return true;
+        } else if (fromValue instanceof UnwrapperedBeanHolder) {
+        	fromValue = ((UnwrapperedBeanHolder) fromValue).unwrapperedBean;
         }
         if (isAssignable(fromValue, toType)) {
             return true;
         }
         
+        final Object toTest = fromValue;
         boolean canConvert = false;
         AccessControlContext acc = blueprintContainer.getAccessControlContext();
         if (acc == null) {
-            canConvert = canConvertWithConverters(fromValue, toType);
+            canConvert = canConvertWithConverters(toTest, toType);
         } else {
             canConvert = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                 public Boolean run() {
-                    return canConvertWithConverters(fromValue, toType);
+                    return canConvertWithConverters(toTest, toType);
                 }            
             }, acc);
         }
@@ -124,14 +128,14 @@ public class AggregateConverter implemen
         
         // TODO implement better logic ?!
         try {
-            convert(fromValue, toType);
+            convert(toTest, toType);
             return true;
         } catch (Exception e) {
             return false;
         }
     }
 
-    public Object convert(final Object fromValue, final ReifiedType type) throws Exception {
+    public Object convert(Object fromValue, final ReifiedType type) throws Exception {
         // Discard null values
         if (fromValue == null) {
             return null;
@@ -139,11 +143,19 @@ public class AggregateConverter implemen
         // First convert service proxies
         if (fromValue instanceof Convertible) {
             return ((Convertible) fromValue).convert(type);
-        }
-        // If the object is an instance of the type, just return it
-        if (isAssignable(fromValue, type)) {
+        } else if (fromValue instanceof UnwrapperedBeanHolder) {
+        	UnwrapperedBeanHolder holder = (UnwrapperedBeanHolder) fromValue;
+        	if (isAssignable(holder.unwrapperedBean, type)) {
+                return BeanRecipe.wrap(holder, type.getRawClass());
+            } else {
+            	fromValue = BeanRecipe.wrap(holder, Object.class);
+            }
+        } else if (isAssignable(fromValue, type)) {
+        	 // If the object is an instance of the type, just return it
             return fromValue;
         }
+        
+        final Object finalFromValue = fromValue;
         ConversionResult result = null;
         AccessControlContext acc = blueprintContainer.getAccessControlContext();
         if (acc == null) {
@@ -151,7 +163,7 @@ public class AggregateConverter implemen
         } else {
             result = AccessController.doPrivileged(new PrivilegedExceptionAction<ConversionResult>() {
                 public ConversionResult run() throws Exception {
-                    return convertWithConverters(fromValue, type);
+                    return convertWithConverters(finalFromValue, type);
                 }            
             }, acc);
         }

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BeanRecipe.java Fri Feb  3 14:56:58 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.aries.blueprint.container;
 
+import static org.apache.aries.blueprint.utils.ReflectionUtils.getRealCause;
+
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -55,14 +57,22 @@ import org.osgi.service.blueprint.reflec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.aries.blueprint.utils.ReflectionUtils.getRealCause;
-
 /**
  * A <code>Recipe</code> to create POJOs.
  *
  * @version $Rev$, $Date$
  */
 public class BeanRecipe extends AbstractRecipe {
+	
+	static class UnwrapperedBeanHolder {
+		final Object unwrapperedBean;
+		final BeanRecipe recipe;
+		
+		public UnwrapperedBeanHolder(Object unwrapperedBean, BeanRecipe recipe) {
+			this.unwrapperedBean = unwrapperedBean;
+			this.recipe = recipe;
+		}
+	}
 
     public class VoidableCallable implements Callable<Object>, Voidable {
 
@@ -272,6 +282,8 @@ public class BeanRecipe extends Abstract
                 } catch (Exception e) {
                     throw new ComponentDefinitionException("Error when instantiating bean " + getName() + " of class " + getType(), getRealCause(e));
                 }
+            } else if (factoryObj instanceof UnwrapperedBeanHolder) {
+            	factoryObj = wrap((UnwrapperedBeanHolder) factoryObj, Object.class);
             }
             
             // Map of matching methods
@@ -362,12 +374,18 @@ public class BeanRecipe extends Abstract
                         found = false;
                         break;
                     }
-                    if (!AggregateConverter.isAssignable(args.get(i), argType)) {
+                    //If the arg is an Unwrappered bean then we need to do the assignment check against the
+                    //unwrappered bean itself.
+                    Object arg = args.get(i);
+                    Object argToTest = arg;
+                    if(arg instanceof UnwrapperedBeanHolder)
+                    	argToTest = ((UnwrapperedBeanHolder)arg).unwrapperedBean;
+                    if (!AggregateConverter.isAssignable(argToTest, argType)) {
                         found = false;
                         break;
                     }
                     try {
-                        match.add(convert(args.get(i), mth.getGenericParameterTypes()[i]));
+                        match.add(convert(arg, mth.getGenericParameterTypes()[i]));
                     } catch (Throwable t) {
                         found = false;
                         break;
@@ -503,12 +521,18 @@ public class BeanRecipe extends Abstract
                         found = false;
                         break;
                     }
-                    if (!AggregateConverter.isAssignable(args.get(i), argType)) {
+                    //If the arg is an Unwrappered bean then we need to do the assignment check against the
+                    //unwrappered bean itself.
+                    Object arg = args.get(i);
+                    Object argToTest = arg;
+                    if(arg instanceof UnwrapperedBeanHolder)
+                    	argToTest = ((UnwrapperedBeanHolder)arg).unwrapperedBean;
+                    if (!AggregateConverter.isAssignable(argToTest, argType)) {
                         found = false;
                         break;
                     }
                     try {
-                        match.add(convert(args.get(i), cns.getGenericParameterTypes()[i]));
+                        match.add(convert(arg, cns.getGenericParameterTypes()[i]));
                     } catch (Throwable t) {
                         found = false;
                         break;
@@ -719,26 +743,28 @@ public class BeanRecipe extends Abstract
         return obj;
     }    
     
-    private Object addInterceptors(final Object original)
+    private Object addInterceptors(final Object original, Collection<Class<?>> requiredInterfaces)
             throws ComponentDefinitionException {
 
         Object intercepted = null;
+        if(requiredInterfaces.isEmpty())
+        	requiredInterfaces.add(original.getClass());
+        
         ComponentDefinitionRegistry reg = blueprintContainer
                 .getComponentDefinitionRegistry();
         List<Interceptor> interceptors = reg.getInterceptors(interceptorLookupKey);
         if (interceptors != null && interceptors.size() > 0) {
             try {
-              Bundle b = FrameworkUtil.getBundle(original.getClass());
-              if (b == null) {
-                // we have a class from the framework parent, so use our bundle for proxying.
-                b = blueprintContainer.getBundleContext().getBundle();
-              }
-              intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
-                  ProxyUtils.asList(original.getClass()), original, 
-                  new Collaborator(interceptorLookupKey, interceptors));
+                Bundle b = FrameworkUtil.getBundle(original.getClass());
+                if (b == null) {
+                    // we have a class from the framework parent, so use our bundle for proxying.
+                    b = blueprintContainer.getBundleContext().getBundle();
+                }
+                intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
+                requiredInterfaces, original, new Collaborator(interceptorLookupKey, interceptors));
             } catch (org.apache.aries.proxy.UnableToProxyException e) {
-                  Bundle b = blueprintContainer.getBundleContext().getBundle();
-                  throw new ComponentDefinitionException("Unable to create proxy for bean " + name + " in bundle " + b.getSymbolicName() + " version " + b.getVersion(), e);
+                Bundle b = blueprintContainer.getBundleContext().getBundle();
+                throw new ComponentDefinitionException("Unable to create proxy for bean " + name + " in bundle " + b.getSymbolicName() + " version " + b.getVersion(), e);
             }
         } else {
             intercepted = original;
@@ -754,8 +780,7 @@ public class BeanRecipe extends Abstract
                 return createProxyBean(rr);
             }
         } 
-        
-        return internalCreate2();
+        return new UnwrapperedBeanHolder(internalCreate2(), this);
     }
     
     private Object createProxyBean(ReferenceRecipe rr) {
@@ -770,7 +795,7 @@ public class BeanRecipe extends Abstract
         }
     }
     
-    protected Object internalCreate2() throws ComponentDefinitionException {
+    private Object internalCreate2() throws ComponentDefinitionException {
         
         instantiateExplicitDependencies();
 
@@ -796,13 +821,31 @@ public class BeanRecipe extends Abstract
         
         obj = runBeanProcPostInit(obj);
         
-        obj = addInterceptors(obj);
+        //Replaced by calling wrap on the UnwrapperedBeanHolder
+//        obj = addInterceptors(obj);
         
         return obj;
     }
     
+    static Object wrap(UnwrapperedBeanHolder holder, Collection<Class<?>> requiredViews) {
+        return holder.recipe.addInterceptors(holder.unwrapperedBean, requiredViews);
+    }
+    
+    static Object wrap(UnwrapperedBeanHolder holder, Class<?> requiredView) {
+        if(requiredView == Object.class) {
+          //We don't know what we need so we have to do everything
+            return holder.recipe.addInterceptors(holder.unwrapperedBean, new ArrayList<Class<?>>(1));
+        } else {
+        	return holder.recipe.addInterceptors(holder.unwrapperedBean, ProxyUtils.asList(requiredView));
+        }
+    }
+    
+    
     @Override
     public void destroy(Object obj) {
+        //This object should *always* be an UnwrapperedBeanHolder, so cast it and get the bean out.
+    	obj = ((UnwrapperedBeanHolder)obj).unwrapperedBean;
+    	
         for (BeanProcessor processor : blueprintContainer.getProcessors(BeanProcessor.class)) {
             processor.beforeDestroy(obj, getName());
         }
@@ -968,15 +1011,26 @@ public class BeanRecipe extends Abstract
                     }
                 } else if (arg != null) {
                     if (convert) {
-                        try {
-                            // TODO: call canConvert instead of convert()
-                            val = convert(arg, entry.type);
-                        } catch (Throwable t) {
+                        
+                        if(canConvert(arg, entry.type)) {
+                            try {
+								val = convert(arg, entry.type);
+							} catch (Exception e) {
+								throw new ComponentDefinitionException(e);
+							}
+                        } else { 
                             continue;
                         }
                     } else {
+                    	UnwrapperedBeanHolder holder = null;
+                        if(arg instanceof UnwrapperedBeanHolder) {
+                        	holder = (UnwrapperedBeanHolder)arg;
+                        	arg = holder.unwrapperedBean;
+                        }
                         if (!AggregateConverter.isAssignable(arg, entry.type)) {
                             continue;
+                        } else if (holder != null) {
+                            val = wrap(holder, entry.type.getRawClass());
                         }
                     }
                 }

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintContainerImpl.java Fri Feb  3 14:56:58 2012
@@ -60,6 +60,7 @@ import org.apache.aries.blueprint.namesp
 import org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl;
 import org.apache.aries.blueprint.parser.Parser;
 import org.apache.aries.blueprint.parser.NamespaceHandlerSet;
+import org.apache.aries.blueprint.proxy.ProxyUtils;
 import org.apache.aries.blueprint.reflect.MetadataUtil;
 import org.apache.aries.blueprint.reflect.PassThroughMetadataImpl;
 import org.apache.aries.blueprint.utils.HeaderParser;
@@ -464,7 +465,7 @@ public class BlueprintContainerImpl 
             }
         }
 
-        Map<String, Object> objects = repository.createAll(typeConverters);
+        Map<String, Object> objects = repository.createAll(typeConverters, ProxyUtils.asList(Converter.class));
         for (String name : typeConverters) {
             Object obj = objects.get(name);
             if (obj instanceof Converter) {
@@ -494,10 +495,10 @@ public class BlueprintContainerImpl 
             }
 
             if (ComponentDefinitionRegistryProcessor.class.isAssignableFrom(clazz)) {
-                Object obj = repository.create(bean.getId());
+                Object obj = repository.create(bean.getId(), ProxyUtils.asList(ComponentDefinitionRegistryProcessor.class));
                 ((ComponentDefinitionRegistryProcessor) obj).process(componentDefinitionRegistry);
             } else if (Processor.class.isAssignableFrom(clazz)) {
-                Object obj = repository.create(bean.getId());
+                Object obj = repository.create(bean.getId(), ProxyUtils.asList(Processor.class));
                 this.processors.add((Processor) obj);
             } else {
                 continue;

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintRepository.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintRepository.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintRepository.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintRepository.java Fri Feb  3 14:56:58 2012
@@ -36,6 +36,7 @@ import java.util.concurrent.ExecutionExc
 import java.util.concurrent.Future;
 
 import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.apache.aries.blueprint.container.BeanRecipe.UnwrapperedBeanHolder;
 import org.apache.aries.blueprint.di.CircularDependencyException;
 import org.apache.aries.blueprint.di.ExecutionContext;
 import org.apache.aries.blueprint.di.IdRefRecipe;
@@ -148,12 +149,26 @@ public class BlueprintRepository impleme
         }
     }
     
-    public Map<String, Object> createAll(Collection<String> names) throws ComponentDefinitionException {
+    public Object create(String name, Collection<Class<?>> proxyInterfaces) throws ComponentDefinitionException {
+        ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
+        try {
+            Object instance = createInstance(name); 
+            if(instance instanceof UnwrapperedBeanHolder)
+                instance = BeanRecipe.wrap((UnwrapperedBeanHolder) instance, proxyInterfaces);
+            return convert(name, instance);
+		} finally {
+            ExecutionContext.Holder.setContext(oldContext);
+        }
+    }
+    
+    public Map<String, Object> createAll(Collection<String> names, Collection<Class<?>> proxyInterfaces) throws ComponentDefinitionException {
         ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
         try {
             Map<String, Object> instances = createInstances(names);
             for (String name : instances.keySet()) {
                 Object obj = instances.get(name);
+                if(obj instanceof UnwrapperedBeanHolder)
+                	obj = BeanRecipe.wrap((UnwrapperedBeanHolder) obj, proxyInterfaces);
                 instances.put(name, convert(name, obj));
             }
             return instances;
@@ -161,6 +176,16 @@ public class BlueprintRepository impleme
             ExecutionContext.Holder.setContext(oldContext);
         }
     }
+    
+    public void createAll(Collection<String> names) throws ComponentDefinitionException {
+        ExecutionContext oldContext = ExecutionContext.Holder.setContext(this);
+        try {
+            createInstances(names);
+            return;
+        } finally {
+            ExecutionContext.Holder.setContext(oldContext);
+        }
+    }
 
     public <T> List<T> getAllRecipes(Class<T> clazz, String... names) {
         List<T> recipes = new ArrayList<T>();

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/RecipeBuilder.java Fri Feb  3 14:56:58 2012
@@ -45,6 +45,7 @@ import org.apache.aries.blueprint.ext.Co
 import org.apache.aries.blueprint.ext.DependentComponentFactoryMetadata;
 import org.apache.aries.blueprint.mutable.MutableMapMetadata;
 import org.apache.aries.blueprint.reflect.MetadataUtil;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.reflect.BeanArgument;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
 import org.osgi.service.blueprint.reflect.BeanProperty;
@@ -144,7 +145,7 @@ public class RecipeBuilder {
     private Recipe createReferenceListRecipe(ReferenceListMetadata metadata) {
         CollectionRecipe listenersRecipe = null;
         if (metadata.getReferenceListeners() != null) {
-            listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class);
+            listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class, Object.class.getName());
             for (ReferenceListener listener : metadata.getReferenceListeners()) {
                 listenersRecipe.add(createRecipe(listener));
             }
@@ -160,7 +161,7 @@ public class RecipeBuilder {
     private ReferenceRecipe createReferenceRecipe(ReferenceMetadata metadata) {
         CollectionRecipe listenersRecipe = null;
         if (metadata.getReferenceListeners() != null) {
-            listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class);
+            listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class, Object.class.getName());
             for (ReferenceListener listener : metadata.getReferenceListeners()) {
                 listenersRecipe.add(createRecipe(listener));
             }
@@ -174,7 +175,7 @@ public class RecipeBuilder {
     }
 
     private Recipe createServiceRecipe(ServiceMetadata serviceExport) {
-        CollectionRecipe listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class);
+        CollectionRecipe listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class, Object.class.getName());
         if (serviceExport.getRegistrationListeners() != null) {
             for (RegistrationListener listener : serviceExport.getRegistrationListeners()) {
                 listenersRecipe.add(createRecipe(listener));
@@ -301,8 +302,8 @@ public class RecipeBuilder {
             return rr;
         } else if (v instanceof CollectionMetadata) {
             CollectionMetadata collectionMetadata = (CollectionMetadata) v;
-            Class cl = collectionMetadata.getCollectionClass();
-            Object type = collectionMetadata.getValueType();
+            Class<?> cl = collectionMetadata.getCollectionClass();
+            String type = collectionMetadata.getValueType();
             if (cl == Object[].class) {
                 ArrayRecipe ar = new ArrayRecipe(getName(null), type);
                 for (Metadata lv : collectionMetadata.getValues()) {
@@ -310,7 +311,7 @@ public class RecipeBuilder {
                 }
                 return ar;
             } else {
-                CollectionRecipe cr = new CollectionRecipe(getName(null), cl != null ? cl : ArrayList.class);
+                CollectionRecipe cr = new CollectionRecipe(getName(null), cl != null ? cl : ArrayList.class, type);
                 for (Metadata lv : collectionMetadata.getValues()) {
                     cr.add(getValue(lv, type));
                 }
@@ -320,7 +321,7 @@ public class RecipeBuilder {
             return createMapRecipe((MapMetadata) v);
         } else if (v instanceof PropsMetadata) {
             PropsMetadata mapValue = (PropsMetadata) v;
-            MapRecipe mr = new MapRecipe(getName(null), Properties.class);
+            MapRecipe mr = new MapRecipe(getName(null), Properties.class, String.class, String.class);
             for (MapEntry entry : mapValue.getEntries()) {
                 Recipe key = getValue(entry.getKey(), String.class);
                 Recipe val = getValue(entry.getValue(), String.class);
@@ -340,7 +341,7 @@ public class RecipeBuilder {
     private MapRecipe createMapRecipe(MapMetadata mapValue) {
         String keyType = mapValue.getKeyType();
         String valueType = mapValue.getValueType();
-        MapRecipe mr = new MapRecipe(getName(null), HashMap.class);
+        MapRecipe mr = new MapRecipe(getName(null), HashMap.class, keyType, valueType);
         for (MapEntry entry : mapValue.getEntries()) {
             Recipe key = getValue(entry.getKey(), keyType);
             Recipe val = getValue(entry.getValue(), valueType);

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ServiceRecipe.java Fri Feb  3 14:56:58 2012
@@ -33,8 +33,11 @@ import org.apache.aries.blueprint.Bluepr
 import org.apache.aries.blueprint.ComponentDefinitionRegistry;
 import org.apache.aries.blueprint.Interceptor;
 import org.apache.aries.blueprint.ServiceProcessor;
+import org.apache.aries.blueprint.container.AggregateConverter.Convertible;
+import org.apache.aries.blueprint.container.BeanRecipe.UnwrapperedBeanHolder;
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.CollectionRecipe;
+import org.apache.aries.blueprint.di.ExecutionContext;
 import org.apache.aries.blueprint.di.MapRecipe;
 import org.apache.aries.blueprint.di.Recipe;
 import org.apache.aries.blueprint.di.Repository;
@@ -53,6 +56,7 @@ import org.osgi.framework.ServiceFactory
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.ReifiedType;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
@@ -268,7 +272,31 @@ public class ServiceRecipe extends Abstr
     private void createService() {
         try {
             LOGGER.debug("Creating service instance");
-            service = createRecipe(serviceRecipe);
+            //We can't use the BlueprintRepository because we don't know what interfaces
+            //to use yet! We have to be a bit smarter.
+            ExecutionContext old = ExecutionContext.Holder.setContext(blueprintContainer.getRepository());
+           
+            try {
+            	Object o = serviceRecipe.create();
+            
+            	if (o instanceof Convertible) {
+            		o = blueprintContainer.getRepository().convert(o, new ReifiedType(Object.class));
+                    validateClasses(o);
+            	} else if (o instanceof UnwrapperedBeanHolder) {
+                    UnwrapperedBeanHolder holder = (UnwrapperedBeanHolder) o;
+                    validateClasses(holder.unwrapperedBean);
+                    o = BeanRecipe.wrap(holder, getClassesForProxying(holder.unwrapperedBean));
+                } else {
+                    validateClasses(o);
+                }
+            	service = o;
+			} catch (Exception e) {
+				LOGGER.error("Error retrieving service from " + this, e);
+				throw new ComponentDefinitionException(e);
+			} finally {
+				ExecutionContext.Holder.setContext(old);
+			}
+            
             LOGGER.debug("Service created: {}", service);
             // When the service is first requested, we need to create listeners and call them
             if (listeners == null) {
@@ -303,6 +331,7 @@ public class ServiceRecipe extends Abstr
             Set<String> allClasses = new HashSet<String>();
             ReflectionUtils.getSuperClasses(allClasses, service.getClass());
             ReflectionUtils.getImplementedInterfaces(allClasses, service.getClass());
+            //This call is safe because we know that we don't need to call internalGet to get the answer
             Set<String> classes = getClasses();
             classes.removeAll(allClasses);
             if (!classes.isEmpty()) {
@@ -326,6 +355,11 @@ public class ServiceRecipe extends Abstr
         }
     }
 
+    /**
+     * Be careful to avoid calling this method from internalGetService or createService before the service
+     * field has been set. If you get this wrong you will get a StackOverflowError!
+     * @return
+     */
     private Set<String> getClasses() {
         Set<String> classes;
         switch (metadata.getAutoExport()) {
@@ -352,18 +386,21 @@ public class ServiceRecipe extends Abstr
      * or everything, then just proxying the real bean class will give us everything we
      * need, if none of the above then we need the class forms of the interfaces in
      * the metadata
+     * 
+     * Note that we use a template object here because we have already instantiated the bean
+     * that we're going to proxy. We can't call internalGetService because it would Stack Overflow.
      * @return
      * @throws ClassNotFoundException
      */
-    private Collection<Class<?>> getClassesForProxying() throws ClassNotFoundException {
+    private Collection<Class<?>> getClassesForProxying(Object template) throws ClassNotFoundException {
       Collection<Class<?>> classes;
       switch (metadata.getAutoExport()) {
           case ServiceMetadata.AUTO_EXPORT_INTERFACES:
-              classes = ReflectionUtils.getImplementedInterfacesAsClasses(new HashSet<Class<?>>(), internalGetService().getClass());
+              classes = ReflectionUtils.getImplementedInterfacesAsClasses(new HashSet<Class<?>>(), template.getClass());
               break;
           case ServiceMetadata.AUTO_EXPORT_CLASS_HIERARCHY:
           case ServiceMetadata.AUTO_EXPORT_ALL_CLASSES:
-            classes = ProxyUtils.asList(internalGetService().getClass());
+            classes = ProxyUtils.asList(template.getClass());
               break;
           default:
               classes = new HashSet<Class<?>>(convertStringsToClasses(metadata.getInterfaces()));
@@ -397,7 +434,7 @@ public class ServiceRecipe extends Abstr
         }
         return repo.create(name);
     }
-   
+    
     private String getComponentName() {
         if (metadata.getServiceComponent() instanceof RefMetadata) {
             RefMetadata ref = (RefMetadata) metadata.getServiceComponent();
@@ -491,7 +528,7 @@ public class ServiceRecipe extends Abstr
                 InvocationListener collaborator = new Collaborator(cm, interceptors);
 
                 intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
-                        getClassesForProxying(), original, collaborator);
+                        getClassesForProxying(original), original, collaborator);
             } catch (Exception u) {
                 Bundle b = blueprintContainer.getBundleContext().getBundle();
                 LOGGER.info("Unable to create a proxy object for the service " + getName() + " defined in bundle " + b.getSymbolicName() + " at version " + b.getVersion() + " with id " + b.getBundleId() + ". Returning the original object instead.", u);

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/AbstractRecipe.java Fri Feb  3 14:56:58 2012
@@ -119,6 +119,10 @@ public abstract class AbstractRecipe imp
         }
     }
     
+    protected boolean canConvert(Object obj, ReifiedType type) {
+    	return ExecutionContext.Holder.getContext().canConvert(obj, type);
+    }
+    
     protected Object convert(Object obj, ReifiedType type) throws Exception {
         return ExecutionContext.Holder.getContext().convert(obj, type);
     }

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/CollectionRecipe.java Fri Feb  3 14:56:58 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.aries.blueprint.di;
 
+import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashSet;
@@ -28,6 +29,7 @@ import java.util.TreeSet;
 
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.ReifiedType;
 
 /**
  * @version $Rev$ $Date$
@@ -35,12 +37,14 @@ import org.osgi.service.blueprint.contai
 public class CollectionRecipe extends AbstractRecipe {
 
     private final List<Recipe> list;
-    private final Class typeClass;
+    private final Class<?> collectionTypeClass;
+    private final String defaultValueType;
 
-    public CollectionRecipe(String name, Class type) {
+    public CollectionRecipe(String name, Class<?> collectionType, String valueType) {
         super(name);
-        if (type == null) throw new NullPointerException("type is null");
-        this.typeClass = type;
+        if (collectionType == null) throw new NullPointerException("type is null");
+        this.collectionTypeClass = collectionType;
+        this.defaultValueType = (valueType != null) ? valueType : Object.class.getName();
         this.list = new ArrayList<Recipe>();
     }
 
@@ -55,7 +59,7 @@ public class CollectionRecipe extends Ab
     }
 
     protected Object internalCreate() throws ComponentDefinitionException {
-        Class type = getCollection(typeClass);
+        Class type = getCollection(collectionTypeClass);
 
         if (!ReflectionUtils.hasDefaultConstructor(type)) {
             throw new ComponentDefinitionException("Type does not have a default constructor " + type.getName());
@@ -73,13 +77,19 @@ public class CollectionRecipe extends Ab
         }
         Collection instance = (Collection) o;
 
+        ReifiedType defaultConversionType = loadType(defaultValueType);
+        Type conversionType = null;
         for (Recipe recipe : list) {
             Object value;
             if (recipe != null) {
                 try {
-                    value = recipe.create();
+                	conversionType = defaultConversionType.getRawClass();
+                    if (recipe instanceof ValueRecipe) {
+                    	conversionType = ((ValueRecipe)recipe).getValueType();
+                    } 
+                    value = convert(recipe.create(), conversionType);
                 } catch (Exception e) {
-                    throw new ComponentDefinitionException("Unable to convert value " + recipe + " to type " + type, e);
+                    throw new ComponentDefinitionException("Unable to convert value " + recipe + " to type " + conversionType, e);
                 }
             } else {
                 value = null;

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/MapRecipe.java Fri Feb  3 14:56:58 2012
@@ -25,12 +25,12 @@ import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import java.util.Hashtable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.aries.blueprint.utils.ReflectionUtils;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.ReifiedType;
 
 /**
  * @version $Rev$ $Date$
@@ -38,13 +38,18 @@ import org.osgi.service.blueprint.contai
 public class MapRecipe extends AbstractRecipe {
 
     private final List<Recipe[]> entries;
-    private final Class typeClass;
-
-    public MapRecipe(String name, Class type) {
+    private final Class<?> typeClass;
+    private final Object keyType;
+    private final Object valueType;
+    
+    
+    public MapRecipe(String name, Class<?> type, Object keyType, Object valueType) {
         super(name);
         if (type == null) throw new NullPointerException("type is null");
         this.typeClass = type;
         this.entries = new ArrayList<Recipe[]>();
+        this.keyType = keyType;
+        this.valueType = valueType;
     }
 
     public List<Recipe> getDependencies() {
@@ -57,9 +62,21 @@ public class MapRecipe extends AbstractR
         }
         return nestedRecipes;
     }
+    
+    private ReifiedType getType(Object o) {
+    	ReifiedType type;
+        if (o instanceof Class) {
+            type = new ReifiedType((Class) o);
+        } else if (o instanceof String) {
+            type = loadType((String) o);
+        } else {
+            type = new ReifiedType(Object.class);
+        }
+        return type;
+    }
 
     protected Object internalCreate() throws ComponentDefinitionException {
-        Class mapType = getMap(typeClass);
+        Class<?> mapType = getMap(typeClass);
 
         if (!ReflectionUtils.hasDefaultConstructor(mapType)) {
             throw new ComponentDefinitionException("Type does not have a default constructor " + mapType.getName());
@@ -81,11 +98,17 @@ public class MapRecipe extends AbstractR
             throw new ComponentDefinitionException("Specified map type does not implement the Map interface: " + mapType.getName());
         }
 
+        ReifiedType convertKeyType = getType(keyType);
+        ReifiedType convertValueType = getType(valueType);
         // add map entries
-        for (Recipe[] entry : entries) {
-            Object key = entry[0].create();
-            Object value = entry[1] != null ? entry[1].create() : null;
-            instance.put(key, value);
+        try {
+            for (Recipe[] entry : entries) {
+                Object key = convert(entry[0].create(), convertKeyType);
+                Object value = entry[1] != null ? convert(entry[1].create(), convertValueType) : null;
+                instance.put(key, value);
+            }
+        } catch (Exception e) {
+        	throw new ComponentDefinitionException(e);
         }
         return instance;
     }
@@ -104,7 +127,7 @@ public class MapRecipe extends AbstractR
         }
     }
 
-    public static Class getMap(Class type) {
+    public static Class<?> getMap(Class<?> type) {
         if (ReflectionUtils.hasDefaultConstructor(type)) {
             return type;
         } else if (SortedMap.class.isAssignableFrom(type)) {

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/RefRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/RefRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/RefRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/RefRecipe.java Fri Feb  3 14:56:58 2012
@@ -57,6 +57,8 @@ public class RefRecipe extends AbstractR
         Object instance = context.getObject(idRef);
         if (instance instanceof Recipe) {
             Recipe recipe = (Recipe) instance;
+            //We do not convert this, it might be an unwrappered bean, but we don't know what type
+            //it needs to be yet. The property setter or factory-ref in the Bean recipe will do this will do this
             instance = recipe.create();
         }
         return instance;

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/Repository.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/Repository.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/Repository.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/Repository.java Fri Feb  3 14:56:58 2012
@@ -59,8 +59,12 @@ public interface Repository {
     void removeRecipe(String name);
 
     Object create(String name) throws ComponentDefinitionException;
+    
+    Object create(String name, Collection<Class<?>> proxyInterfaces) throws ComponentDefinitionException;
 
-    Map<String, Object> createAll(Collection<String> names) throws ComponentDefinitionException;
+    void createAll(Collection<String> names) throws ComponentDefinitionException;
+    
+    Map<String, Object> createAll(Collection<String> names, Collection<Class<?>> proxyInterfaces) throws ComponentDefinitionException;
 
     <T> List<T> getAllRecipes(Class<T> clazz, String... names);
 

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/di/ValueRecipe.java Fri Feb  3 14:56:58 2012
@@ -50,18 +50,23 @@ public class ValueRecipe extends Abstrac
     @Override
     protected Object internalCreate() throws ComponentDefinitionException {
         try {
-            Type type = Object.class;
-            if (this.type instanceof Type) {
-                type = (Type) this.type;
-            } else if (this.type instanceof String) {
-                type = loadClass((String) this.type);
-            }
+            Type type = getValueType();
             return convert(value.getStringValue(), type);
         } catch (Exception e) {            
             throw new ComponentDefinitionException(e);
         }
     }
 
+	protected Type getValueType() {
+		Type type = Object.class;
+		if (this.type instanceof Type) {
+		    type = (Type) this.type;
+		} else if (this.type instanceof String) {
+		    type = loadClass((String) this.type);
+		}
+		return type;
+	}
+
     @Override
     public String toString() {
         return "ValueRecipe[" +

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/TestBlueprintContainer.java Fri Feb  3 14:56:58 2012
@@ -18,20 +18,31 @@
  */
 package org.apache.aries.blueprint;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.blueprint.container.AggregateConverter;
 import org.apache.aries.blueprint.container.BlueprintContainerImpl;
 import org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl;
+import org.apache.aries.blueprint.proxy.ProxyUtils;
 import org.apache.aries.blueprint.reflect.PassThroughMetadataImpl;
 import org.apache.aries.proxy.ProxyManager;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.Target;
 
 public class TestBlueprintContainer extends BlueprintContainerImpl {
 
     private ComponentDefinitionRegistryImpl registry;
     
-    public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry) {
+    public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry) throws Exception {
         this(registry, null);
     }
 
-    public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry, ProxyManager proxyManager) {
+    public TestBlueprintContainer(ComponentDefinitionRegistryImpl registry, ProxyManager proxyManager) throws Exception {
         super(new TestBundleContext(), null, null, null, null, null, proxyManager);
         this.registry = registry;
         if (registry != null) {
@@ -39,6 +50,30 @@ public class TestBlueprintContainer exte
             registry.registerComponentDefinition(new PassThroughMetadataImpl("blueprintBundle", getBundleContext().getBundle()));
             registry.registerComponentDefinition(new PassThroughMetadataImpl("blueprintBundleContext", getBundleContext()));
             registry.registerComponentDefinition(new PassThroughMetadataImpl("blueprintConverter", getConverter()));
+            processTypeConverters();
+        }
+    }
+    
+    private void processTypeConverters() throws Exception {
+        List<String> typeConverters = new ArrayList<String>();
+        for (Target target : registry.getTypeConverters()) {
+            if (target instanceof ComponentMetadata) {
+                typeConverters.add(((ComponentMetadata) target).getId());
+            } else if (target instanceof RefMetadata) {
+                typeConverters.add(((RefMetadata) target).getComponentId());
+            } else {
+                throw new ComponentDefinitionException("Unexpected metadata for type converter: " + target);
+            }
+        }
+
+        Map<String, Object> objects = getRepository().createAll(typeConverters, ProxyUtils.asList(Converter.class));
+        for (String name : typeConverters) {
+            Object obj = objects.get(name);
+            if (obj instanceof Converter) {
+                ((AggregateConverter)getConverter()).registerConverter((Converter) obj);
+            } else {
+                throw new ComponentDefinitionException("Type converter " + obj + " does not implement the " + Converter.class.getName() + " interface");
+            }
         }
     }
 

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java Fri Feb  3 14:56:58 2012
@@ -46,6 +46,8 @@ import org.apache.aries.blueprint.pojos.
 import org.apache.aries.blueprint.pojos.PojoListener;
 import org.apache.aries.blueprint.pojos.PojoRecursive;
 import org.apache.aries.blueprint.pojos.Primavera;
+import org.apache.aries.blueprint.proxy.ProxyUtils;
+import org.apache.aries.proxy.impl.JdkProxyManager;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 
@@ -90,7 +92,7 @@ public class WiringTest extends Abstract
         
         assertNotNull(pojoa.getSet());
         assertTrue(pojoa.getSet().contains("set value"));
-        assertTrue(pojoa.getSet().contains(pojob));
+        assertTrue(pojoa.getSet().contains(pojob.getUri()));
         assertTrue(pojoa.getSet().contains(URI.create("http://geronimo.apache.org")));
         
         assertNotNull(pojoa.getMap());
@@ -217,7 +219,7 @@ public class WiringTest extends Abstract
 
         ComponentDefinitionRegistryImpl registry = parse("/test-depends-on.xml");
         Repository repository = new TestBlueprintContainer(registry).getRepository();
-        Map instances = repository.createAll(Arrays.asList("c", "d", "e"));
+        Map instances = repository.createAll(Arrays.asList("c", "d", "e"), ProxyUtils.asList(Object.class));
         
         List<Callback> callback = CallbackTracker.getCallbacks();
         assertEquals(3, callback.size());

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java Fri Feb  3 14:56:58 2012
@@ -36,7 +36,7 @@ public class AggregateConverterTest exte
 
     private AggregateConverter service;
 
-    protected void setUp() {
+    protected void setUp() throws Exception {
         service = new AggregateConverter(new TestBlueprintContainer(null));
     }
 

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java Fri Feb  3 14:56:58 2012
@@ -19,6 +19,7 @@
 package org.apache.aries.blueprint.pojos;
 
 import java.io.File;
+import java.net.URI;
 
 import org.osgi.service.blueprint.container.ReifiedType;
 import org.osgi.service.blueprint.container.Converter;
@@ -26,12 +27,15 @@ import org.osgi.service.blueprint.contai
 public class ConverterA implements Converter {
 
     public boolean canConvert(Object fromValue, ReifiedType toType) {
-        return fromValue instanceof String && toType.getRawClass() == File.class;
+        return (fromValue instanceof String && toType.getRawClass() == File.class)
+        		|| fromValue instanceof PojoB && toType.getRawClass() == URI.class;
     }
 
     public Object convert(Object source, ReifiedType toType) throws Exception {
         if (source instanceof String) {
             return new File((String) source);
+        } else if (source instanceof PojoB) {
+        	return ((PojoB)source).getUri();
         }
         throw new Exception("Unable to convert from " + (source != null ? source.getClass().getName() : "<null>") + " to " + File.class.getName());
     }

Modified: aries/trunk/blueprint/blueprint-core/src/test/resources/test-wiring.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/resources/test-wiring.xml?rev=1240203&r1=1240202&r2=1240203&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/resources/test-wiring.xml (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/resources/test-wiring.xml Fri Feb  3 14:56:58 2012
@@ -20,9 +20,7 @@
            default-availability="mandatory" >
 
     <type-converters>
-            <bean id="converter1" class="org.apache.aries.blueprint.pojos.ConverterA">
-                <property name="bundle" ref="blueprintBundleContext" />
-            </bean>
+            <bean id="converter1" class="org.apache.aries.blueprint.pojos.ConverterA"/>
     </type-converters>
 
     <service id="service1" ref="pojoB" interface="org.apache.aries.blueprint.pojos.PojoB">