You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/06/22 17:03:55 UTC

svn commit: r787264 [1/2] - in /geronimo/sandbox/blueprint: blueprint-api/src/main/java/org/osgi/service/blueprint/container/ blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/ blueprint-core/src/main/java/org/apache/geronimo/bluep...

Author: gnodet
Date: Mon Jun 22 15:03:53 2009
New Revision: 787264

URL: http://svn.apache.org/viewvc?rev=787264&view=rev
Log:
Update API to use CollapsedType

Added:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/CollapsedType.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/container/GenericTypeTest.java
Modified:
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
    geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java
    geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedProperties.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AggregateConverter.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BeanRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/AbstractRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ArrayRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/CollectionRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/MapRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/TypeUtils.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/container/AggregateConverterTest.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/ConverterA.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/ConverterB.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/pojos/PojoA.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/utils/HeaderParserTest.java
    geronimo/sandbox/blueprint/blueprint-sample/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java
    geronimo/sandbox/blueprint/blueprint-sample/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java (original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/BlueprintContainer.java Mon Jun 22 15:03:53 2009
@@ -22,100 +22,111 @@
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 
 /**
- * BlueprintContainer providing access to the components, service exports, and
- * service references of a bundle using blueprint services. Only bundles in the
- * ACTIVE state may have an associated BlueprintContainer. A given BundleContext
- * has at most one associated BlueprintContainer.
+ * Blueprint Container providing access to the components, exported services,
+ * and service references of a bundle using Blueprint services. Only bundles in
+ * the <code>ACTIVE</code> (or also <code>STARTING</code> for bundles with a
+ * lazy activation policy) state may have an associated Blueprint Container. A
+ * given Bundle Context has at most one associated Blueprint Container.
  *
- * An instance of BlueprintContainer may be obtained from within a blueprint context by
- * injecting the predefined "blueprintContainer" component.
- * Alternatively you can look up BlueprintContainer services in the service registry.
- * The Constants.BUNDLE_SYMBOLICNAME and Constants.BUNDLE_VERSION service
- * properties can be used to determine which bundle the published BlueprintContainer
- * service is associated with.
+ * A Blueprint Container may be obtained by injecting the predefined
+ * "blueprintContainer" component instance. Alternatively you can look up a
+ * Blueprint Container services in the service registry. The
+ * {@link org.osgi.framework.Constants#BUNDLE_SYMBOLICNAME} and
+ * {@link org.osgi.framework.Constants#BUNDLE_VERSION} service properties can be
+ * used to determine which bundle the published Blueprint Container service is
+ * associated with.
  *
- * A BlueprintContainer implementation must support safe concurrent access. It is
- * legal for the set of named components and component metadata to change
+ * A Blueprint Container implementation must support safe concurrent access. It
+ * is legal for the set of named components and component Metadata to change
  * between invocations on the same thread if another thread is concurrently
- * modifying the same mutable BlueprintContainer implementation object.
+ * modifying the same mutable Blueprint Container implementation object.
  *
  * @see org.osgi.framework.Constants
- *
  */
 public interface BlueprintContainer {
 
-    /**
-     * The container will apply strict compliance rules
-     */
-    static final int COMPLIANCE_STRICT = 1;
-
-    /**
-      * The container will use loose compliance rules
-      */
-    static final int COMPLIANCE_LOOSE = 2;
+	/**
+	 * The container will apply strict compliance rules
+	 */
+	static final int COMPLIANCE_STRICT = 1;
+
+	/**
+	 * The container will use loose compliance rules
+	 */
+	static final int COMPLIANCE_LOOSE = 2;
 
 	/**
 	 * The set of component names recognized by the blueprint context.
 	 *
-	 * @return an immutable set (of Strings) containing the names of all of the components within the
-	 * context.
+	 * @return an immutable set (of Strings) containing the names of all of the
+	 *         components within the context.
 	 */
-	Set getComponentIds();
+	Set<String> getComponentIds();
 
 	/**
-	 * Get the component instance for a given named component. If the component has
-	 * not yet been instantiated, calling this operation will cause the component instance
-	 * to be created and initialized. If the component
-	 * has a prototype scope then each call to getComponent will return a new
-	 * component instance. If the component has a bundle scope then the component
-	 * instance returned will be the instance for the caller's bundle (and that
-	 * instance will be instantiated if it has not already been created).
-	 *
-	 * Note: calling getComponent from logic executing during the instantiation and
-	 * configuration of a component, before the init method (if specified) has returned,
-	 * may trigger a circular dependency (for a trivial example, consider a component
-	 * that looks itself up by name during its init method). Implementations of the
-	 * Blueprint Service are not required to support cycles in the dependency graph
-	 * and may throw an exception if a cycle is detected. Implementations that can
-	 * support certain kinds of cycles are free to do so.
-	 *
-	 * @param id the name of the component for which the instance is to be
-	 * retrieved.
+	 * Get the component instance for a given named component. If the component
+	 * has not yet been instantiated, calling this operation will cause the
+	 * component instance to be created and initialized. If the component has a
+	 * prototype scope then each call to getComponent will return a new
+	 * component instance. If the component has a bundle scope then the
+	 * component instance returned will be the instance for the caller's bundle
+	 * (and that instance will be instantiated if it has not already been
+	 * created).
+	 *
+	 * Note: calling getComponent from logic executing during the instantiation
+	 * and configuration of a component, before the init method (if specified)
+	 * has returned, may trigger a circular dependency (for a trivial example,
+	 * consider a component that looks itself up by name during its init
+	 * method). Implementations of the Blueprint Service are not required to
+	 * support cycles in the dependency graph and may throw an exception if a
+	 * cycle is detected. Implementations that can support certain kinds of
+	 * cycles are free to do so.
+	 *
+	 * @param id
+	 *            the name of the component for which the instance is to be
+	 *            retrieved.
 	 *
 	 * @return the component instance, the type of the returned object is
-	 * dependent on the component definition, and may be determined by
-	 * introspecting the component metadata.
+	 *         dependent on the component definition, and may be determined by
+	 *         introspecting the component Metadata.
 	 *
-	 * @throws NoSuchComponentException if the name specified is not the
-	 * name of a component within the context.
+	 * @throws NoSuchComponentException
+	 *             if the name specified is not the name of a component within
+	 *             the context.
 	 */
 	Object getComponentInstance(String id);
 
 	/**
-	 * Get the component metadata for a given named component.
+	 * Get the component Metadata for a given named component.
 	 *
-	 * @param id the name of the component for which the metadata is to be
-	 * retrieved.
+	 * @param id
+	 *            the name of the component for which the Metadata is to be
+	 *            retrieved.
 	 *
-	 * @return the component metadata for the component.
+	 * @return the component Metadata for the component.
 	 *
-	 * @throws NoSuchComponentException if the name specified is not the
-	 * name of a component within the context.
+	 * @throws NoSuchComponentException
+	 *             if the name specified is not the name of a component within
+	 *             the context.
 	 */
 	ComponentMetadata getComponentMetadata(String id);
 
 	/**
-	 * Returns all ComponentMetadata instances of the given type.  The supported
-	 * metadata types are ComponentMetadata (which returns the metadata for all defined
-     * component types), BeanMetadata, ServiceReferenceMetadata (which returns both
-     * ReferenceMetadata and RefListMetadata instances), ReferenceMetadata,
-     * RefListMetadata, and ServiceMetadata.  The collection will include all
-     * metadata instances of the requested type, including components that are declared
-     * as inline values.
+	 * Returns all ComponentMetadata instances of the given type. The supported
+	 * Metadata types are ComponentMetadata (which returns the Metadata for all
+	 * defined component types), BeanMetadata, ServiceReferenceMetadata (which
+	 * returns both ReferenceMetadata and RefListMetadata instances),
+	 * ReferenceMetadata, RefListMetadata, and ServiceMetadata. The collection
+	 * will include all Metadata instances of the requested type, including
+	 * components that are declared as inline values.
+	 *
+	 * @param type
 	 *
-	 * @return an immutable collection of ComponentMetadata objects of the matching type.
+	 * @return an immutable collection of ComponentMetadata objects of the
+	 *         matching type.
 	 */
-	<T extends ComponentMetadata> Collection<T> getMetadata(Class<T> type);
+	<T extends ComponentMetadata> Collection<T> getMetadata(
+			Class<T> type);
 
 	/**
 	 * Get the bundle context of the bundle this blueprint context is associated
@@ -125,16 +136,15 @@
 	 */
 	BundleContext getBundleContext();
 
-    /**
-     * Returns the compliance rule in effect for the target
-     * BlueprintContainer.  COMPLIANCE_LOOSE is returned if
-     * any configuration file for the container specifies
-     * loose compliance.
-     *
-     * @return The value COMPLIANCE_STRICT if strict compliance (the
-     *         default) is used for all configuration files, or the
-     *         value COMPLIANCE_LOOSE if loose complance is specified
-     *         in any of the configuration files.
-     */
-    int getCompliance();
+	/**
+	 * Returns the compliance rule in effect for the target BlueprintContainer.
+	 * COMPLIANCE_LOOSE is returned if any configuration file for the container
+	 * specifies loose compliance.
+	 *
+	 * @return The value COMPLIANCE_STRICT if strict compliance (the default) is
+	 *         used for all configuration files, or the value COMPLIANCE_LOOSE
+	 *         if loose complance is specified in any of the configuration
+	 *         files.
+	 */
+	int getCompliance();
 }

Added: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/CollapsedType.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/CollapsedType.java?rev=787264&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/CollapsedType.java (added)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/CollapsedType.java Mon Jun 22 15:03:53 2009
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.osgi.service.blueprint.container;
+
+/**
+ * Provides access to a concrete type and its optional generic type argument.
+ *
+ * A Collapsed Type converts a type declaration to a generalized form that is
+ * directly usable for conversion.It provides access to the concrete Class of
+ * the type as well of the optional type arguments.
+ *
+ * In Java 1.4, this class only works on non-generic types. In those cases, a
+ * Collapsed Type provides to the class and has no type arguments. Blueprint
+ * extender implementations can subclass this class and provide access to the
+ * generics type graph if used in a declaration. Such a subclass must
+ * <em>collapse<em> the different <code>Type</code> instances into the
+ * collapsed form. That is, a form where the raw Class is available with its optional type arguments.
+ *
+ *@Immutable
+ */
+
+public class CollapsedType {
+	final static CollapsedType ALL = new CollapsedType(Object.class);
+
+	private final Class clazz;
+
+	/**
+	 * Create a Collapsed Type for a normal Java class without any generics
+	 * information.
+	 *
+	 * @param clazz
+	 *            The class that is the collapsed type.
+	 */
+	public CollapsedType(Class clazz) {
+		this.clazz = clazz;
+	}
+
+	/**
+	 * Access to the raw class.
+	 *
+	 * The raw class represents the concrete class that is associated with a
+	 * type declaration. This class could have been deduced from the generics
+	 * type graph of the declaration. For example, in the following example:
+	 *
+	 * <pre>
+	 * Map&lt;String, Object&gt; map;
+	 * </pre>
+	 *
+	 * The raw class is the Map class.
+	 *
+	 * @return the collapsed raw class that represents this type.
+	 */
+	public Class getRawClass() {
+		return clazz;
+	}
+
+	/**
+	 * Access to a type argument.
+	 *
+	 * The type argument refers to a argument in a generic type declaration
+	 * given by index <code>i</code>. This method returns a Collapsed Type
+	 * that has Object as class when no generic type information is available.
+	 * Any object is assignable to Object and therefore no conversion is then
+	 * necessary, this is compatible with older Javas.
+	 *
+	 * This method should be overridden by a subclass that provides access to
+	 * the generic information.
+	 *
+	 * For example, in the following example:
+	 *
+	 * <pre>
+	 * Map&lt;String, Object&gt; map;
+	 * </pre>
+	 *
+	 * The type argument 0 is <code>String</code>, and type argument 1 is
+	 * <code>Object</code>.
+	 *
+	 * @param i
+	 *            The index of the type argument
+	 * @return A Collapsed Type that represents a type argument. If
+	 */
+	public CollapsedType getActualTypeArgument(int i) {
+		return ALL;
+	}
+
+    /**
+     * Number of type arguments.
+     *
+     * @return number of type arguments
+     */
+    public int size() {
+        return 0;
+    }
+
+}

Modified: geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java (original)
+++ geronimo/sandbox/blueprint/blueprint-api/src/main/java/org/osgi/service/blueprint/container/Converter.java Mon Jun 22 15:03:53 2009
@@ -17,33 +17,38 @@
 
 /**
  * Provides access to the type conversions (both predefined and user registered)
- * that are defined for the blueprint container.
+ * that are defined for the Blueprint Container.
  */
 public interface Converter {
 
 	/**
-	 * Check if the converter is able to convert the given value to the specified
-	 * type.
-	 * 
-	 * @param fromValue the object to be converted
-     * @param toType the type that the instance is to be converted to.
-     *        This will be either a Class object or a Type object.	 
-	 * @return <code>true</code> if the conversion is possible, <code>false</code> otherwise.
+	 * Check if the converter is able to convert the given value to the
+	 * specified type.
+	 *
+	 * @param s
+	 *            The source object to convert from
+	 * @param T
+	 *            The target type
+	 *
+	 * @return <code>true</code> if the conversion is possible,
+	 *         <code>false</code> otherwise.
 	 */
-	boolean canConvert(Object fromValue, Object toType);
+	boolean canConvert(Object s, CollapsedType T);
 
 	/**
-	 * Convert an object to an instance of the given class, using the built-in and 
-	 * user-registered type converters as necessary.
-	 * 
-	 * @param fromValue the object to be converted
-	 * @param toType the type that the instance is to be converted to.
-	 *        This will be either a Class object or a Type object.
+	 * Convert an object to an instance of the given class, using the built-in
+	 * and user-registered type converters as necessary.
+	 *
+	 * @param s
+	 *            The source object to convert from
+	 * @param T
+	 *            The target type
 	 * @return an instance of the class 'toType'
-	 * @throws Exception if the conversion cannot succeed. This exception is
-	 * checked because callers should expect that not all source objects
-	 * can be successfully converted.
+	 * @throws Exception
+	 *             if the conversion cannot succeed. This exception is checked
+	 *             because callers should expect that not all source objects can
+	 *             be successfully converted.
 	 */
-	Object convert(Object fromValue, Object toType) throws Exception;
-	
+	Object convert(Object s, CollapsedType T) throws Exception;
+
 }
\ No newline at end of file

Modified: geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedProperties.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedProperties.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedProperties.java (original)
+++ geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmManagedProperties.java Mon Jun 22 15:03:53 2009
@@ -42,6 +42,7 @@
 import org.osgi.framework.Constants;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -235,7 +236,7 @@
                             Class methodParameterType = method.getParameterTypes()[0];
                             Object propertyValue;
                             try {
-                                propertyValue = blueprintContainer.getConverter().convert(val, methodParameterType);
+                                propertyValue = blueprintContainer.getConverter().convert(val, new CollapsedType(methodParameterType));
                             } catch (Throwable t) {
                                 LOGGER.debug("Unable to convert value for setter: " + method, t);
                                 continue;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java Mon Jun 22 15:03:53 2009
@@ -21,7 +21,6 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -41,20 +40,18 @@
 import org.apache.geronimo.blueprint.ExtendedServiceReferenceMetadata;
 import org.apache.geronimo.blueprint.di.AbstractRecipe;
 import org.apache.geronimo.blueprint.di.Recipe;
-import org.apache.geronimo.blueprint.di.ExecutionContext;
 import org.apache.geronimo.blueprint.utils.BundleDelegatingClassLoader;
 import org.apache.geronimo.blueprint.utils.ReflectionUtils;
-import org.apache.geronimo.blueprint.utils.TypeUtils;
-import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -195,7 +192,7 @@
         return classes;
     }
 
-    protected Type loadType(String typeName, ClassLoader fromClassLoader) {
+    protected CollapsedType loadType(String typeName, ClassLoader fromClassLoader) {
         if (typeName == null) {
             return null;
         }
@@ -204,7 +201,7 @@
             // because proxies can be created outside of the recipe creation which
             // would lead to an exception because the context is not set
             // TODO: consider having the context as a property on the recipe rather than a thread local
-            return TypeUtils.parseJavaType(typeName, fromClassLoader != null ? fromClassLoader : blueprintContainer);
+            return GenericType.parse(typeName, fromClassLoader != null ? fromClassLoader : blueprintContainer);
         } catch (ClassNotFoundException e) {
             throw new ComponentDefinitionException("Unable to load class " + typeName + " from recipe " + this, e);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AggregateConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AggregateConverter.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AggregateConverter.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AggregateConverter.java Mon Jun 22 15:03:53 2009
@@ -17,25 +17,26 @@
 package org.apache.geronimo.blueprint.container;
 
 import java.io.ByteArrayInputStream;
+import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Array;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
-import java.util.Properties;
-import java.util.Collection;
 import java.util.Map;
+import java.util.Properties;
 import java.util.regex.Pattern;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
-import org.apache.geronimo.blueprint.di.MapRecipe;
 import org.apache.geronimo.blueprint.di.CollectionRecipe;
+import org.apache.geronimo.blueprint.di.MapRecipe;
 import static org.apache.geronimo.blueprint.utils.ReflectionUtils.getRealCause;
-import org.apache.geronimo.blueprint.utils.TypeUtils;
-import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.Converter;
 
 /**
@@ -53,6 +54,15 @@
  */
 public class AggregateConverter implements Converter {
 
+    /**
+     * Objects implementing this interface will bypass the default conversion rules
+     * and be called directly to transform into the expected type.
+     */
+    public static interface Convertible {
+
+        Object convert(CollapsedType type) throws Exception;
+    }
+
     private ExtendedBlueprintContainer blueprintContainer;
     private List<Converter> converters = new ArrayList<Converter>();
 
@@ -68,47 +78,42 @@
         converters.remove(converter);
     }
 
-    public boolean canConvert(Object fromValue, Object toType) {
+    public boolean canConvert(Object fromValue, CollapsedType toType) {
         if (fromValue == null) {
             return true;
         }
-        Type type = (Type) toType;
-        if (TypeUtils.isInstance(type, fromValue)) {
+        if (isAssignable(fromValue, toType)) {
             return true;
         }
         for (Converter converter : converters) {
-            if (converter.canConvert(fromValue, type)) {
+            if (converter.canConvert(fromValue, toType)) {
                 return true;
             }
         }
+        // TODO
         if (fromValue instanceof String) {
-
+            //
         }
         return false;
     }
 
-    public Object convert(Object fromValue, Object toType) throws Exception {
+    public Object convert(Object fromValue, CollapsedType type) throws Exception {
         // Discard null values
         if (fromValue == null) {
             return null;
         }
-        Type type = (Type) toType;
         // 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
-        // We need to pass through for arrays / maps / collections because of genenrics
-        if (TypeUtils.isInstance(type, fromValue)
-                && !toClass(type).isArray()
-                && !Map.class.isAssignableFrom(toClass(type))
-                && !Collection.class.isAssignableFrom(toClass(type))) {
+        if (isAssignable(fromValue, type)) {
             return fromValue;
         }
         Object value = convertWithConverters(fromValue, type);
         if (value == null) {
-            if (fromValue instanceof String && toType instanceof Class) {
-                return convertFromString((String) fromValue, (Class) type, blueprintContainer);
+            if (fromValue instanceof String) {
+                return convertFromString((String) fromValue, toClass(type), blueprintContainer);
             } else if (toClass(type).isArray()) {
                 return convertArray(fromValue, type);
             } else if (Map.class.isAssignableFrom(toClass(type))) {
@@ -118,12 +123,11 @@
             } else {
                 throw new Exception("Unable to convert value " + fromValue + " to type " + type);
             }
-        } else {
-            return value;
         }
+        return value;
     }
 
-    private Object convertWithConverters(Object source, Type type) throws Exception {
+    private Object convertWithConverters(Object source, CollapsedType type) throws Exception {
         Object value = null;
         for (Converter converter : converters) {
             if (converter.canConvert(source, type)) {
@@ -136,10 +140,16 @@
         return value;
     }
 
-    public static Object convertFromString(String value, Class toType, Object loader) throws Exception {
-        if (Class.class == toType || Type.class == toType) {
+    public Object convertFromString(String value, Class toType, Object loader) throws Exception {
+        if (CollapsedType.class == toType && blueprintContainer.getCompliance() == BlueprintContainer.COMPLIANCE_LOOSE) {
             try {
-                return TypeUtils.parseJavaType(value, loader);
+                return GenericType.parse(value, loader);
+            } catch (ClassNotFoundException e) {
+                throw new Exception("Unable to convert", e);
+            }
+        } else if (Class.class == toType) {
+            try {
+                return GenericType.parse(value, loader).getRawClass();
             } catch (ClassNotFoundException e) {
                 throw new Exception("Unable to convert", e);
             }
@@ -214,12 +224,8 @@
         }
     }
 
-    private Object convertCollection(Object obj, Type type) throws Exception {
-        Type valueType = Object.class;
-        Type[] typeParameters = TypeUtils.getTypeParameters(Collection.class, type);
-        if (typeParameters != null && typeParameters.length == 1) {
-            valueType = typeParameters[0];
-        }
+    private Object convertCollection(Object obj, CollapsedType type) throws Exception {
+        CollapsedType valueType = type.getActualTypeArgument(0);
         Collection newCol = (Collection) CollectionRecipe.getCollection(toClass(type)).newInstance();
         if (obj.getClass().isArray()) {
             for (int i = 0; i < Array.getLength(obj); i++) {
@@ -241,14 +247,9 @@
         return newCol;
     }
 
-    private Object convertMap(Object obj, Type type) throws Exception {
-        Type keyType = Object.class;
-        Type valueType = Object.class;
-        Type[] typeParameters = TypeUtils.getTypeParameters(Map.class, type);
-        if (typeParameters != null && typeParameters.length == 2) {
-            keyType = typeParameters[0];
-            valueType = typeParameters[1];
-        }
+    private Object convertMap(Object obj, CollapsedType type) throws Exception {
+        CollapsedType keyType = type.getActualTypeArgument(0);
+        CollapsedType valueType = type.getActualTypeArgument(1);
         Map newMap = (Map) MapRecipe.getMap(toClass(type)).newInstance();
         for (Map.Entry e : ((Map<Object,Object>) obj).entrySet()) {
             try {
@@ -260,17 +261,15 @@
         return newMap;
     }
 
-    private Object convertArray(Object obj, Type type) throws Exception {
+    private Object convertArray(Object obj, CollapsedType type) throws Exception {
         if (obj instanceof Collection) {
             obj = ((Collection) obj).toArray();
         }
         if (!obj.getClass().isArray()) {
             throw new Exception("Unable to convert from " + obj + " to " + type);
         }
-        Type componentType = type instanceof GenericArrayType
-                                    ? ((GenericArrayType) type).getGenericComponentType()
-                                    : toClass(type).getComponentType();
-        Object array = Array.newInstance(TypeUtils.toClass(componentType), Array.getLength(obj));
+        CollapsedType componentType = type.getActualTypeArgument(0);
+        Object array = Array.newInstance(toClass(componentType), Array.getLength(obj));
         for (int i = 0; i < Array.getLength(obj); i++) {
             try {
                 Array.set(array, i, convert(Array.get(obj, i), componentType));
@@ -281,12 +280,67 @@
         return array;
     }
 
-    /**
-     * Objects implementing this interface will bypass the default conversion rules
-     * and be called directly to transform into the expected type.
-     */
-    public static interface Convertible {
+    // TODO need to do proper disambiguation
+    private <T> Constructor<T> getDisambiguatedConstructor(Class<T> t, Class<?> s) {
+        for (Constructor<T> c : t.getConstructors()) {
+            if (c.getParameterTypes().length == 1
+                    && c.getParameterTypes()[0] == s) {
+                return c;
+            }
+        }
+        for (Constructor<T> c : t.getConstructors()) {
+            if (c.getParameterTypes().length == 1
+                    && c.getParameterTypes()[0].isAssignableFrom(s)) {
+                return c;
+            }
+        }
+        return null;
+    }
+
+    private Collection<?> getAsCollection(Object s) {
+        if (s.getClass().isArray())
+            return Arrays.asList((Object[]) s);
+        else if (Collection.class.isAssignableFrom(s.getClass()))
+            return (Collection<?>) s;
+        else
+            return null;
+    }
 
-        Object convert(Type type) throws Exception;
+    private boolean isAssignable(Object source, CollapsedType target) {
+        return target.size() == 0
+                && unwrap(target.getRawClass()).isAssignableFrom(unwrap(source.getClass()));
     }
+
+    private static Class unwrap(Class c) {
+        Class u = primitives.get(c);
+        return u != null ? u : c;
+    }
+
+    private static final Map<Class, Class> primitives;
+    static {
+        primitives = new HashMap<Class, Class>();
+        primitives.put(byte.class, Byte.class);
+        primitives.put(short.class, Short.class);
+        primitives.put(char.class, Character.class);
+        primitives.put(int.class, Integer.class);
+        primitives.put(long.class, Long.class);
+        primitives.put(float.class, Float.class);
+        primitives.put(double.class, Double.class);
+        primitives.put(boolean.class, Boolean.class);
+    }
+
+    public Object convert(Object source, Type target) throws Exception {
+        return convert( source, new GenericType(target));
+    }
+
+
+    private Class<?> loadClass(String s) throws Exception {
+
+        return blueprintContainer.loadClass(s);
+    }
+
+    private Class toClass(CollapsedType type) {
+        return type.getRawClass();
+    }
+
 }
\ No newline at end of file

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BeanRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BeanRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BeanRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BeanRecipe.java Mon Jun 22 15:03:53 2009
@@ -36,8 +36,8 @@
 import org.apache.geronimo.blueprint.di.Recipe;
 import org.apache.geronimo.blueprint.utils.ReflectionUtils;
 import static org.apache.geronimo.blueprint.utils.ReflectionUtils.getRealCause;
-import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
 import static org.apache.geronimo.blueprint.utils.TypeUtils.isInstance;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -160,11 +160,13 @@
 
     @Override
     protected Class loadClass(String className) {
-        return toClass(loadType(className, type instanceof Class ? ((Class) type).getClassLoader() : null));
+        ClassLoader loader = type instanceof Class ? ((Class) type).getClassLoader() : null;
+        CollapsedType t = loadType(className, loader);
+        return t != null ? t.getRawClass() : null;
     }
 
     @Override
-    protected Type loadType(String className) {
+    protected CollapsedType loadType(String className) {
         return loadType(className, type instanceof Class ? ((Class) type).getClassLoader() : null);
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java Mon Jun 22 15:03:53 2009
@@ -63,12 +63,12 @@
 import org.osgi.service.blueprint.reflect.BeanProperty;
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 import org.osgi.service.blueprint.reflect.PropsMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
 import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintExtender.java Mon Jun 22 15:03:53 2009
@@ -20,7 +20,6 @@
 
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
@@ -36,8 +35,8 @@
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
-import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.framework.Constants;
+import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.BlueprintEvent;
 import org.slf4j.Logger;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintRepository.java Mon Jun 22 15:03:53 2009
@@ -18,31 +18,31 @@
 package org.apache.geronimo.blueprint.container;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.LinkedHashMap;
-import java.util.Collections;
-import java.util.Collection;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.lang.reflect.Type;
 
+import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
+import org.apache.geronimo.blueprint.di.CircularDependencyException;
+import org.apache.geronimo.blueprint.di.ExecutionContext;
+import org.apache.geronimo.blueprint.di.IdRefRecipe;
+import org.apache.geronimo.blueprint.di.Recipe;
+import org.apache.geronimo.blueprint.di.RefRecipe;
+import org.apache.geronimo.blueprint.di.Repository;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.container.NoSuchComponentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.geronimo.blueprint.di.Repository;
-import org.apache.geronimo.blueprint.di.Recipe;
-import org.apache.geronimo.blueprint.di.ExecutionContext;
-import org.apache.geronimo.blueprint.di.RefRecipe;
-import org.apache.geronimo.blueprint.di.IdRefRecipe;
-import org.apache.geronimo.blueprint.di.CircularDependencyException;
-import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
 
 /**
  * The default repository implementation
@@ -148,7 +148,7 @@
                 Object obj = createInstance(name);
                 try {
                     // Make sure to go through the conversion step in case we have a Convertible object
-                    obj = convert(obj, Object.class);
+                    obj = convert(obj, new CollapsedType(Object.class));
                 } catch (Exception e) {
                     throw new ComponentDefinitionException("Unable to convert instance " + name, e);
                 }
@@ -320,7 +320,7 @@
         return obj;
     }
 
-    public Object convert(Object value, Type type) throws Exception {
+    public Object convert(Object value, CollapsedType type) throws Exception {
         return blueprintContainer.getConverter().convert(value, type);
     }
 

Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java?rev=787264&view=auto
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java (added)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/GenericType.java Mon Jun 22 15:03:53 2009
@@ -0,0 +1,169 @@
+package org.apache.geronimo.blueprint.container;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
+import org.apache.geronimo.blueprint.di.ExecutionContext;
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.container.CollapsedType;
+
+public class GenericType extends CollapsedType {
+
+	private static final GenericType[] EMPTY = new GenericType[0];
+
+    private static final Map<String, Class> primitiveClasses = new HashMap<String, Class>();
+
+    static {
+        primitiveClasses.put("int", int.class);
+        primitiveClasses.put("short", short.class);
+        primitiveClasses.put("long", long.class);
+        primitiveClasses.put("byte", byte.class);
+        primitiveClasses.put("char", char.class);
+        primitiveClasses.put("float", float.class);
+        primitiveClasses.put("double", double.class);
+        primitiveClasses.put("boolean", boolean.class);
+    }
+
+    private GenericType[] parameters;
+
+	public GenericType(Type type) {
+		this(getConcreteClass(type), parametersOf(type));
+	}
+
+    public GenericType(Class clazz, GenericType... parameters) {
+        super(clazz);
+        this.parameters = parameters;
+    }
+
+    public static GenericType parse(String type, Object loader) throws ClassNotFoundException, IllegalArgumentException {
+        type = type.trim();
+        // Check if this is an array
+        if (type.endsWith("[]")) {
+            GenericType t = parse(type.substring(0, type.length() - 2), loader);
+            return new GenericType(Array.newInstance(t.getRawClass(), 0).getClass(), t);
+        }
+        // Check if this is a generic
+        int genericIndex = type.indexOf('<');
+        if (genericIndex > 0) {
+            if (!type.endsWith(">")) {
+                throw new IllegalArgumentException("Can not load type: " + type);
+            }
+            GenericType base = parse(type.substring(0, genericIndex), loader);
+            String[] params = type.substring(genericIndex + 1, type.length() - 1).split(",");
+            GenericType[] types = new GenericType[params.length];
+            for (int i = 0; i < params.length; i++) {
+                types[i] = parse(params[i], loader);
+            }
+            return new GenericType(base.getRawClass(), types);
+        }
+        // Primitive
+        if (primitiveClasses.containsKey(type)) {
+            return new GenericType(primitiveClasses.get(type));
+        }
+        // Class
+        if (loader instanceof ClassLoader) {
+            return new GenericType(((ClassLoader) loader).loadClass(type));
+        } else if (loader instanceof Bundle) {
+            return new GenericType(((Bundle) loader).loadClass(type));
+        } else if (loader instanceof ExecutionContext) {
+            return new GenericType(((ExecutionContext) loader).loadClass(type));
+        } else if (loader instanceof ExtendedBlueprintContainer) {
+            return new GenericType(((ExtendedBlueprintContainer) loader).loadClass(type));
+        } else {
+            throw new IllegalArgumentException("Unsupported loader: " + loader);
+        }
+    }
+
+    @Override
+    public CollapsedType getActualTypeArgument(int i) {
+        if (parameters.length == 0) {
+            return super.getActualTypeArgument(i);
+        }
+        return parameters[i];
+    }
+
+    @Override
+    public int size() {
+        return parameters.length;
+    }
+
+    @Override
+    public String toString() {
+        Class cl = getRawClass();
+        if (cl.isArray()) {
+            return parameters[0].toString() + "[]";
+        }
+        if (parameters.length > 0) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(cl.getName());
+            sb.append("<");
+            for (int i = 0; i < parameters.length; i++) {
+                if (i > 0) {
+                    sb.append(",");
+                }
+                sb.append(parameters[i].toString());
+            }
+            sb.append(">");
+            return sb.toString();
+        }
+        return cl.getName();
+    }
+
+    static GenericType[] parametersOf(Type type ) {
+		if ( type instanceof Class )
+			return EMPTY;
+        if ( type instanceof ParameterizedType ) {
+            ParameterizedType pt = (ParameterizedType) type;
+            Type [] parameters = pt.getActualTypeArguments();
+            GenericType[] gts = new GenericType[parameters.length];
+            for ( int i =0; i<gts.length; i++) {
+                gts[i] = new GenericType(parameters[i]);
+            }
+            return gts;
+        }
+        if ( type instanceof GenericArrayType ) {
+            return new GenericType[] { new GenericType(((GenericArrayType) type).getGenericComponentType()) };
+        }
+        throw new IllegalStateException();
+	}
+
+	static Class<?> getConcreteClass(Type type) {
+		Type ntype = collapse(type);
+		if ( ntype instanceof Class )
+			return (Class<?>) ntype;
+
+		if ( ntype instanceof ParameterizedType )
+			return getConcreteClass(collapse(((ParameterizedType)ntype).getRawType()));
+
+		throw new RuntimeException("Unknown type " + type );
+	}
+
+	static Type collapse(Type target) {
+		if (target instanceof Class || target instanceof ParameterizedType ) {
+			return target;
+		} else if (target instanceof TypeVariable) {
+			return collapse(((TypeVariable<?>) target).getBounds()[0]);
+		} else if (target instanceof GenericArrayType) {
+			Type t = collapse(((GenericArrayType) target)
+					.getGenericComponentType());
+			while ( t instanceof ParameterizedType )
+				t = collapse(((ParameterizedType)t).getRawType());
+			return Array.newInstance((Class<?>)t, 0).getClass();
+		} else if (target instanceof WildcardType) {
+			WildcardType wct = (WildcardType) target;
+			if (wct.getLowerBounds().length == 0)
+				return collapse(wct.getUpperBounds()[0]);
+			else
+				return collapse(wct.getLowerBounds()[0]);
+		}
+		throw new RuntimeException("Huh? " + target);
+	}
+
+}

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java Mon Jun 22 15:03:53 2009
@@ -56,13 +56,13 @@
 import org.apache.geronimo.blueprint.reflect.BeanPropertyImpl;
 import org.apache.geronimo.blueprint.reflect.CollectionMetadataImpl;
 import org.apache.geronimo.blueprint.reflect.IdRefMetadataImpl;
-import org.apache.geronimo.blueprint.reflect.ReferenceListenerImpl;
 import org.apache.geronimo.blueprint.reflect.MapEntryImpl;
 import org.apache.geronimo.blueprint.reflect.MapMetadataImpl;
 import org.apache.geronimo.blueprint.reflect.MetadataUtil;
 import org.apache.geronimo.blueprint.reflect.PropsMetadataImpl;
 import org.apache.geronimo.blueprint.reflect.RefListMetadataImpl;
 import org.apache.geronimo.blueprint.reflect.RefMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.ReferenceListenerImpl;
 import org.apache.geronimo.blueprint.reflect.ReferenceMetadataImpl;
 import org.apache.geronimo.blueprint.reflect.RegistrationListenerImpl;
 import org.apache.geronimo.blueprint.reflect.ServiceMetadataImpl;
@@ -76,7 +76,6 @@
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.IdRefMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
@@ -85,6 +84,7 @@
 import org.osgi.service.blueprint.reflect.PropsMetadata;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java Mon Jun 22 15:03:53 2009
@@ -30,7 +30,6 @@
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
 import org.apache.geronimo.blueprint.di.ArrayRecipe;
 import org.apache.geronimo.blueprint.di.CollectionRecipe;
-import org.apache.geronimo.blueprint.container.BlueprintRepository;
 import org.apache.geronimo.blueprint.di.IdRefRecipe;
 import org.apache.geronimo.blueprint.di.MapRecipe;
 import org.apache.geronimo.blueprint.di.Recipe;
@@ -45,7 +44,6 @@
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.IdRefMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
@@ -53,6 +51,7 @@
 import org.osgi.service.blueprint.reflect.PropsMetadata;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java Mon Jun 22 15:03:53 2009
@@ -24,20 +24,20 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.RandomAccess;
-import java.util.Collections;
 import java.util.concurrent.Callable;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
 import org.apache.geronimo.blueprint.ExtendedRefListMetadata;
 import org.apache.geronimo.blueprint.di.Recipe;
 import org.apache.geronimo.blueprint.utils.DynamicCollection;
-import org.apache.geronimo.blueprint.utils.TypeUtils;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.container.ServiceUnavailableException;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
@@ -230,9 +230,9 @@
 
     public class ProvidedObject implements AggregateConverter.Convertible {
 
-        public Object convert(Type type) {
+        public Object convert(CollapsedType type) {
             LOGGER.debug("Converting ManagedCollection to {}", type);
-            if (!TypeUtils.toClass(type).isAssignableFrom(List.class)) {
+            if (!type.getRawClass().isAssignableFrom(List.class)) {
                 throw new ComponentDefinitionException("<ref-list/> can only be converted to a List, not " + type);
             }
             boolean useRef = false;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java Mon Jun 22 15:03:53 2009
@@ -18,16 +18,15 @@
  */
 package org.apache.geronimo.blueprint.container;
 
-import java.lang.reflect.Type;
-import java.util.List;
 import java.util.Collections;
+import java.util.List;
 import java.util.concurrent.Callable;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
 import org.apache.geronimo.blueprint.di.Recipe;
-import org.apache.geronimo.blueprint.utils.TypeUtils;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.blueprint.container.BlueprintEvent;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.container.ServiceUnavailableException;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
@@ -207,10 +206,10 @@
 
     public class ServiceProxyWrapper implements AggregateConverter.Convertible {
 
-        public Object convert(Type type) throws Exception {
-            if (type == ServiceReference.class) {
+        public Object convert(CollapsedType type) throws Exception {
+            if (type.getRawClass() == ServiceReference.class) {
                 return getServiceReference();
-            } else if (TypeUtils.toClass(type).isInstance(proxy)) {
+            } else if (type.getRawClass().isInstance(proxy)) {
                 return proxy;
             } else {
                 throw new ComponentDefinitionException("Unable to convert to " + type);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/AbstractRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/AbstractRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/AbstractRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/AbstractRecipe.java Mon Jun 22 15:03:53 2009
@@ -18,14 +18,10 @@
 package org.apache.geronimo.blueprint.di;
 
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 
+import org.apache.geronimo.blueprint.container.GenericType;
+import org.osgi.service.blueprint.container.CollapsedType;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
-import org.apache.geronimo.blueprint.utils.TypeUtils;
 
 public abstract class AbstractRecipe implements Recipe {
 
@@ -86,24 +82,29 @@
         ExecutionContext.Holder.getContext().addObject(name, obj, partial);
     }
     
-    protected Object convert(Object obj, Type type) throws Exception {
+    protected Object convert(Object obj, CollapsedType type) throws Exception {
         return ExecutionContext.Holder.getContext().convert(obj, type);
     }
 
+    protected Object convert(Object obj, Type type) throws Exception {
+        return ExecutionContext.Holder.getContext().convert(obj, new GenericType(type));
+    }
+
     protected Class loadClass(String className) {
-        return toClass(loadType(className, null));
+        CollapsedType t = loadType(className, null);
+        return t != null ? t.getRawClass() : null;
     }
 
-    protected Type loadType(String typeName) {
+    protected CollapsedType loadType(String typeName) {
         return loadType(typeName, null);
     }
 
-    protected Type loadType(String typeName, ClassLoader fromClassLoader) {
+    protected CollapsedType loadType(String typeName, ClassLoader fromClassLoader) {
         if (typeName == null) {
             return null;
         }
         try {
-            return TypeUtils.parseJavaType(typeName, fromClassLoader != null ? fromClassLoader : ExecutionContext.Holder.getContext());
+            return GenericType.parse(typeName, fromClassLoader != null ? fromClassLoader : ExecutionContext.Holder.getContext());
         } catch (ClassNotFoundException e) {
             throw new ComponentDefinitionException("Unable to load class " + typeName + " from recipe " + this, e);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ArrayRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ArrayRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ArrayRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ArrayRecipe.java Mon Jun 22 15:03:53 2009
@@ -21,8 +21,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.CollapsedType;
 
 /**
  * @version $Rev$ $Date$
@@ -49,21 +50,21 @@
     }
 
     protected Object internalCreate() throws ComponentDefinitionException {
-        Type type;
+        CollapsedType type;
         if (this.type instanceof Class) {
-            type = (Class) this.type;
+            type = new CollapsedType((Class) this.type);
         } else if (this.type instanceof String) {
             type = loadType((String) this.type);
         } else {
-            type = Object.class;
+            type = new CollapsedType(Object.class);
         }
 
         // create array instance
         Object array;
         try {
-            array = Array.newInstance(toClass(type), list.size());
+            array = Array.newInstance(type.getRawClass(), list.size());
         } catch (Exception e) {
-            throw new ComponentDefinitionException("Error while creating array instance: " + toClass(type));
+            throw new ComponentDefinitionException("Error while creating array instance: " + type);
         }
 
         int index = 0;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/CollectionRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/CollectionRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/CollectionRecipe.java Mon Jun 22 15:03:53 2009
@@ -18,13 +18,13 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Queue;
+import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import java.util.Set;
-import java.util.LinkedHashSet;
-import java.util.Queue;
-import java.util.LinkedList;
 
 import org.apache.geronimo.blueprint.utils.TypeUtils;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java Mon Jun 22 15:03:53 2009
@@ -17,8 +17,7 @@
  */
 package org.apache.geronimo.blueprint.di;
 
-import java.lang.reflect.Type;
-import java.util.List;
+import org.osgi.service.blueprint.container.CollapsedType;
 
 public interface ExecutionContext {
 
@@ -93,7 +92,7 @@
     
     public abstract Object getPartialObject(String name);
 
-    public abstract Object convert(Object value, Type type) throws Exception;
+    public abstract Object convert(Object value, CollapsedType type) throws Exception;
 
     public abstract Class loadClass(String className) throws ClassNotFoundException;
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/MapRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/MapRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/MapRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/MapRecipe.java Mon Jun 22 15:03:53 2009
@@ -19,14 +19,14 @@
 import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Dictionary;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import java.util.LinkedHashMap;
-import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import org.apache.geronimo.blueprint.utils.TypeUtils;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java Mon Jun 22 15:03:53 2009
@@ -17,10 +17,10 @@
  */
 package org.apache.geronimo.blueprint.di;
 
-import java.util.Set;
-import java.util.Map;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java Mon Jun 22 15:03:53 2009
@@ -19,8 +19,8 @@
 package org.apache.geronimo.blueprint.di;
 
 import java.lang.reflect.Type;
-import java.util.List;
 import java.util.Collections;
+import java.util.List;
 
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.reflect.ValueMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java Mon Jun 22 15:03:53 2009
@@ -29,10 +29,10 @@
 import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableBeanProperty;
 import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableReferenceListener;
 import org.apache.geronimo.blueprint.mutable.MutableMapEntry;
 import org.apache.geronimo.blueprint.mutable.MutableMapMetadata;
 import org.apache.geronimo.blueprint.mutable.MutablePropsMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableReferenceListener;
 import org.apache.geronimo.blueprint.mutable.MutableRegistrationListener;
 import org.apache.geronimo.blueprint.mutable.MutableServiceMetadata;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
@@ -40,13 +40,13 @@
 import org.osgi.service.blueprint.reflect.BeanMetadata;
 import org.osgi.service.blueprint.reflect.BeanProperty;
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 import org.osgi.service.blueprint.reflect.NonNullMetadata;
 import org.osgi.service.blueprint.reflect.PropsMetadata;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceListener;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java Mon Jun 22 15:03:53 2009
@@ -17,11 +17,11 @@
 
 package org.apache.geronimo.blueprint.reflect;
 
+import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
-import java.io.Serializable;
 
 import org.osgi.service.blueprint.reflect.BeanArgument;
 import org.osgi.service.blueprint.reflect.BeanMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/TypeUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/TypeUtils.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/TypeUtils.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/TypeUtils.java Mon Jun 22 15:03:53 2009
@@ -23,14 +23,12 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
-import java.util.Map;
 import java.util.HashMap;
-import java.util.Collection;
+import java.util.Map;
 
-import org.osgi.framework.Bundle;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.apache.geronimo.blueprint.di.ExecutionContext;
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
+import org.apache.geronimo.blueprint.di.ExecutionContext;
+import org.osgi.framework.Bundle;
 
 /**
  * @version $Rev: 6687 $ $Date: 2005-12-28T21:08:56.733437Z $
@@ -89,13 +87,6 @@
         return instance == null || type.isInstance(instance);
     }
 
-    public static boolean isAssignable(Type expectedType, Type actualType) {
-        // TODO: check parameterized Collection / Maps / Arrays ?
-        Class expectedClass = toClass(expectedType);
-        Class actualClass = toClass(actualType);
-        return expectedClass.isAssignableFrom(actualClass);
-    }
-
     public static Class toClass(Type type) {
         // GenericArrayType, ParameterizedType, TypeVariable<D>, WildcardType
         if (type instanceof Class) {
@@ -113,165 +104,4 @@
         }
     }
 
-    public static Type[] getTypeParameters(Class desiredType, Type type) {
-        if (type instanceof Class) {
-            Class rawClass = (Class) type;
-
-            // if this is the collection class we're done
-            if (desiredType.equals(type)) {
-                return null;
-            }
-
-            for (Type intf : rawClass.getGenericInterfaces()) {
-                Type[] collectionType = getTypeParameters(desiredType, intf);
-                if (collectionType != null) {
-                    return collectionType;
-                }
-            }
-
-            Type[] collectionType = getTypeParameters(desiredType, rawClass.getGenericSuperclass());
-            return collectionType;
-        } else if (type instanceof ParameterizedType) {
-            ParameterizedType parameterizedType = (ParameterizedType) type;
-
-            Type rawType = parameterizedType.getRawType();
-            if (desiredType.equals(rawType)) {
-                Type[] argument = parameterizedType.getActualTypeArguments();
-                return argument;
-            }
-            Type[] collectionTypes = getTypeParameters(desiredType,rawType);
-            if (collectionTypes != null) {
-                for (int i = 0; i < collectionTypes.length; i++) {
-                    if (collectionTypes[i] instanceof TypeVariable) {
-                        TypeVariable typeVariable = (TypeVariable) collectionTypes[i];
-                        TypeVariable[] rawTypeParams = ((Class) rawType).getTypeParameters();
-                        for (int j = 0; j < rawTypeParams.length; j++) {
-                            if (typeVariable.getName().equals(rawTypeParams[j].getName())) {
-                                collectionTypes[i] = parameterizedType.getActualTypeArguments()[j];
-                            }
-                        }
-                    }
-                }
-            }
-            return collectionTypes;
-        }
-        return null;
-    }
-
-    private static Map<String, Class> primitiveClasses = new HashMap<String, Class>();
-
-    static {
-        primitiveClasses.put("int", int.class);
-        primitiveClasses.put("short", short.class);
-        primitiveClasses.put("long", long.class);
-        primitiveClasses.put("byte", byte.class);
-        primitiveClasses.put("char", char.class);
-        primitiveClasses.put("float", float.class);
-        primitiveClasses.put("double", double.class);
-        primitiveClasses.put("boolean", boolean.class);
-    }
-
-    public static Type parseJavaType(String type, Object loader) throws ClassNotFoundException {
-        // TODO: support wilcards for generics
-        type = type.trim();
-        // Check if this is an array
-        if (type.endsWith("[]")) {
-            return new GenericArrayTypeImpl(parseJavaType(type.substring(0, type.length() - 2), loader));
-        }
-        // Check if this is a generic
-        int genericIndex = type.indexOf('<');
-        if (genericIndex > 0) {
-            if (!type.endsWith(">")) {
-                throw new IllegalArgumentException("Can not load type: " + type);
-            }
-            Type base = parseJavaType(type.substring(0, genericIndex), loader);
-            String[] params = type.substring(genericIndex + 1, type.length() - 1).split(",");
-            Type[] types = new Type[params.length];
-            for (int i = 0; i < params.length; i++) {
-                types[i] = parseJavaType(params[i], loader);
-            }
-            return new ParameterizedTypeImpl(base, types);
-        }
-        // Primitive
-        if (primitiveClasses.containsKey(type)) {
-            return primitiveClasses.get(type);
-        }
-        // Class
-        if (loader instanceof ClassLoader) {
-            return ((ClassLoader) loader).loadClass(type);
-        } else if (loader instanceof Bundle) {
-            return ((Bundle) loader).loadClass(type);
-        } else if (loader instanceof ExecutionContext) {
-            return ((ExecutionContext) loader).loadClass(type);
-        } else if (loader instanceof ExtendedBlueprintContainer) {
-            return ((ExtendedBlueprintContainer) loader).loadClass(type); 
-        } else {
-            throw new IllegalArgumentException("Unsupported loader: " + loader);
-        }
-    }
-
-    private static class ParameterizedTypeImpl implements ParameterizedType {
-
-        private final Type base;
-        private final Type[] params;
-
-        private ParameterizedTypeImpl(Type base, Type[] params) {
-            this.base = base;
-            this.params = params;
-        }
-
-        public Type[] getActualTypeArguments() {
-            return params;
-        }
-
-        public Type getRawType() {
-            return base;
-        }
-
-        public Type getOwnerType() {
-            return null;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder sb = new StringBuilder();
-            sb.append(getDescription(base));
-            sb.append("<");
-            for (int i = 0; i < params.length; i++) {
-                if (i > 0) {
-                    sb.append(",");
-                }
-                sb.append(getDescription(params[i]));
-            }
-            sb.append(">");
-            return sb.toString();
-        }
-    }
-
-    private static class GenericArrayTypeImpl implements GenericArrayType {
-
-        private final Type genericComponentType;
-
-        private GenericArrayTypeImpl(Type genericComponentType) {
-            this.genericComponentType = genericComponentType;
-        }
-
-        public Type getGenericComponentType() {
-            return genericComponentType;
-        }
-
-        @Override
-        public String toString() {
-            return getDescription(genericComponentType) + "[]";
-        }
-    }
-
-    private static String getDescription(Type type) {
-        if (type instanceof Class) {
-            return ((Class) type).getName();
-        } else {
-            return type.toString();
-        }
-    }
-
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/AbstractBlueprintTest.java Mon Jun 22 15:03:53 2009
@@ -22,10 +22,9 @@
 import java.util.Collections;
 
 import junit.framework.TestCase;
-import org.apache.geronimo.blueprint.NamespaceHandler;
-import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
-import org.apache.geronimo.blueprint.container.Parser;
 import org.apache.geronimo.blueprint.container.NamespaceHandlerRegistry;
+import org.apache.geronimo.blueprint.container.Parser;
+import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
 
 public abstract class AbstractBlueprintTest extends TestCase {
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/ParserTest.java Mon Jun 22 15:03:53 2009
@@ -26,11 +26,8 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import org.apache.geronimo.blueprint.reflect.BeanMetadataImpl;
-import org.apache.geronimo.blueprint.ComponentDefinitionRegistry;
-import org.apache.geronimo.blueprint.NamespaceHandler;
-import org.apache.geronimo.blueprint.ParserContext;
 import org.apache.geronimo.blueprint.container.NamespaceHandlerRegistry;
+import org.apache.geronimo.blueprint.reflect.BeanMetadataImpl;
 import org.osgi.service.blueprint.reflect.BeanArgument;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
 import org.osgi.service.blueprint.reflect.BeanProperty;
@@ -47,6 +44,11 @@
  */
 public class ParserTest extends AbstractBlueprintTest {
 
+    public void test() {
+        Integer[] oo = new Integer[1];
+        Object[] ii = oo;
+    }
+
     public void testParseComponent() throws Exception {
         ComponentDefinitionRegistry registry = parse("/test-simple-component.xml");
         assertNotNull(registry);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java?rev=787264&r1=787263&r2=787264&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java Mon Jun 22 15:03:53 2009
@@ -28,15 +28,15 @@
 import java.util.Set;
 
 import org.apache.geronimo.blueprint.CallbackTracker.Callback;
+import org.apache.geronimo.blueprint.di.Repository;
 import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
 import org.apache.geronimo.blueprint.pojos.BeanD;
+import org.apache.geronimo.blueprint.pojos.BeanF;
 import org.apache.geronimo.blueprint.pojos.Multiple;
 import org.apache.geronimo.blueprint.pojos.PojoA;
 import org.apache.geronimo.blueprint.pojos.PojoB;
 import org.apache.geronimo.blueprint.pojos.PojoGenerics;
 import org.apache.geronimo.blueprint.pojos.PojoListener;
-import org.apache.geronimo.blueprint.pojos.BeanF;
-import org.apache.geronimo.blueprint.di.Repository;
 import org.osgi.framework.ServiceRegistration;
 
 public class WiringTest extends AbstractBlueprintTest {