Add the HandlerFactory interface to avoid the ClassCastException when proxying factories (Issue Felix-552)
As a consequence, the archi command now target this kind of factory.
Some tests have been updated to reflect this change.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@656044 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java b/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
index d173645..5441df9 100644
--- a/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
+++ b/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
@@ -43,7 +43,7 @@
     private Factory[] m_factories;
     
     /** Handler Factories. */
-    private Factory[] m_handlers;
+    private HandlerFactory[] m_handlers;
 
     /**
      * Get the command name.
@@ -212,15 +212,14 @@
      */
     private void printHandlers(PrintStream out) {
         for (int i = 0; i < m_handlers.length; i++) {
-            HandlerFactory hf = (HandlerFactory) m_handlers[i];
-            String name = hf.getHandlerName();
-            if ("composite".equals(hf.getType())) {
+            String name = m_handlers[i].getHandlerName();
+            if ("composite".equals(m_handlers[i].getType())) {
                 name = name + " [composite]";
             }
-            if (hf.getMissingHandlers().size() == 0) {
+            if (m_handlers[i].getMissingHandlers().size() == 0) {
                 out.println("Handler " + name + " (VALID)");
             } else {
-                out.println("Handler " + name + " (INVALID : " + hf.getMissingHandlers() + ")");
+                out.println("Handler " + name + " (INVALID : " + m_handlers[i].getMissingHandlers() + ")");
             }
         }
     }
diff --git a/ipojo/arch/src/main/resources/metadata.xml b/ipojo/arch/src/main/resources/metadata.xml
index 9bb20ee..761b8d9 100644
--- a/ipojo/arch/src/main/resources/metadata.xml
+++ b/ipojo/arch/src/main/resources/metadata.xml
@@ -22,10 +22,8 @@
 		factory="false">
 		<Provides />
 		<Requires field="m_archs" optional="true" />
-		<Requires field="m_factories" optional="true"
-			filter="(!(handler.name=*))" />
-		<Requires field="m_handlers" optional="true"
-			filter="(handler.name=*)" />
+		<Requires field="m_factories" optional="true"/>
+		<Requires field="m_handlers" optional="true"/>
 	</Component>
 	<instance component="org.apache.felix.ipojo.arch.ArchCommandImpl"
 		name="ArchCommand" />
diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java
index 9c980a1..60432a8 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java
@@ -25,8 +25,8 @@
 import org.apache.felix.ipojo.ComponentFactory;

 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.ConfigurationException;

-import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

+import org.apache.felix.ipojo.HandlerFactory;

 import org.apache.felix.ipojo.HandlerManager;

 import org.apache.felix.ipojo.IPojoContext;

 import org.apache.felix.ipojo.MissingHandlerException;

@@ -118,7 +118,7 @@
     public synchronized void starting() {

         if (m_requiredHandlers.size() != 0) {

             try {

-                String filter = "(&(" + Constants.OBJECTCLASS + "=" + Factory.class.getName() + ")"

+                String filter = "(&(" + Constants.OBJECTCLASS + "=" + HandlerFactory.class.getName() + ")"

                     + "(" + Handler.HANDLER_TYPE_PROPERTY + "=" + CompositeHandler.HANDLER_TYPE + ")" 

                     + "(factory.state=1)"

                     + ")";

diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java
index 00537ea..3d10c51 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java
@@ -49,17 +49,17 @@
     /**

      * The context of the component.

      */

-    private BundleContext m_context;

+    private final BundleContext m_context;

 

     /**

      * Parent factory (ComponentFactory).

      */

-    private CompositeFactory m_factory;

+    private final CompositeFactory m_factory;

 

     /**

      * Composite Handler list.

      */

-    private HandlerManager[] m_handlers = new HandlerManager[0];

+    private HandlerManager[] m_handlers;

 

     /**

      * Instance State Listener List.

diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
index fcbec3c..a5b981f 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
@@ -30,6 +30,7 @@
 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.HandlerFactory;

 import org.apache.felix.ipojo.HandlerManager;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.MissingHandlerException;

 import org.apache.felix.ipojo.PolicyServiceContext;

 import org.apache.felix.ipojo.UnacceptableConfiguration;

diff --git a/ipojo/core/pom.xml b/ipojo/core/pom.xml
index d561153..803f13b 100644
--- a/ipojo/core/pom.xml
+++ b/ipojo/core/pom.xml
@@ -72,7 +72,7 @@
 						</Bundle-Activator>
 						<IPOJO-Extension>
 							component:org.apache.felix.ipojo.ComponentFactory,
-							handler:org.apache.felix.ipojo.HandlerFactory
+							handler:org.apache.felix.ipojo.HandlerManagerFactory
 						</IPOJO-Extension>
 						<Import-Package>
 							org.osgi.framework, org.osgi.service.cm,
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
index 9a10c73..1c30774 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
@@ -18,156 +18,45 @@
  */

 package org.apache.felix.ipojo;

 

-import java.util.Dictionary;

-

-import org.apache.felix.ipojo.architecture.ComponentTypeDescription;

-import org.apache.felix.ipojo.metadata.Element;

-import org.osgi.framework.BundleContext;

 

 /**

- * The component factory manages component instance objects. This management

- * consist in creating and managing component instance build with the component

- * factory. This class could export Factory and ManagedServiceFactory services.

- * 

+ * Service interface published by handler factory. 

  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

  */

-public class HandlerFactory extends ComponentFactory implements Factory {

+public interface HandlerFactory extends Factory {

 

     /**

      * iPOJO Default Namespace.

      */

-    public static final String IPOJO_NAMESPACE = "org.apache.felix.ipojo";

+    String IPOJO_NAMESPACE = "org.apache.felix.ipojo";

 

     /**

-     * Handler type (composite|primitive).

+     * Gets the namespace associated with this handler factory.

+     * @return the namespace used by this handler

      */

-    private final String m_type;

+    String getNamespace();

 

     /**

-     * iPOJO Handler Namespace.

-     * (Set the the iPOJO default namespace is not specified)

+     * Gets the name associated with this handler factory.

+     * @return the name used by this handler

      */

-    private final String m_namespace;

+    String getHandlerName();

 

     /**

-     * Handler start level.

-     * Lower level are priority are configured and started before higher level, and are stopped after. 

+     * Gets the type of created handler.

+     * The handler can only be plugged on instance container with the same type.

+     * Basically, types are primitive and composite.

+     * @return the types of the handler

      */

-    private final int m_level;

+    String getType();

 

     /**

-     * Creates a handler factory.

-     * @param context : bundle context

-     * @param metadata : metadata of the component to create

-     * @throws ConfigurationException occurs when the element describing the factory is malformed.

+     * Gets the start level of the handlers created by this factory.

+     * Handlers with a low start level are configured and started before 

+     * handlers with an higher start level. Moreover, these handlers are

+     * stopped and disposed after.

+     * @return the handler's start level

      */

-    public HandlerFactory(BundleContext context, Element metadata) throws ConfigurationException {

-        super(context, metadata);

+    int getStartLevel();

 

-        // Get the name

-        m_factoryName = metadata.getAttribute("name");

-        if (m_factoryName == null) { throw new ConfigurationException("An Handler needs a name"); }

-

-        // Get the type

-        String type = metadata.getAttribute("type");

-        if (type != null) {

-            m_type = type;

-        } else {

-            m_type = "primitive"; // Set to primitive if not specified.

-        }

-

-        String level = metadata.getAttribute("level");

-        if (level != null) {

-            m_level = new Integer(level).intValue();

-        } else {

-            m_level = Integer.MAX_VALUE; // Set to max if not specified.

-        }

-

-        // Get the namespace

-        String namespace = metadata.getAttribute("namespace");

-        if (namespace != null) {

-            m_namespace = namespace.toLowerCase();

-        } else {

-            m_namespace = IPOJO_NAMESPACE; // Set to the iPOJO default namespace if not specified.

-        }

-    }

-

-    public String getNamespace() {

-        return m_namespace;

-    }

-

-    public String getHandlerName() {

-        return m_namespace + ":" + getName();

-    }

-

-    public String getType() {

-        return m_type;

-    }

-

-    public int getStartLevel() {

-        return m_level;

-    }

-

-    public ComponentTypeDescription getComponentTypeDescription() {

-        return new HandlerTypeDescription(this);

-    }

-

-    /**

-     * Stops the factory.

-     * This method does not disposed created instances.

-     * These instances will be disposed by the instance managers.

-     * This method is called with the lock.

-     */

-    public void stopping() {

-        if (m_tracker != null) {

-            m_tracker.close();

-            m_tracker = null;

-        }

-    }

-

-    /**

-     * Creates an instance. The given configuration needs to contain the 'name'

-     * property. This method is called when holding the lock.

-     * @param configuration : configuration of the created instance.

-     * @param context : the service context to push for this instance.

-     * @param handlers : handler array to used.

-     * @return the created component instance.

-     * not consistent with the component type of this factory.

-     * @throws org.apache.felix.ipojo.ConfigurationException : when the instance configuration failed.

-     * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary)

-     */

-    public ComponentInstance createInstance(Dictionary configuration, IPojoContext context, HandlerManager[] handlers) throws ConfigurationException {

-        HandlerManager instance = new HandlerManager(this, context, handlers);

-        instance.configure(m_componentMetadata, configuration);

-        return instance;

-    }

-

-    private class HandlerTypeDescription extends ComponentTypeDescription {

-

-        /**

-         * Constructor.

-         * @param factory : factory.

-         */

-        public HandlerTypeDescription(Factory factory) {

-            super(factory);

-        }

-

-        /**

-         * Add properties to publish : 

-         * handler.name, handler.namespace, handler.type and handler.level if the level is not Integer.MAX.

-         * @return return the dictionary to publish.

-         * @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getPropertiesToPublish()

-         */

-        public Dictionary getPropertiesToPublish() {

-            Dictionary props = super.getPropertiesToPublish();

-

-            props.put(Handler.HANDLER_NAME_PROPERTY, m_factoryName);

-            props.put(Handler.HANDLER_NAMESPACE_PROPERTY, m_namespace);

-            props.put(Handler.HANDLER_TYPE_PROPERTY, m_type);

-            if (m_level != Integer.MAX_VALUE) {

-                props.put(Handler.HANDLER_LEVEL_PROPERTY, new Integer(m_level));

-            }

-            return props;

-        }

-    }

 }

diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
index 87cf4a9..a967e88 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
@@ -503,7 +503,7 @@
         if (m_isPublic) {

             // Exposition of the factory service

             m_sr =

-                    m_context.registerService(new String[] { Factory.class.getName(), ManagedServiceFactory.class.getName() }, this, m_componentDesc

+                    m_context.registerService(m_componentDesc.getFactoryInterfacesToPublish(), this, m_componentDesc

                             .getPropertiesToPublish());

         }

     }

diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java
index 39081d9..f49390e 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java
@@ -27,6 +27,7 @@
 import org.apache.felix.ipojo.metadata.Element;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.service.cm.ManagedServiceFactory;
 
 /**
  * Component Type description.
@@ -58,7 +59,7 @@
     }
 
     /**
-     * Get a printable form of the current component type description.
+     * Gets a printable form of the current component type description.
      * @return printable form of the component type description
      * @see java.lang.Object#toString()
      */
@@ -67,7 +68,7 @@
     }
 
     /**
-     * Get the implementation class of this component type.
+     * Gets the implementation class of this component type.
      * @return the component type implementation class name.
      */
     public String getClassName() {
@@ -75,7 +76,7 @@
     }
 
     /**
-     * Get component-type properties.
+     * Gets component-type properties.
      * @return the list of configuration properties accepted by the component type type.
      */
     public PropertyDescription[] getProperties() {
@@ -83,7 +84,7 @@
     }
 
     /**
-     * Add a String property in the component type.
+     * Adds a String property in the component type.
      * @param name : property name.
      * @param value : property value.
      */
@@ -92,7 +93,7 @@
     }
     
     /**
-     * Add a String property in the component type.
+     * Adds a String property in the component type.
      * @param name : property name.
      * @param value : property value.
      * @param immutable : the property is immutable.
@@ -103,7 +104,7 @@
     }
 
     /**
-     * Add a configuration properties to the component type.
+     * Adds a configuration properties to the component type.
      * @param pd : the property to add
      */
     public void addProperty(PropertyDescription pd) { //NOPMD remove the instance name of the 'name' property.
@@ -125,7 +126,7 @@
     }
 
     /**
-     * Get the list of provided service offered by instances of this type.
+     * Gets the list of provided service offered by instances of this type.
      * @return the list of the provided service.
      */
     public String[] getprovidedServiceSpecification() {
@@ -133,7 +134,7 @@
     }
 
     /**
-     * Add a provided service to the component type.
+     * Adds a provided service to the component type.
      * @param serviceSpecification : the provided service to add (interface name)
      */
     public void addProvidedServiceSpecification(String serviceSpecification) {
@@ -144,7 +145,7 @@
     }
 
     /**
-     * Return the component-type name.
+     * Returns the component-type name.
      * @return the name of this component type
      */
     public String getName() {
@@ -152,7 +153,7 @@
     }
     
     /**
-     * Compute the default service properties to publish : 
+     * Computes the default service properties to publish : 
      * factory.name, service.pid, component.providedServiceSpecification, component.properties, component.description, factory.State.
      * @return : the dictionary of properties to publish.
      */
@@ -180,10 +181,17 @@
 
     }
     
-    
-
     /**
-     * Get the component type description.
+     * Gets the interfaces published by the factory.
+     * By default publish both {@link Factory} and {@link ManagedServiceFactory}.
+     * @return : the list of interface published by the factory.
+     */
+    public String[] getFactoryInterfacesToPublish() {
+        return new String[] {Factory.class.getName(), ManagedServiceFactory.class.getName()};
+    }
+    
+    /**
+     * Gets the component type description.
      * @return : the description
      */
     public Element getDescription() {
diff --git a/ipojo/tests/tests.core.annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index 5eb2dc4..fcfe99b 100644
--- a/ipojo/tests/tests.core.annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -28,6 +28,7 @@
 import org.apache.felix.ipojo.Handler;

 import org.apache.felix.ipojo.HandlerFactory;

 import org.apache.felix.ipojo.ServiceContext;

+import org.apache.felix.ipojo.metadata.Element;

 import org.apache.felix.ipojo.parser.ManifestMetadataParser;

 import org.apache.felix.ipojo.parser.ParseException;

 import org.osgi.framework.BundleContext;

@@ -35,8 +36,6 @@
 import org.osgi.framework.ServiceReference;

 import org.osgi.service.cm.ManagedServiceFactory;

 

-import org.apache.felix.ipojo.metadata.Element;

-

 public class Utils {

     

     public static Element getMetatadata(BundleContext bc, String component) {

@@ -82,7 +81,7 @@
     public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

-            refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

+            refs = bc.getServiceReferences(HandlerFactory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

             if (refs == null) {

                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

diff --git a/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java b/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
index baa6fee..2a3cfa4 100644
--- a/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
+++ b/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/bad/BadFactories.java
@@ -20,7 +20,7 @@
 

 import org.apache.felix.ipojo.ComponentFactory;

 import org.apache.felix.ipojo.ConfigurationException;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

 import org.apache.felix.ipojo.metadata.Attribute;

 import org.apache.felix.ipojo.metadata.Element;

@@ -56,7 +56,7 @@
     

     public void testBadHandlerFactory1() {

         try {

-            new HandlerFactory(context, getElementHandlerFactoryWithNoClassName());

+            new HandlerManagerFactory(context, getElementHandlerFactoryWithNoClassName());

             fail("An handler factory with no class name must be rejected");

         } catch (ConfigurationException e) {

           // OK.   

@@ -65,7 +65,7 @@
     

     public void testBadHandlerFactory2() {

         try {

-            new HandlerFactory(context, getElementHandlerFactoryWithNoName());

+            new HandlerManagerFactory(context, getElementHandlerFactoryWithNoName());

             fail("An handler factory with no name must be rejected");

         } catch (ConfigurationException e) {

           // OK.   

diff --git a/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.bad.configurations/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
index 82c404a..16f4ed3 100644
--- a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
@@ -22,6 +22,7 @@
 

 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.architecture.Architecture;

 import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

 import org.apache.felix.ipojo.test.scenarios.eh.service.CheckService;

@@ -158,7 +159,7 @@
         assertEquals("Check validity", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

         

         // Kill the handler factory

-        HandlerFactory f = (HandlerFactory) Utils.getHandlerFactoryByName(context, "check");

+        HandlerManagerFactory f = (HandlerManagerFactory) Utils.getHandlerFactoryByName(context, "check");

         f.stop();

         

         sr = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "HandlerTest-1");

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..1500115 100644
--- a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -28,7 +28,6 @@
 import org.apache.felix.ipojo.Handler;

 import org.apache.felix.ipojo.HandlerFactory;

 import org.apache.felix.ipojo.ServiceContext;

-//import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.InvalidSyntaxException;

 import org.osgi.framework.ServiceReference;

@@ -54,7 +53,7 @@
     public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

-            refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

+            refs = bc.getServiceReferences(HandlerFactory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

             if (refs == null) {

                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

diff --git a/ipojo/tests/tests.core.factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.factories/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index 7dbb8d0..81f4b4c 100644
--- a/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.lifecycle.callback/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.InvalidSyntaxException;

@@ -50,7 +50,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -58,7 +58,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.service.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.service.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index 7dbb8d0..81f4b4c 100644
--- a/ipojo/tests/tests.core.service.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.service.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 import org.osgi.framework.BundleContext;

 import org.osgi.framework.InvalidSyntaxException;

@@ -50,7 +50,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -58,7 +58,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;

diff --git a/ipojo/tests/tests.core.service.providing/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.service.providing/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
index cb87c86..a684a6b 100644
--- a/ipojo/tests/tests.core.service.providing/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
+++ b/ipojo/tests/tests.core.service.providing/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -26,7 +26,7 @@
 import org.apache.felix.ipojo.ComponentInstance;

 import org.apache.felix.ipojo.Factory;

 import org.apache.felix.ipojo.Handler;

-import org.apache.felix.ipojo.HandlerFactory;

+import org.apache.felix.ipojo.HandlerManagerFactory;

 import org.apache.felix.ipojo.ServiceContext;

 //import org.apache.felix.ipojo.composite.CompositeManager;

 import org.osgi.framework.BundleContext;

@@ -51,7 +51,7 @@
         }

     }

 

-    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

         ServiceReference[] refs;

         try {

             refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

@@ -59,7 +59,7 @@
                 System.err.println("Cannot get the factory " + factoryName);

                 return null;

             }

-            return (HandlerFactory) bc.getService(refs[0]);

+            return (HandlerManagerFactory) bc.getService(refs[0]);

         } catch (InvalidSyntaxException e) {

             System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

             return null;