Applied patch (FELIX-244) to allow external handlers to participate in 
the architecture service and to migrate immediate component management 
code from the instance manager to the lifecycle callback handler.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@515124 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/pom.xml b/ipojo/pom.xml
index bd63032..08adf4d 100644
--- a/ipojo/pom.xml
+++ b/ipojo/pom.xml
@@ -49,7 +49,9 @@
               org.apache.felix.ipojo.metadata, 
               org.apache.felix.ipojo.architecture, 
               org.apache.felix.ipojo.parser,
-              org.apache.felix.ipojo.util, 
+              org.apache.felix.ipojo.util,
+              org.apache.felix.ipojo.handlers.dependency,
+              org.apache.felix.ipojo.handlers.providedservice, 
               org.osgi.service.cm; specification-version="1.2",
               org.osgi.service.log; specification-version="1.3"
             </exportPackage>
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java b/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java
index 54a63bb..1861f5d 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java
@@ -82,7 +82,7 @@
     String getInstanceName();
     
     /**
-     * @return true if getState return 1 or 2.
+     * @return true if getState returns INVALID or VALID.
      */
     boolean isStarted();
 
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java b/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java
index bc4081d..14542c1 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java
@@ -20,6 +20,7 @@
 
 import java.util.Dictionary;
 
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 import org.apache.felix.ipojo.metadata.Element;
 
 /**
@@ -78,4 +79,9 @@
      * @param instance : the created instance
      */
     public void createInstance(Object instance) { }
+    
+    /**
+     * @return the description of the handler..
+     */
+    public HandlerDescription getDescription() { return new HandlerDescription(this.getClass().getName(), isValid()); }
 }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java b/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java
index 7164eea..45e6038 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 
 import org.apache.felix.ipojo.architecture.ComponentDescription;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.util.Logger;
 import org.osgi.framework.BundleContext;
@@ -51,11 +52,6 @@
     private String m_className;
 
     /**
-     * Is the component an immediate component ?
-     */
-    private boolean m_isImmediate = false;
-
-    /**
      * The context of the component.
      */
     private BundleContext m_context;
@@ -118,7 +114,6 @@
         if (m_className == null) {
             m_factory.getLogger().log(Logger.ERROR, "The class name of the component cannot be setted, it does not exist in the metadata");
         }
-        if (cm.containsAttribute("immediate") && cm.getAttribute("immediate").equalsIgnoreCase("true")) { m_isImmediate = true; }
 
         // ComponentInfo initialization
         m_componentDesc = new ComponentDescription();
@@ -134,9 +129,9 @@
                 Handler h = (Handler) IPojoConfiguration.INTERNAL_HANDLERS[i].newInstance();
                 h.configure(this, cm, configuration);
             } catch (InstantiationException e) {
-                m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
+                m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
             } catch (IllegalAccessException e) {
-                m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
+                m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
             }
         }
 
@@ -149,11 +144,11 @@
                     Handler h = (Handler) c.newInstance();
                     h.configure(this, cm, configuration);
                 } catch (ClassNotFoundException e) {
-                    m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                    m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
                 } catch (InstantiationException e) {
-                    m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                    m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
                 } catch (IllegalAccessException e) {
-                    m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                    m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
                 }
 
             }
@@ -165,6 +160,23 @@
      * @return the component type information.
      */
     public ComponentDescription getComponentDescription() { return m_componentDesc; }
+    
+    public InstanceDescription getInstanceDescription() {
+    	int componentState = getState();
+        InstanceDescription instanceDescription = new InstanceDescription(m_name, m_className, componentState, getContext().getBundle().getBundleId());
+
+        String[] objects = new String[getPojoObjects().length];
+        for (int i = 0; i < getPojoObjects().length; i++) {
+        	objects[i] = getPojoObjects()[i].toString();
+        }
+        instanceDescription.setCreatedObjects(objects);
+
+        Handler[] handlers = getRegistredHandlers();
+        for (int i = 0; i < handlers.length; i++) {
+        	instanceDescription.addHandler(handlers[i].getDescription());
+        }
+        return instanceDescription;
+    }
 
     /**
      * @return the list of the registred handlers.
@@ -199,7 +211,7 @@
     	if(m_state != STOPPED) { return; } // Instance already started
     	
         // Start all the handlers
-        m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] Start the instance manager with " + m_handlers.length + " handlers");
+        m_factory.getLogger().log(Logger.INFO, "[" + m_name + "] Start the instance manager with " + m_handlers.length + " handlers");
 
         // The new state of the component is UNRESOLVED
         m_state = INVALID;
@@ -236,8 +248,8 @@
         if (m_state != state) {
 
             // Log the state change
-            if (state == INVALID) { m_factory.getLogger().log(Logger.INFO, "[" + m_className + "]  State -> INVALID"); }
-            if (state == VALID) { m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] State -> VALID"); }
+            if (state == INVALID) { m_factory.getLogger().log(Logger.INFO, "[" + m_name + "]  State -> INVALID"); }
+            if (state == VALID) { m_factory.getLogger().log(Logger.INFO, "[" + m_name + "] State -> VALID"); }
 
             // The state changed call the handler stateChange method
             m_state = state;
@@ -273,7 +285,7 @@
         try {
             m_clazz = m_factory.loadClass(m_className);
         } catch (ClassNotFoundException  e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] Class not found during the loading phase : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Class not found during the loading phase : " + e.getMessage());
             return;
         }
     }
@@ -348,7 +360,6 @@
         if (!isLoaded()) { load(); }
         Object instance = null;
         try {
-            m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] createInstance -> Try to find the constructor");
 
             // Try to find if there is a constructor with a bundle context as parameter :
             try {
@@ -366,23 +377,23 @@
             }
 
         } catch (InstantiationException e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] createInstance -> The Component Instance cannot be instancied : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> The Component Instance cannot be instancied : " + e.getMessage());
             e.printStackTrace();
         } catch (IllegalAccessException e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] createInstance -> The Component Instance is not accessible : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> The Component Instance is not accessible : " + e.getMessage());
             e.printStackTrace();
         } catch (SecurityException e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] createInstance -> The Component Instance is not accessible (security reason) : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> The Component Instance is not accessible (security reason) : " + e.getMessage());
             e.printStackTrace();
         } catch (InvocationTargetException e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] createInstance -> Cannot invoke the constructor method (illegal target) : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> Cannot invoke the constructor method (illegal target) : " + e.getMessage());
             e.printStackTrace();
         } catch (NoSuchMethodException e) {
-            m_factory.getLogger().log(Logger.ERROR, "[" + m_className + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage());
+            m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage());
             e.printStackTrace();
         }
 
-        m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] createInstance -> Return the instance " + instance);
+        m_factory.getLogger().log(Logger.INFO, "[" + m_name + "] createInstance -> Return the instance " + instance);
 
         // Register the new instance
         addInstance(instance);
@@ -567,7 +578,7 @@
      * Check the state of all handlers.
      */
     public void checkInstanceState() {
-        m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] Check the component state");
+        m_factory.getLogger().log(Logger.INFO, "[" + m_name + "] Check the instance state");
         boolean isValid = true;
         for (int i = 0; i < m_handlers.length; i++) {
             boolean b = m_handlers[i].isValid();
@@ -581,12 +592,7 @@
             m_pojoObjects = new Object[0];
             return;
         }
-        if (isValid && m_state == INVALID) {
-            setState(VALID);
-            if (m_isImmediate && m_pojoObjects.length == 0) { createPojoObject(); }
-        }
-
-        m_factory.getLogger().log(Logger.INFO, "[" + m_className + "] Component Manager : " + m_state);
+        if (isValid && m_state == INVALID) { setState(VALID); }
     }
 
 	public String getInstanceName() { return m_name; }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java
index 0fd1684..684d258 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java
@@ -24,17 +24,7 @@
 import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.DependencyDescription;
-import org.apache.felix.ipojo.architecture.DependencyHandlerDescription;
-import org.apache.felix.ipojo.architecture.HandlerDescription;
 import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.architecture.ProvidedServiceDescription;
-import org.apache.felix.ipojo.architecture.ProvidedServiceHandlerDescription;
-import org.apache.felix.ipojo.handlers.dependency.Dependency;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
-import org.apache.felix.ipojo.handlers.providedservice.Property;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedService;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler;
 import org.apache.felix.ipojo.metadata.Element;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -62,11 +52,6 @@
     private String m_name;
 
     /**
-     * Component Type.
-     */
-    private String m_className;
-
-    /**
      * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.InstanceManager, org.apache.felix.ipojo.metadata.Element)
      */
     public void configure(InstanceManager im, Element metadata, Dictionary configuration) {
@@ -75,8 +60,6 @@
             if (isArchitectureEnabled.equalsIgnoreCase("true")) { im.register(this); }
         }
 
-        m_className = metadata.getAttribute("className");
-
         m_name = (String) configuration.get("name");
 
         m_manager = im;
@@ -112,55 +95,7 @@
      * @see org.apache.felix.ipojo.architecture.Architecture#getComponentDescription()
      */
     public InstanceDescription getInstanceDescription() {
-        int componentState = m_manager.getState();
-        InstanceDescription instanceDescription = new InstanceDescription(m_name, m_className, componentState, m_manager.getContext().getBundle().getBundleId());
-
-        String[] objects = new String[m_manager.getPojoObjects().length];
-        for (int i = 0; i < m_manager.getPojoObjects().length; i++) {
-        	objects[i] = m_manager.getPojoObjects()[i].toString();
-        }
-        instanceDescription.setCreatedObjects(objects);
-
-        Handler[] handlers = m_manager.getRegistredHandlers();
-        for (int i = 0; i < handlers.length; i++) {
-            if (handlers[i] instanceof DependencyHandler) {
-                DependencyHandler dh = (DependencyHandler) handlers[i];
-                DependencyHandlerDescription dhd = new DependencyHandlerDescription(dh.isValid());
-                for (int j = 0; j < dh.getDependencies().length; j++) {
-                    Dependency dep = dh.getDependencies()[j];
-                    // Create & add the dependency description
-                    DependencyDescription dd = new DependencyDescription(dep.getSpecification(), dep.isMultiple(), dep.isOptional(), dep.getFilter(), dep.getState(), instanceDescription);
-                    dd.setServiceReferences(dep.getServiceReferences());
-                    dd.setUsedServices(dep.getUsedServices());
-                    dhd.addDependency(dd);
-                }
-                instanceDescription.addHandler(dhd);
-            } else { 
-            	if (handlers[i] instanceof ProvidedServiceHandler) {
-            		ProvidedServiceHandler psh = (ProvidedServiceHandler) handlers[i];
-            		ProvidedServiceHandlerDescription pshd = new ProvidedServiceHandlerDescription(psh.isValid());
-
-            		for (int j = 0; j < psh.getProvidedService().length; j++) {
-            			ProvidedService ps = psh.getProvidedService()[j];
-            			ProvidedServiceDescription psd = new ProvidedServiceDescription(ps.getServiceSpecification(), ps.getState(), ps.getServiceReference(), instanceDescription);
-
-            			Properties props = new Properties();
-            			for (int k = 0; k < ps.getProperties().length; k++) {
-            				Property prop = ps.getProperties()[k];
-            				if (prop.getValue() != null) { props.put(prop.getName(), prop.getValue().toString()); }
-            			}
-            			psd.setProperty(props);
-            			pshd.addProvidedService(psd);
-            		}
-            		instanceDescription.addHandler(pshd);
-            	}
-            	else { 
-            		// Else add a generic handler to the description
-            		instanceDescription.addHandler(new HandlerDescription(handlers[i].getClass().getName(), handlers[i].isValid()));
-            	}
-            }
-        }
-        return instanceDescription;
+        return m_manager.getInstanceDescription();
     }
 
 }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
similarity index 93%
rename from ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java
rename to ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
index e7652e9..6919911 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyDescription.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.ipojo.architecture;
+package org.apache.felix.ipojo.handlers.dependency;
 
 import java.util.HashMap;
 
@@ -95,9 +95,8 @@
      * @param optional : is the depdendency optional ?
      * @param filter : the filter
      * @param state : the state
-     * @param parent : the description of the parent (either a ProvidedServiceDescription, either a ComponentDescription)
      */
-    public DependencyDescription(String itf, boolean multiple, boolean optional, String filter, int state, Object parent) {
+    public DependencyDescription(String itf, boolean multiple, boolean optional, String filter, int state) {
         super();
         m_interface = itf;
         m_multiple = multiple;
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
index 6d60a16..55d758d 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
@@ -23,6 +23,7 @@
 
 import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 import org.apache.felix.ipojo.handlers.dependency.nullable.NullableObjectWriter;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.util.Logger;
@@ -355,5 +356,18 @@
         m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Component Dependencies are valid");
         return valide;
     }
+    
+    public HandlerDescription getDescription() {
+        DependencyHandlerDescription dhd = new DependencyHandlerDescription(isValid());
+        for (int j = 0; j < getDependencies().length; j++) {
+            Dependency dep = getDependencies()[j];
+            // Create & add the dependency description
+            DependencyDescription dd = new DependencyDescription(dep.getSpecification(), dep.isMultiple(), dep.isOptional(), dep.getFilter(), dep.getState());
+            dd.setServiceReferences(dep.getServiceReferences());
+            dd.setUsedServices(dep.getUsedServices());
+            dhd.addDependency(dd);
+        }
+        return dhd;
+    }
 
 }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
similarity index 96%
rename from ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java
rename to ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
index 66b6e7b..a67109d 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/DependencyHandlerDescription.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
@@ -16,10 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.ipojo.architecture;
+package org.apache.felix.ipojo.handlers.dependency;
 
 import java.util.Iterator;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
+
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 
 /**
  * Dependency Handler Description.
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
index 60779d9..3c85db7 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
@@ -21,6 +21,7 @@
 import java.lang.reflect.InvocationTargetException;
 import java.util.Dictionary;
 
+import org.apache.felix.ipojo.ComponentInstance;
 import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.metadata.Element;
@@ -47,6 +48,11 @@
      */
     private InstanceManager m_manager;
 
+	/**
+	 * Does a POJO object be created at starting
+	 */
+	private boolean m_immediate = false;
+
     /**
      * Add the given callback to the callback list.
      * @param hk : the element to add
@@ -74,6 +80,8 @@
     public void configure(InstanceManager cm, Element metadata, Dictionary configuration) {
         m_manager = cm;
         m_callbacks = new LifecycleCallback[0];
+        
+        if (metadata.containsAttribute("immediate") && metadata.getAttribute("immediate").equalsIgnoreCase("true")) { m_immediate = true; }
 
         Element[] hooksMetadata = metadata.getElements("callback");
         for (int i = 0; i < hooksMetadata.length; i++) {
@@ -87,7 +95,7 @@
             LifecycleCallback hk = new LifecycleCallback(this, initialState, finalState, method, isStatic);
             addCallback(hk);
         }
-        if (m_callbacks.length > 0) { m_manager.register(this); }
+        if (m_callbacks.length > 0 || m_immediate) { m_manager.register(this); }
     }
 
     /**
@@ -112,6 +120,11 @@
      * @see org.apache.felix.ipojo.Handler#stateChanged(int)
      */
     public void stateChanged(int state) {
+    	// Manage immediate component
+    	if(m_state == ComponentInstance.INVALID && state == ComponentInstance.VALID && m_manager.getPojoObjects().length == 0) {
+    		m_manager.createPojoObject();
+    	}
+    	
         for (int i = 0; i < m_callbacks.length; i++) {
             if (m_callbacks[i].getInitialState() == m_state && m_callbacks[i].getFinalState() == state) {
                 try {
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
index a47e82e..f1638c6 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
@@ -26,8 +26,6 @@
 import org.apache.felix.ipojo.parser.ParseUtils;
 import org.apache.felix.ipojo.util.Logger;
 
-import sun.net.www.ParseUtil;
-
 /**
  * Represent a property i.e. a set : [name, type, value].
  * A property can be attached to a field.
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
similarity index 89%
rename from ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java
rename to ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
index 5d5ab3f..0c15af2 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceDescription.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
@@ -16,10 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.ipojo.architecture;
+package org.apache.felix.ipojo.handlers.providedservice;
 
 import java.util.Properties;
 
+import org.apache.felix.ipojo.handlers.dependency.DependencyDescription;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -58,10 +59,10 @@
      */
     private ServiceReference m_serviceReference;
 
-    /**
-     * Handler on the component description who contains this description.
-     */
-    private InstanceDescription m_parent;
+//    /**
+//     * Handler on the component description who contains this description.
+//     */
+//    private InstanceDescription m_parent;
 
     /**
      * Properties of the provided service.
@@ -76,11 +77,11 @@
      * @param sr : Service Registration (to obtain the reference), or null if state is UNREGISTRED
      * @param parent : the component description declaring this proided service
      */
-    public ProvidedServiceDescription(String[] serviceSpecification, int state, ServiceReference sr, InstanceDescription parent) {
+    public ProvidedServiceDescription(String[] serviceSpecification, int state, ServiceReference sr/*, InstanceDescription parent*/) {
         m_serviceSpecification = serviceSpecification;
         m_state = state;
         m_serviceReference = sr;
-        m_parent = parent;
+       // m_parent = parent;
     }
 
     /**
@@ -135,11 +136,4 @@
         return m_serviceReference;
     }
 
-    /**
-     * @return the parent description.
-     */
-    public InstanceDescription getInstanceDescription() {
-        return m_parent;
-    }
-
 }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
index 0ae43ec..25f3884 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
@@ -19,10 +19,12 @@
 package org.apache.felix.ipojo.handlers.providedservice;
 
 import java.util.Dictionary;
+import java.util.Properties;
 
 import org.apache.felix.ipojo.Handler;
 import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.architecture.ComponentDescription;
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 import org.apache.felix.ipojo.architecture.PropertyDescription;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.parser.ParseUtils;
@@ -320,5 +322,27 @@
             m_providedServices[i].deleteProperties(dict);
         }
     }
+	
+	/**
+	 * @see org.apache.felix.ipojo.Handler#getDescription()
+	 */
+	public HandlerDescription getDescription() {
+		ProvidedServiceHandlerDescription pshd = new ProvidedServiceHandlerDescription(this.isValid());
+
+		for (int j = 0; j < getProvidedService().length; j++) {
+			ProvidedService ps = getProvidedService()[j];
+			ProvidedServiceDescription psd = new ProvidedServiceDescription(ps.getServiceSpecification(), ps.getState(), ps.getServiceReference());
+
+			Properties props = new Properties();
+			for (int k = 0; k < ps.getProperties().length; k++) {
+				Property prop = ps.getProperties()[k];
+				if (prop.getValue() != null) { props.put(prop.getName(), prop.getValue().toString()); }
+			}
+			psd.setProperty(props);
+			pshd.addProvidedService(psd);
+		}
+		
+		return pshd;
+	}
 
 }
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
similarity index 94%
rename from ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java
rename to ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
index a838d86..90acdc6 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ProvidedServiceHandlerDescription.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
@@ -16,12 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.ipojo.architecture;
+package org.apache.felix.ipojo.handlers.providedservice;
 
 import java.util.Iterator;
 
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedService;
-import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler;
+import org.apache.felix.ipojo.architecture.HandlerDescription;
 
 /**
  * Provided Service Handler Description.