You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/03/03 16:46:43 UTC

svn commit: r633138 [1/7] - in /felix/sandbox/clement/ipojo: composite/ composite/src/main/java/org/apache/felix/ipojo/composite/ composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ composite/src/main/java/org/apache/felix/ipojo/comp...

Author: clement
Date: Mon Mar  3 07:46:27 2008
New Revision: 633138

URL: http://svn.apache.org/viewvc?rev=633138&view=rev
Log:
Preparation of the merge : 
Code refactoring
Several classes are merged to avoid code redundancy
Remove the core dependency on ASM (useless)

Added:
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
      - copied, changed from r631196, felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/AbstractServiceDependency.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyStateListener.java
      - copied, changed from r631196, felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyLifecycleListener.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Property.java
Removed:
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ExportDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/AbstractServiceDependency.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/DependencyLifecycleListener.java
Modified:
    felix/sandbox/clement/ipojo/composite/   (props changed)
    felix/sandbox/clement/ipojo/composite/pom.xml
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeHandler.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeServiceContext.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/FactoryProxy.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ArchitectureHandler.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandlerDescription.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceInstantiatorDescription.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/MethodMetadata.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/POJOWriter.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedService.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandler.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ProvidedServiceHandlerDescription.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/ServiceExporter.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/SpecificationMetadata.java
    felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/util/SourceManager.java
    felix/sandbox/clement/ipojo/core/pom.xml
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/ConfigurationException.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Factory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/Handler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/HandlerManager.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoContext.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceCreator.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/MissingHandlerException.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/PolicyServiceContext.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/PrimitiveHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/ComponentTypeDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/HandlerDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/context/ServiceReferenceImpl.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/context/ServiceRegistrationImpl.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/context/ServiceRegistry.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/context/StringMap.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/architecture/ArchitectureHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceUsage.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/controller/ControllerHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/FieldMetadata.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/ParseUtils.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/PojoMetadata.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java
    felix/sandbox/clement/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
    felix/sandbox/clement/ipojo/jmx.handler/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java

Propchange: felix/sandbox/clement/ipojo/composite/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Mar  3 07:46:27 2008
@@ -2,3 +2,5 @@
 .classpath
 .project
 target
+.pmd
+reports

Modified: felix/sandbox/clement/ipojo/composite/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/pom.xml?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/pom.xml (original)
+++ felix/sandbox/clement/ipojo/composite/pom.xml Mon Mar  3 07:46:27 2008
@@ -46,11 +46,11 @@
 				<configuration>
 					<instructions>
 						<Bundle-Name>
-							iPOJO-composite-unstable
+							iPOJO Composite
 						</Bundle-Name>
 						<Bundle-Vendor>Clement ESCOFFIER</Bundle-Vendor>
 						<Bundle-Description>
-							iPOJO Composite
+							iPOJO Composititon Framework 
 						</Bundle-Description>
 						<Import-Package>
 							org.apache.felix.ipojo,

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeFactory.java Mon Mar  3 07:46:27 2008
@@ -55,24 +55,24 @@
 
     /**
      * Create a composite factory.
-     * @param bc : bundle context
-     * @param cm : metadata of the component to create
+     * @param context : bundle context
+     * @param metadata : metadata of the component to create
      * @throws ConfigurationException occurs when the element describing the factory is malformed.
      */
-    public CompositeFactory(BundleContext bc, Element cm) throws ConfigurationException {
-        super(bc, cm);
+    public CompositeFactory(BundleContext context, Element metadata) throws ConfigurationException {
+        super(context, metadata);
     }
     
     /**
      * Check if the metadata are well formed.
-     * @param cm : metadata
+     * @param metadata : metadata
      * @throws ConfigurationException occurs when the element describing the factory is malformed.
      * @see org.apache.felix.ipojo.ComponentFactory#check(org.apache.felix.ipojo.metadata.Element)
      */
-    public void check(Element cm) throws ConfigurationException {
-        String name = cm.getAttribute("name");
+    public void check(Element metadata) throws ConfigurationException {
+        String name = metadata.getAttribute("name");
         if (name == null) {
-            throw new ConfigurationException("A composite needs a name : " + cm);
+            throw new ConfigurationException("A composite needs a name : " + metadata);
         }
     }
     
@@ -88,15 +88,15 @@
         Element[] elems = m_componentMetadata.getElements();
         for (int i = 0; i < elems.length; i++) {
             Element current = elems[i]; 
-            RequiredHandler hi = new RequiredHandler(current.getName(), current.getNameSpace());
-            if (! list.contains(hi)) { list.add(hi); }
+            RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace());
+            if (! list.contains(req)) { list.add(req); }
         }
         
         // Add architecture if architecture != 'false'
         String arch = m_componentMetadata.getAttribute("architecture");
         if (arch == null || arch.equalsIgnoreCase("true")) {
-            RequiredHandler hi = new RequiredHandler("architecture", null);
-            if (! list.contains(hi)) { list.add(hi); }
+            RequiredHandler req = new RequiredHandler("architecture", null);
+            if (! list.contains(req)) { list.add(req); }
         }
         
         return list;
@@ -160,15 +160,15 @@
         if (properties == null || properties.get("name") == null) {
             throw new UnacceptableConfiguration("The configuration does not contains the \"name\" property");
         }
-        final String name = (String) properties.get("name");
+        String name = (String) properties.get("name");
         
-        ComponentInstance cm = (CompositeManager) m_componentInstances.get(name);
+        ComponentInstance instance = (CompositeManager) m_componentInstances.get(name);
         
-        if (cm == null) {
+        if (instance == null) {
             return; // The instance does not exist.
         }
         
-        cm.reconfigure(properties); // re-configure the component
+        instance.reconfigure(properties); // re-configure the component
     }
 
     public String getFactoryName() {

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeHandler.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeHandler.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeHandler.java Mon Mar  3 07:46:27 2008
@@ -50,10 +50,10 @@
     /**
      * Set the manager.
      * This method me be called only once time.
-     * @param cm : the composite manager.
+     * @param instance : the composite manager.
      */
-    protected final void attach(ComponentInstance cm) {
-        m_manager = (CompositeManager) cm;
+    protected final void attach(ComponentInstance instance) {
+        m_manager = (CompositeManager) instance;
     }
     
     public final void setFactory(Factory factory) {

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeManager.java Mon Mar  3 07:46:27 2008
@@ -64,7 +64,7 @@
     /**
      * Instance State Listener List.
      */
-    private List m_instanceListeners = new ArrayList();
+    private List m_listeners = new ArrayList();
 
     /**
      * Internal service context of the composition.
@@ -84,12 +84,12 @@
     /**
      * Construct a new Component Manager.
      * @param factory : the factory managing the instance manager
-     * @param bc : the bundle context to give to the instance
+     * @param context : the bundle context to give to the instance
      * @param handlers : the handlers to plug
      */
-    public CompositeManager(CompositeFactory factory, BundleContext bc, HandlerManager[] handlers) {
+    public CompositeManager(CompositeFactory factory, BundleContext context, HandlerManager[] handlers) {
         m_factory = factory;
-        m_context = bc;
+        m_context = context;
         // Initialize the service context.
         m_internalContext = new CompositeServiceContext(m_context, this);
         m_handlers = handlers;
@@ -97,16 +97,16 @@
 
     /**
      * Plug the given handler to the current container.
-     * @param h : the handler to plug.
+     * @param handler : the handler to plug.
      */
-    public synchronized void addCompositeHandler(HandlerManager h) {
+    public synchronized void addCompositeHandler(HandlerManager handler) {
         if (m_handlers.length > 0) {
             HandlerManager[] newInstances = new HandlerManager[m_handlers.length + 1];
             System.arraycopy(m_handlers, 0, newInstances, 0, m_handlers.length);
-            newInstances[m_handlers.length] = h;
+            newInstances[m_handlers.length] = handler;
             m_handlers = newInstances;
         } else {
-            m_handlers = new HandlerManager[] { h };
+            m_handlers = new HandlerManager[] { handler };
         }
     }
 
@@ -116,8 +116,8 @@
      * @see org.apache.felix.ipojo.ComponentInstance#addInstanceStateListener(org.apache.felix.ipojo.InstanceStateListener)
      */
     public void addInstanceStateListener(InstanceStateListener listener) {
-        synchronized (m_instanceListeners) {
-            m_instanceListeners.add(listener);
+        synchronized (m_listeners) {
+            m_listeners.add(listener);
         }
     }
 
@@ -125,17 +125,17 @@
      * Configure the instance manager. Stop the existing handler, clear the
      * handler list, change the metadata, recreate the handler
      * 
-     * @param cm : the component type metadata
+     * @param metadata : the component type metadata
      * @param configuration : the configuration of the instance
      * @throws ConfigurationException : occurs when the component type are incorrect.
      */
-    public void configure(Element cm, Dictionary configuration) throws ConfigurationException {        
+    public void configure(Element metadata, Dictionary configuration) throws ConfigurationException {        
         // Add the name
         m_name = (String) configuration.get("name");
         
         // Create the standard handlers and add these handlers to the list
         for (int i = 0; i < m_handlers.length; i++) {
-            m_handlers[i].init(this, cm, configuration);
+            m_handlers[i].init(this, metadata, configuration);
         }
     }
     
@@ -146,8 +146,8 @@
     public void dispose() {
         if (m_state > STOPPED) { stop(); }
         
-        for (int i = 0; i < m_instanceListeners.size(); i++) {
-            ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, DISPOSED);
+        for (int i = 0; i < m_listeners.size(); i++) {
+            ((InstanceStateListener) m_listeners.get(i)).stateChanged(this, DISPOSED);
         }
         
         m_factory.disposed(this);
@@ -158,7 +158,7 @@
             m_handlers[i].dispose();
         }
         m_handlers = new HandlerManager[0];
-        m_instanceListeners.clear();
+        m_listeners.clear();
     }
 
     /**
@@ -199,8 +199,8 @@
      * @return the global bundle context.
      */
     public BundleContext getGlobalContext() {
-        IPojoContext c = (IPojoContext) m_context;
-        return c.getGlobalContext();
+        IPojoContext context = (IPojoContext) m_context;
+        return context.getGlobalContext();
     }
     
     /**
@@ -209,10 +209,10 @@
      * @see org.apache.felix.ipojo.ComponentInstance#getInstanceDescription()
      */
     public InstanceDescription getInstanceDescription() {
-        InstanceDescription instanceDescription = new InstanceDescription(m_name, m_state, getContext().getBundle().getBundleId(), m_factory.getComponentDescription());
+        InstanceDescription desc = new InstanceDescription(m_name, m_state, getContext().getBundle().getBundleId(), m_factory.getComponentDescription());
         CompositeHandler[] handlers = getRegistredCompositeHandlers();
         for (int i = 0; i < handlers.length; i++) {
-            instanceDescription.addHandler(handlers[i].getDescription());
+            desc.addHandler(handlers[i].getDescription());
         }
 
         // Get instances description of internal instance
@@ -222,14 +222,14 @@
             if (refs != null) {
                 for (int i = 0; i < refs.length; i++) {
                     Architecture arch = (Architecture) m_internalContext.getService(refs[i]);
-                    instanceDescription.addInstance(arch.getInstanceDescription());
+                    desc.addInstance(arch.getInstanceDescription());
                     m_internalContext.ungetService(refs[i]);
                 }
             }
         } catch (InvalidSyntaxException e) {
-            e.printStackTrace(); // Should not happen
+            // Cannot happen
         }
-        return instanceDescription;
+        return desc;
     }
 
     /**
@@ -246,8 +246,8 @@
      * @return the parent service context.
      */
     public ServiceContext getParentServiceContext() {
-        IPojoContext c = (IPojoContext) m_context;
-        return c.getServiceContext();
+        IPojoContext context = (IPojoContext) m_context;
+        return context.getServiceContext();
     }
 
     /**
@@ -255,11 +255,11 @@
      * @return the list of the registered handlers.
      */
     public CompositeHandler[] getRegistredCompositeHandlers() {
-        CompositeHandler[] h = new CompositeHandler[m_handlers.length];
+        CompositeHandler[] handler = new CompositeHandler[m_handlers.length];
         for (int i = 0; i < m_handlers.length; i++) {
-            h[i] = (CompositeHandler) m_handlers[i].getHandler();
+            handler[i] = (CompositeHandler) m_handlers[i].getHandler();
         }
-        return h;
+        return handler;
     }
     
     /**
@@ -305,8 +305,8 @@
      * @see org.apache.felix.ipojo.ComponentInstance#removeInstanceStateListener(org.apache.felix.ipojo.InstanceStateListener)
      */
     public void removeInstanceStateListener(InstanceStateListener listener) {
-        synchronized (m_instanceListeners) {
-            m_instanceListeners.remove(listener);
+        synchronized (m_listeners) {
+            m_listeners.remove(listener);
         }
     }
 
@@ -331,8 +331,8 @@
                 }
             }
             
-            for (int i = 0; i < m_instanceListeners.size(); i++) {
-                ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, state);
+            for (int i = 0; i < m_listeners.size(); i++) {
+                ((InstanceStateListener) m_listeners.get(i)).stateChanged(this, state);
             }
         }
     }
@@ -414,8 +414,8 @@
         m_internalContext.stop(); // Turn off the factory tracking
         m_state = STOPPED;
         
-        for (int i = 0; i < m_instanceListeners.size(); i++) {
-            ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, STOPPED);
+        for (int i = 0; i < m_listeners.size(); i++) {
+            ((InstanceStateListener) m_listeners.get(i)).stateChanged(this, STOPPED);
         }
     }
     
@@ -426,8 +426,8 @@
     protected synchronized void kill() {
         if (m_state > STOPPED) { stop(); }
         
-        for (int i = 0; i < m_instanceListeners.size(); i++) {
-            ((InstanceStateListener) m_instanceListeners.get(i)).stateChanged(this, DISPOSED);
+        for (int i = 0; i < m_listeners.size(); i++) {
+            ((InstanceStateListener) m_listeners.get(i)).stateChanged(this, DISPOSED);
         }
 
         // Cleaning
@@ -437,6 +437,6 @@
             m_handlers[i].dispose();
         }
         m_handlers = new HandlerManager[0];
-        m_instanceListeners.clear();
+        m_listeners.clear();
     }
 }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeServiceContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeServiceContext.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeServiceContext.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/CompositeServiceContext.java Mon Mar  3 07:46:27 2008
@@ -73,12 +73,6 @@
      * List of imported factories.
      */
     private List m_factories = new ArrayList();
-
-    /**
-     * External context.
-     */
-    private BundleContext m_parent;
-
     /**
      * Internal service registry.
      */
@@ -103,27 +97,26 @@
      * Constructor. This constructor instantiate a service registry with the
      * given bundle context.
      * 
-     * @param bc : the bundle context
+     * @param context : the bundle context
      */
-    public CompositeServiceContext(BundleContext bc) {
-        m_registry = new ServiceRegistry(bc);
-        m_parent = bc;
-        if (m_parent instanceof IPojoContext) {
-            m_global = ((IPojoContext) m_parent).getGlobalContext();
+    public CompositeServiceContext(BundleContext context) {
+        m_registry = new ServiceRegistry(context);
+        if (context instanceof IPojoContext) {
+            m_global = ((IPojoContext) context).getGlobalContext();
         } else {
-            m_global = m_parent; // the parent context is the global context
+            m_global = context; // the parent context is the global context
         }
     }
 
     /**
      * Constructor.
      * 
-     * @param bc : the bundle context
-     * @param ci : the component instance owning this context
+     * @param context : the bundle context
+     * @param instance : the component instance owning this context
      */
-    public CompositeServiceContext(BundleContext bc, ComponentInstance ci) {
-        this(bc);
-        m_instance = ci;
+    public CompositeServiceContext(BundleContext context, ComponentInstance instance) {
+        this(context);
+        m_instance = instance;
     }
 
     /**
@@ -353,12 +346,12 @@
 
     /**
      * Get the bundle object with the given id.
-     * @param id : bundle id
+     * @param bundleId : bundle id
      * @return the bundle object
      * @see org.osgi.framework.BundleContext#getBundle(long)
      */
-    public Bundle getBundle(long id) {
-        return m_global.getBundle(id);
+    public Bundle getBundle(long bundleId) {
+        return m_global.getBundle(bundleId);
     }
 
     /**

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/FactoryProxy.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/FactoryProxy.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/FactoryProxy.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/FactoryProxy.java Mon Mar  3 07:46:27 2008
@@ -51,11 +51,11 @@
     /**
      * Constructor.
      * @param fact : the targeted factory.
-     * @param s : the service context to target.
+     * @param svcContext : the service context to target.
      */
-    public FactoryProxy(Factory fact, ServiceContext s) {
+    public FactoryProxy(Factory fact, ServiceContext svcContext) {
         m_delegate = fact;
-        m_context = s;
+        m_context = svcContext;
     }
 
     /**
@@ -67,29 +67,28 @@
      * @throws ConfigurationException : occurs when the creation failed due to a configuration issue
      * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary)
      */
-    public ComponentInstance createComponentInstance(Dictionary configuration) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+    public ComponentInstance createComponentInstance(Dictionary configuration) throws UnacceptableConfiguration, MissingHandlerException,
+            ConfigurationException {
         return m_delegate.createComponentInstance(configuration, m_context);
     }
 
     /**
-     * Create an instance manager (i.e. component type instance). This has these
-     * service interaction in the scope given in argument.
+     * Create an instance manager (i.e. component type instance). This has these service interaction in the scope given in argument.
      * @param configuration : the configuration properties for this component.
      * @param serviceContext : the service context of the component.
      * @return the created instance manager.
      * @throws UnacceptableConfiguration : when the given configuration is not valid.
-     * @throws MissingHandlerException : when at least one handler is missing. 
+     * @throws MissingHandlerException : when at least one handler is missing.
      * @throws ConfigurationException : when an issue occurs during the oconfiguration of the instance.
-     * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary,
-     * org.apache.felix.ipojo.ServiceContext)
+     * @see org.apache.felix.ipojo.Factory#createComponentInstance(java.util.Dictionary, org.apache.felix.ipojo.ServiceContext)
      */
-    public ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+    public ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration,
+            MissingHandlerException, ConfigurationException {
         return m_delegate.createComponentInstance(configuration, serviceContext);
     }
 
     /**
-     * Get the component type information containing provided service,
-     * configuration properties ...
+     * Get the component type information containing provided service, configuration properties ...
      * @return the component type information.
      * @see org.apache.felix.ipojo.Factory#getDescription()
      */
@@ -107,8 +106,7 @@
     }
 
     /**
-     * Check if the given configuration is acceptable as a configuration of a
-     * component instance.
+     * Check if the given configuration is acceptable as a configuration of a component instance.
      * @param conf : the configuration to test
      * @return true if the configuration is acceptable
      * @see org.apache.felix.ipojo.Factory#isAcceptable(java.util.Dictionary)
@@ -118,11 +116,9 @@
     }
 
     /**
-     * Reconfigure an instance already created. This configuration need to have
-     * the name property to identify the instance.
+     * Reconfigure an instance already created. This configuration need to have the name property to identify the instance.
      * @param conf : the configuration to reconfigure the instance.
-     * @throws UnacceptableConfiguration : if the given configuration is not
-     * consistent for the targeted instance.
+     * @throws UnacceptableConfiguration : if the given configuration is not consistent for the targeted instance.
      * @throws MissingHandlerException : when at least one handler is missing
      * @see org.apache.felix.ipojo.Factory#reconfigure(java.util.Dictionary)
      */
@@ -132,11 +128,11 @@
 
     /**
      * Add a factory listener.
-     * @param l : the listener to add.
+     * @param listener : the listener to add.
      * @see org.apache.felix.ipojo.Factory#addFactoryStateListener(org.apache.felix.ipojo.FactoryStateListener)
      */
-    public void addFactoryStateListener(FactoryStateListener l) {
-        m_delegate.addFactoryStateListener(l);
+    public void addFactoryStateListener(FactoryStateListener listener) {
+        m_delegate.addFactoryStateListener(listener);
 
     }
 
@@ -150,11 +146,11 @@
 
     /**
      * Remove a service listener.
-     * @param l : the listener to remove
+     * @param listener : the listener to remove
      * @see org.apache.felix.ipojo.Factory#removeFactoryStateListener(org.apache.felix.ipojo.FactoryStateListener)
      */
-    public void removeFactoryStateListener(FactoryStateListener l) {
-        m_delegate.removeFactoryStateListener(l);
+    public void removeFactoryStateListener(FactoryStateListener listener) {
+        m_delegate.removeFactoryStateListener(listener);
 
     }
 

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ArchitectureHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ArchitectureHandler.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ArchitectureHandler.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/architecture/ArchitectureHandler.java Mon Mar  3 07:46:27 2008
@@ -53,7 +53,9 @@
      * Stop the handler.
      * @see org.apache.felix.ipojo.Handler#stop()
      */
-    public void stop() { }
+    public void stop() {
+        // Nothing to do.
+    }
 
     /**
      * Start the handler.

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandler.java Mon Mar  3 07:46:27 2008
@@ -94,7 +94,7 @@
          * Return the managed configuration.
          * @return the configuration.
          */
-        Dictionary getConfiguration() {
+        protected Dictionary getConfiguration() {
             return m_configuration;
         }
 
@@ -102,11 +102,11 @@
          * Return the used factory name.
          * @return the factory name
          */
-        String getFactory() {
+        protected String getFactory() {
             return m_factoryName;
         }
         
-        String getNeededFactoryName() {
+        protected String getNeededFactoryName() {
             return m_desiredFactory;
         }
 
@@ -114,7 +114,7 @@
          * Return the created instance.
          * @return the instance (or null if no instance are created).
          */
-        ComponentInstance getInstance() {
+        protected ComponentInstance getInstance() {
             return m_instance;
         }
 
@@ -123,7 +123,7 @@
          * 
          * @param name : the factory name.
          */
-        void setFactory(String name) {
+        protected void setFactory(String name) {
             m_factoryName = name;
         }
 
@@ -132,7 +132,7 @@
          * 
          * @param instance : the instance
          */
-        void setInstance(ComponentInstance instance) {
+        protected void setInstance(ComponentInstance instance) {
             m_instance = instance;
         }
     }
@@ -165,15 +165,15 @@
     
     /**
      * A new valid factory appears.
-     * @param f : factory.
+     * @param factory : factory.
      */
-    public void bindFactory(Factory f) {
+    public void bindFactory(Factory factory) {
         boolean implicated = false;
-        String factName = f.getName();
-        String className = f.getComponentDescription().getClassName();
+        String factName = factory.getName();
+        String className = factory.getComponentDescription().getClassName();
         for (int i = 0; i < m_configurations.length; i++) {
             if (m_configurations[i].getInstance() == null && (m_configurations[i].getNeededFactoryName().equals(factName) || m_configurations[i].getNeededFactoryName().equals(className))) {
-                createInstance(f, m_configurations[i]);
+                createInstance(factory, m_configurations[i]);
                 implicated = true;
             }
         }
@@ -184,12 +184,12 @@
     
     /**
      * An existing factory disappears or becomes invalid.
-     * @param f : factory
+     * @param factory : factory
      */
-    public void unbindFactory(Factory f) {
+    public void unbindFactory(Factory factory) {
         boolean implicated = false;
         for (int i = 0; i < m_configurations.length; i++) {
-            if (m_configurations[i].getInstance() != null && m_configurations[i].getFactory().equals(f.getName())) {
+            if (m_configurations[i].getInstance() != null && m_configurations[i].getFactory().equals(factory.getName())) {
                 m_configurations[i].setInstance(null);
                 m_configurations[i].setFactory(null);
                 implicated = true;
@@ -280,9 +280,7 @@
         String value = prop.getAttribute("value");
         if (name == null) { throw new ParseException("A property does not have the 'name' attribute"); }
         // Final case : the property element has a 'value' attribute
-        if (value != null) {
-            dict.put(name, value);
-        } else {
+        if (value == null) {
             // Recursive case
             // Check if there is 'property' element
             Element[] subProps = prop.getElements("property");
@@ -292,6 +290,8 @@
                 parseProperty(subProps[i], dict2);
                 dict.put(prop.getAttribute("name"), dict2);
             }
+        } else {
+            dict.put(name, value);
         }
     }
 
@@ -380,11 +380,11 @@
      * @see org.apache.felix.ipojo.CompositeHandler#getDescription()
      */
     public HandlerDescription getDescription() {
-        List l = new ArrayList();
+        List list = new ArrayList();
         for (int i = 0; i < m_configurations.length; i++) {
-            l.add(m_configurations[i]);
+            list.add(m_configurations[i]);
         }
-        return new InstanceHandlerDescription(this, l);
+        return new InstanceHandlerDescription(this, list);
     }
 
     /**

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandlerDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandlerDescription.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandlerDescription.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/instance/InstanceHandlerDescription.java Mon Mar  3 07:46:27 2008
@@ -42,11 +42,11 @@
     /**
      * Constructor.
      * 
-     * @param h : handler
+     * @param handler : handler
      * @param insts : list of component instances
      */
-    public InstanceHandlerDescription(CompositeHandler h, List insts) {
-        super(h);
+    public InstanceHandlerDescription(CompositeHandler handler, List insts) {
+        super(handler);
         m_instances = insts;
     }
 
@@ -60,7 +60,10 @@
         for (int i = 0; i < m_instances.size(); i++) {
             ManagedConfiguration inst = (ManagedConfiguration) m_instances.get(i);
             Element instance = new Element("Instance", "");
-            if (inst.getInstance() != null) {
+            if (inst.getInstance() == null) { 
+                instance.addAttribute(new Attribute("Factory", inst.getConfiguration().get("component").toString()));
+                instance.addAttribute(new Attribute("State", "Not Available"));
+            } else {
                 instance.addAttribute(new Attribute("Factory", inst.getFactory()));
                 instance.addAttribute(new Attribute("Name", inst.getInstance().getInstanceName()));
                 String state = null;
@@ -78,9 +81,6 @@
                 }
                 instance.addAttribute(new Attribute("State", state));
                 instance.addElement(inst.getInstance().getInstanceDescription().getDescription());
-            } else {
-                instance.addAttribute(new Attribute("Factory", inst.getConfiguration().get("component").toString()));
-                instance.addAttribute(new Attribute("State", "Not Available"));
             }
             instances.addElement(instance);
         }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceDependencyHandler.java Mon Mar  3 07:46:27 2008
@@ -33,8 +33,8 @@
 import org.apache.felix.ipojo.composite.util.SourceManager;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.parser.ParseException;
-import org.apache.felix.ipojo.util.AbstractServiceDependency;
-import org.apache.felix.ipojo.util.DependencyLifecycleListener;
+import org.apache.felix.ipojo.util.DependencyModel;
+import org.apache.felix.ipojo.util.DependencyStateListener;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
@@ -45,7 +45,7 @@
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class ServiceDependencyHandler extends CompositeHandler implements DependencyLifecycleListener {
+public class ServiceDependencyHandler extends CompositeHandler implements DependencyStateListener {
 
     /**
      * List of instances to manage.
@@ -80,9 +80,9 @@
             throw new ConfigurationException("Malformed service : the specification attribute is mandatory");
         }
         String filter = "(&(!(factory.name=" + getCompositeManager().getFactory().getComponentDescription().getName() + "))(factory.state=1))"; // Cannot reinstantiate yourself
-        String f = service.getAttribute("filter");
-        if (f != null) {
-            filter = "(&" + filter + f + ")";
+        String givenFilter = service.getAttribute("filter");
+        if (givenFilter != null) {
+            filter = "(&" + filter + givenFilter + ")"; //NOPMD
         }
         
         Filter fil;
@@ -102,26 +102,26 @@
             }
         }
         
-        String ag = service.getAttribute("aggregate");
-        boolean agg = ag != null && ag.equalsIgnoreCase("true");
+        String aggregate = service.getAttribute("aggregate");
+        boolean agg = aggregate != null && aggregate.equalsIgnoreCase("true");
         
-        String op = service.getAttribute("optional");
-        boolean opt = op != null && op.equalsIgnoreCase("true");
+        String optional = service.getAttribute("optional");
+        boolean opt = optional != null && optional.equalsIgnoreCase("true");
         
-        int policy = AbstractServiceDependency.getPolicy(service);
+        int policy = DependencyModel.getPolicy(service);
         
-        Comparator cmp = AbstractServiceDependency.getComparator(service, getCompositeManager().getGlobalContext());
+        Comparator cmp = DependencyModel.getComparator(service, getCompositeManager().getGlobalContext());
         
         SvcInstance inst = new SvcInstance(this, spec, prop, agg, opt, fil, cmp, policy);
         m_instances.add(inst);
         
         String sources = service.getAttribute("context-source");
         if (sources != null) {
-            SourceManager sm = new SourceManager(sources, filter, inst, getCompositeManager());
+            SourceManager source = new SourceManager(sources, filter, inst, getCompositeManager());
             if (m_sources == null) {
                 m_sources = new ArrayList(1);
             }
-            m_sources.add(sm);
+            m_sources.add(source);
         }
     }
     
@@ -129,15 +129,19 @@
      * Create a Service importer object from the given Element.
      * This method parse the given element and configure the service importer object.
      * @param imp : Element describing the import
-     * @param filterConfiguration : instance filter customization
+     * @param confFilter : instance filter customization
      * @throws ConfigurationException : the service importer cannot be created correctly
      */
-    private void createServiceImport(Element imp, Dictionary filterConfiguration) throws ConfigurationException {
+    private void createServiceImport(Element imp, Dictionary confFilter) throws ConfigurationException {
         boolean optional = false;
         boolean aggregate = false;
         String specification = imp.getAttribute("specification");
 
-        if (specification != null) {
+        if (specification == null) { 
+            // Malformed import
+            error("Malformed imports : the specification attribute is mandatory");
+            throw new ConfigurationException("Malformed imports : the specification attribute is mandatory");
+        } else {
             String opt = imp.getAttribute("optional");
             optional = opt != null && opt.equalsIgnoreCase("true");
 
@@ -146,28 +150,28 @@
 
             String original = "(&(objectClass=" + specification + ")(!(instance.name=" + getCompositeManager().getInstanceName() + ")))"; // Cannot import yourself
             String filter = original;
-            String f = imp.getAttribute("filter");
-            if (f != null) {
-                filter = "(&" + filter + f + ")";
+            String givenFilter = imp.getAttribute("filter");
+            if (givenFilter != null) {
+                filter = "(&" + filter + givenFilter + ")"; //NOPMD
             }
 
-            String id = imp.getAttribute("id");
+            String identitity = imp.getAttribute("id");
 
             String scope = imp.getAttribute("scope");
-            BundleContext bc = getCompositeManager().getGlobalContext(); // Get the default bundle context.
+            BundleContext context = getCompositeManager().getGlobalContext(); // Get the default bundle context.
             if (scope != null) {
                 if (scope.equalsIgnoreCase("global")) {
-                    bc = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.GLOBAL);
+                    context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.GLOBAL);
                 } else if (scope.equalsIgnoreCase("composite")) {
-                    bc = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL);
+                    context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL);
                 } else if (scope.equalsIgnoreCase("composite+global")) {
-                    bc = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL_AND_GLOBAL);
+                    context = new PolicyServiceContext(getCompositeManager().getGlobalContext(), getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL_AND_GLOBAL);
                 }
             }
 
             // Configure instance filter if available
-            if (filterConfiguration != null && id != null && filterConfiguration.get(id) != null) {
-                filter = "(&" + original + (String) filterConfiguration.get(id) + ")";
+            if (confFilter != null && identitity != null && confFilter.get(identitity) != null) {
+                filter = "(&" + original + (String) confFilter.get(identitity) + ")";
             }
 
             Filter fil = null;
@@ -179,25 +183,22 @@
                 }
             }
 
-            Comparator cmp = AbstractServiceDependency.getComparator(imp, getCompositeManager().getGlobalContext());
-            Class spec = AbstractServiceDependency.loadSpecification(specification, getCompositeManager().getGlobalContext());
-            int policy = AbstractServiceDependency.getPolicy(imp);
+            Comparator cmp = DependencyModel.getComparator(imp, getCompositeManager().getGlobalContext());
+            Class spec = DependencyModel.loadSpecification(specification, getCompositeManager().getGlobalContext());
+            int policy = DependencyModel.getPolicy(imp);
 
-            ServiceImporter si = new ServiceImporter(spec, fil, aggregate, optional, cmp, policy, bc, id, this);
-            m_importers.add(si);
+            ServiceImporter importer = new ServiceImporter(spec, fil, aggregate, optional, cmp, policy, context, identitity, this);
+            m_importers.add(importer);
             
             String sources = imp.getAttribute("context-source");
             if (sources != null) {
-                SourceManager sm = new SourceManager(sources, filter, si, getCompositeManager());
+                SourceManager source = new SourceManager(sources, filter, importer, getCompositeManager());
                 if (m_sources == null) {
                     m_sources = new ArrayList(1);
                 }
-                m_sources.add(sm);
+                m_sources.add(source);
             }
             
-        } else { // Malformed import
-            error("Malformed imports : the specification attribute is mandatory");
-            throw new ConfigurationException("Malformed imports : the specification attribute is mandatory");
         }
     }
 
@@ -211,9 +212,9 @@
     public void configure(Element metadata, Dictionary conf) throws ConfigurationException {
         Element[] services = metadata.getElements("subservice");
         // Get instance filters
-        Dictionary filtersConfiguration = null;
+        Dictionary confFilter = null;
         if (conf.get("requires.filters") != null) {
-            filtersConfiguration = (Dictionary) conf.get("requires.filters");
+            confFilter = (Dictionary) conf.get("requires.filters");
         }
         
         for (int i = 0; i < services.length; i++) {
@@ -223,7 +224,7 @@
             } else if ("instantiate".equalsIgnoreCase(action)) {
                 createServiceInstance(services[i]);
             } else if ("import".equalsIgnoreCase(action)) {
-                createServiceImport(services[i], filtersConfiguration);
+                createServiceImport(services[i], confFilter);
             } else {
                 throw new ConfigurationException("Unknown action : " + action);
             }
@@ -240,13 +241,13 @@
      */
     public void start() {
         for (int i = 0; m_sources != null && i < m_sources.size(); i++) {
-            SourceManager sm = (SourceManager) m_sources.get(i);
-            sm.start();
+            SourceManager source = (SourceManager) m_sources.get(i);
+            source.start();
         }
         
         for (int i = 0; i < m_importers.size(); i++) {
-            ServiceImporter si = (ServiceImporter) m_importers.get(i);
-            si.start();
+            ServiceImporter imp = (ServiceImporter) m_importers.get(i);
+            imp.start();
         }
         
         for (int i = 0; i < m_instances.size(); i++) {
@@ -264,8 +265,8 @@
      */
     private void isHandlerValid() {
         for (int i = 0; i < m_importers.size(); i++) {
-            ServiceImporter si = (ServiceImporter) m_importers.get(i);
-            if (si.getState() != AbstractServiceDependency.RESOLVED) {
+            ServiceImporter imp = (ServiceImporter) m_importers.get(i);
+            if (imp.getState() != DependencyModel.RESOLVED) {
                 setValidity(false);
                 return;
             }
@@ -273,7 +274,7 @@
         
         for (int i = 0; i < m_instances.size(); i++) {
             SvcInstance inst = (SvcInstance) m_instances.get(i);
-            if (inst.getState() != AbstractServiceDependency.RESOLVED) {
+            if (inst.getState() != DependencyModel.RESOLVED) {
                 setValidity(false);
                 return;
             }
@@ -289,8 +290,8 @@
      */
     public void stop() {
         for (int i = 0; m_sources != null && i < m_sources.size(); i++) {
-            SourceManager sm = (SourceManager) m_sources.get(i);
-            sm.stop();
+            SourceManager source = (SourceManager) m_sources.get(i);
+            source.stop();
         }
         
         for (int i = 0; i < m_instances.size(); i++) {
@@ -299,8 +300,8 @@
         }
         
         for (int i = 0; i < m_importers.size(); i++) {
-            ServiceImporter si = (ServiceImporter) m_importers.get(i);
-            si.stop();
+            ServiceImporter imp = (ServiceImporter) m_importers.get(i);
+            imp.stop();
         }
 
         m_isStarted = false;
@@ -316,16 +317,16 @@
         // If we are becoming valid and started, check if we need to freeze importers.
         if (m_isStarted && newState == ComponentInstance.VALID) { 
             for (int i = 0; i < m_importers.size(); i++) {
-                ServiceImporter si = (ServiceImporter) m_importers.get(i);
-                if (si.getBindingPolicy() == AbstractServiceDependency.STATIC_BINDING_POLICY) {
-                    si.freeze();
+                ServiceImporter imp = (ServiceImporter) m_importers.get(i);
+                if (imp.getBindingPolicy() == DependencyModel.STATIC_BINDING_POLICY) {
+                    imp.freeze();
                 }
             }
             
             for (int i = 0; i < m_instances.size(); i++) {
-                SvcInstance si = (SvcInstance) m_instances.get(i);
-                if (si.getBindingPolicy() == AbstractServiceDependency.STATIC_BINDING_POLICY) {
-                    si.freeze();
+                SvcInstance imp = (SvcInstance) m_instances.get(i);
+                if (imp.getBindingPolicy() == DependencyModel.STATIC_BINDING_POLICY) {
+                    imp.freeze();
                 }
             }
         }
@@ -335,7 +336,7 @@
      * An service instance becomes valid.
      * @param dep : dependency becoming valid.
      */
-    public void validate(AbstractServiceDependency dep) {
+    public void validate(DependencyModel dep) {
         if (!getValidity()) {
             isHandlerValid();
         }
@@ -345,7 +346,7 @@
      * A service instance becomes invalid.
      * @param dep : dependency becoming valid.
      */
-    public void invalidate(AbstractServiceDependency dep) {
+    public void invalidate(DependencyModel dep) {
         if (getValidity()) {
             isHandlerValid();
         }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceImporter.java Mon Mar  3 07:46:27 2008
@@ -25,7 +25,7 @@
 import java.util.Properties;
 
 import org.apache.felix.ipojo.PolicyServiceContext;
-import org.apache.felix.ipojo.util.AbstractServiceDependency;
+import org.apache.felix.ipojo.util.DependencyModel;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
@@ -35,7 +35,7 @@
  * Import a service form the parent to the internal service registry.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class ServiceImporter extends AbstractServiceDependency {
+public class ServiceImporter extends DependencyModel {
 
     /**
      * Reference on the handler.
@@ -62,7 +62,7 @@
          * Constructor.
          * @param ref : service reference.
          */
-        private Record(ServiceReference ref) {
+        protected Record(ServiceReference ref) {
             m_ref = ref;
         }
 
@@ -100,17 +100,25 @@
 
         /**
          * Test object equality.
-         * @param o : object to confront against the current object.
+         * @param object : object to confront against the current object.
          * @return true if the two objects are equals (same service reference).
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        public boolean equals(Object o) {
-            if (o instanceof Record) {
-                Record rec = (Record) o;
+        public boolean equals(Object object) {
+            if (object instanceof Record) {
+                Record rec = (Record) object;
                 return rec.m_ref == m_ref;
             }
             return false;
         }
+        
+        /**
+         * Hash code method.
+         * @return the hash code by calling the parent method.
+         */
+        public int hashCode() {
+            return super.hashCode();
+        }
     }
 
     /**
@@ -126,7 +134,7 @@
     /**
      * Is this requirement attached to a service-level requirement.
      */
-    private boolean m_isServiceLevelRequirement;
+    private boolean m_specLevelReq;
 
     /**
      * Is the set of used provider frozen ?
@@ -142,19 +150,20 @@
      * @param optional : is the import optional ?
      * @param cmp : comparator to use for the tracking 
      * @param policy : resolving policy
-     * @param bc : bundle context to use for the tracking (can be a servie context)
-     * @param id : requirement id (may be null)
-     * @param in : handler
-     */
-    public ServiceImporter(Class specification, Filter filter, boolean multiple, boolean optional, Comparator cmp, int policy, BundleContext bc, String id, ServiceDependencyHandler in) {
-        super(specification, multiple, optional, filter, cmp, policy, bc, in);
+     * @param context : bundle context to use for the tracking (can be a servie context)
+     * @param identitity : requirement id (may be null)
+     * @param handler : handler
+     */
+    public ServiceImporter(Class specification, Filter filter, boolean multiple, boolean optional, Comparator cmp, int policy, BundleContext context, String identitity
+            , ServiceDependencyHandler handler) {
+        super(specification, multiple, optional, filter, cmp, policy, context, handler);
 
-        this.m_handler = in;
+        this.m_handler = handler;
 
         if (m_id == null) {
             m_id = super.getSpecification().getName();
         } else {
-            m_id = id;
+            m_id = identitity;
         }
 
     }
@@ -209,14 +218,14 @@
      * @return the list containing all record using the given reference
      */
     private List/* <Record> */getRecordsByRef(ServiceReference ref) {
-        List l = new ArrayList();
+        List list = new ArrayList();
         for (int i = 0; i < m_records.size(); i++) {
             Record rec = (Record) m_records.get(i);
             if (rec.m_ref == ref) {
-                l.add(rec);
+                list.add(rec);
             }
         }
-        return l;
+        return list;
     }
 
     /**
@@ -224,11 +233,11 @@
      * @return the list of all imported services.
      */
     public List getProviders() {
-        List l = new ArrayList();
+        List list = new ArrayList();
         for (int i = 0; i < m_records.size(); i++) {
-            l.add((((Record) m_records.get(i)).m_ref).getProperty("instance.name"));
+            list.add((((Record) m_records.get(i)).m_ref).getProperty("instance.name"));
         }
-        return l;
+        return list;
     }
 
     /**
@@ -237,9 +246,9 @@
      * @param b
      */
     public void setServiceLevelDependency() {
-        m_isServiceLevelRequirement = true;
-        PolicyServiceContext bc = new PolicyServiceContext(m_handler.getCompositeManager().getGlobalContext(), m_handler.getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL);
-        setBundleContext(bc);
+        m_specLevelReq = true;
+        PolicyServiceContext context = new PolicyServiceContext(m_handler.getCompositeManager().getGlobalContext(), m_handler.getCompositeManager().getParentServiceContext(), PolicyServiceContext.LOCAL);
+        setBundleContext(context);
     }
 
     public String getId() {
@@ -247,14 +256,14 @@
     }
 
     public boolean isServiceLevelRequirement() {
-        return m_isServiceLevelRequirement;
+        return m_specLevelReq;
     }
 
     /**
      * On Dependency Reconfiguration notification method.
      * @param departs : leaving service references.
      * @param arrivals : new injected service references.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])
+     * @see org.apache.felix.ipojo.util.DependencyModel#onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])
      */
     public void onDependencyReconfiguration(ServiceReference[] departs, ServiceReference[] arrivals) {
         for (int i = 0; departs != null && i < departs.length; i++) {
@@ -270,7 +279,7 @@
      * A new service is injected by the tracker.
      * This method create a 'Record' and register it.
      * @param ref : new service reference.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onServiceArrival(org.osgi.framework.ServiceReference)
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
      */
     public void onServiceArrival(ServiceReference ref) {
         Record rec = new Record(ref);
@@ -283,26 +292,26 @@
      * A used service disappears.
      * This method find the implicated 'Record', dispose it and remove it from the list.
      * @param ref : leaving service reference.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onServiceDeparture(org.osgi.framework.ServiceReference)
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceDeparture(org.osgi.framework.ServiceReference)
      */
     public void onServiceDeparture(ServiceReference ref) {
-        List l = getRecordsByRef(ref);
-        for (int i = 0; i < l.size(); i++) { // Stop the implied record
-            Record rec = (Record) l.get(i);
+        List list = getRecordsByRef(ref);
+        for (int i = 0; i < list.size(); i++) { // Stop the implied record
+            Record rec = (Record) list.get(i);
             rec.dispose();
         }
-        m_records.removeAll(l);
+        m_records.removeAll(list);
     }
 
     /**
      * A used service is modified.
      * @param ref : modified service reference.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onServiceModification(org.osgi.framework.ServiceReference)
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceModification(org.osgi.framework.ServiceReference)
      */
     public void onServiceModification(ServiceReference ref) {
-        List l = getRecordsByRef(ref);
-        for (int i = 0; i < l.size(); i++) { // Stop the implied record
-            Record rec = (Record) l.get(i);
+        List list = getRecordsByRef(ref);
+        for (int i = 0; i < list.size(); i++) { // Stop the implied record
+            Record rec = (Record) list.get(i);
             rec.update();
         }
     }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceInstantiatorDescription.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceInstantiatorDescription.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceInstantiatorDescription.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/ServiceInstantiatorDescription.java Mon Mar  3 07:46:27 2008
@@ -28,7 +28,7 @@
 import org.apache.felix.ipojo.composite.CompositeHandler;
 import org.apache.felix.ipojo.metadata.Attribute;
 import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.util.AbstractServiceDependency;
+import org.apache.felix.ipojo.util.DependencyModel;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -51,12 +51,12 @@
     /**
      * Constructor.
      * 
-     * @param h : composite handler
+     * @param handler : composite handler
      * @param insts : list of service instances
      * @param imps : list of service importers
      */
-    public ServiceInstantiatorDescription(CompositeHandler h, List insts, List imps) {
-        super(h);
+    public ServiceInstantiatorDescription(CompositeHandler handler, List insts, List imps) {
+        super(handler);
         m_instances = insts;
         m_imports = imps;
     }
@@ -75,12 +75,12 @@
             if (imp.getFilter() != null) {
                 impo.addAttribute(new Attribute("Filter", imp.getFilter()));
             }
-            if (imp.getState() == AbstractServiceDependency.RESOLVED) {
+            if (imp.getState() == DependencyModel.RESOLVED) {
                 impo.addAttribute(new Attribute("State", "resolved"));
                 for (int j = 0; j < imp.getProviders().size(); j++) {
-                    Element pr = new Element("Provider", "");
-                    pr.addAttribute(new Attribute("name", (String) imp.getProviders().get(j)));
-                    impo.addElement(pr);
+                    Element prov = new Element("Provider", "");
+                    prov.addAttribute(new Attribute("name", (String) imp.getProviders().get(j)));
+                    impo.addElement(prov);
                 }
             } else {
                 impo.addAttribute(new Attribute("State", "unresolved"));
@@ -93,19 +93,19 @@
             Element service = new Element("Service", "");
             service.addAttribute(new Attribute("Specification", inst.getServiceSpecification()));
             String state = "unresolved";
-            if (inst.getState() == AbstractServiceDependency.RESOLVED) {
+            if (inst.getState() == DependencyModel.RESOLVED) {
                 state = "resolved";
             }
             service.addAttribute(new Attribute("State", state));
             Map map = inst.getMatchingFactories();
             Set keys = map.keySet();
-            Iterator it = keys.iterator();
-            while (it.hasNext()) {
-                ServiceReference ref = (ServiceReference) it.next();
-                Object o = map.get(ref);
-                if (o != null) {
+            Iterator iterator = keys.iterator();
+            while (iterator.hasNext()) {
+                ServiceReference ref = (ServiceReference) iterator.next();
+                Object object = map.get(ref);
+                if (object != null) {
                     Element fact = new Element("Factory", "");
-                    fact.addAttribute(new Attribute("Name", ((ComponentInstance) o).getFactory().getName()));
+                    fact.addAttribute(new Attribute("Name", ((ComponentInstance) object).getFactory().getName()));
                     service.addElement(fact);
                 }
             }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java Mon Mar  3 07:46:27 2008
@@ -33,7 +33,8 @@
 import org.apache.felix.ipojo.MissingHandlerException;
 import org.apache.felix.ipojo.UnacceptableConfiguration;
 import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
-import org.apache.felix.ipojo.util.AbstractServiceDependency;
+import org.apache.felix.ipojo.architecture.PropertyDescription;
+import org.apache.felix.ipojo.util.DependencyModel;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 
@@ -41,7 +42,7 @@
  * Manage a service instantiation. This service create component instance providing the required service specification.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class SvcInstance extends AbstractServiceDependency {
+public class SvcInstance extends DependencyModel {
 
     /**
      * Configuration to push to the instance.
@@ -56,7 +57,7 @@
     /**
      * Map of matching factories Service Reference => instance or null (null if the service reference is not actually used).
      */
-    private Map /* <ServiceReference, Instance> */m_matchingFactories = new HashMap();
+    private Map /* <ServiceReference, Instance> */m_factories = new HashMap();
 
     /**
      * Required specification.
@@ -70,7 +71,7 @@
 
     /**
      * Constructor.
-     * @param h : the handler.
+     * @param handler : the handler.
      * @param spec : required specification.
      * @param conf : instance configuration.
      * @param isAgg : is the service instance an aggregate service ?
@@ -80,12 +81,12 @@
      * @param policy : binding policy
      * @throws ConfigurationException : an attribute cannot be parsed correctly, or is incorrect.
      */
-    public SvcInstance(ServiceDependencyHandler h, String spec, Dictionary conf, boolean isAgg, boolean isOpt, Filter filt, Comparator cmp, int policy) throws ConfigurationException {
-        super(Factory.class, isAgg, isOpt, filt, cmp, policy, null, h);
+    public SvcInstance(ServiceDependencyHandler handler, String spec, Dictionary conf, boolean isAgg, boolean isOpt, Filter filt, Comparator cmp, int policy) throws ConfigurationException {
+        super(Factory.class, isAgg, isOpt, filt, cmp, policy, null, handler);
 
         m_specification = spec;
 
-        m_handler = h;
+        m_handler = handler;
         setBundleContext(m_handler.getCompositeManager().getServiceContext());
 
         m_configuration = conf;
@@ -97,17 +98,17 @@
     public void stop() {
         super.stop();
 
-        Set keys = m_matchingFactories.keySet();
-        Iterator it = keys.iterator();
-        while (it.hasNext()) {
-            ServiceReference ref = (ServiceReference) it.next();
-            Object o = m_matchingFactories.get(ref);
-            if (o != null) {
-                ((ComponentInstance) o).dispose();
+        Set keys = m_factories.keySet();
+        Iterator iterator = keys.iterator();
+        while (iterator.hasNext()) {
+            ServiceReference ref = (ServiceReference) iterator.next();
+            Object object = m_factories.get(ref);
+            if (object != null) {
+                ((ComponentInstance) object).dispose();
             }
         }
 
-        m_matchingFactories.clear();
+        m_factories.clear();
 
     }
 
@@ -133,14 +134,14 @@
      */
     private ComponentInstance createInstance(Factory factory) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
         // Recreate the configuration to avoid sharing.
-        Properties p = new Properties();
-        Enumeration kk = m_configuration.keys();
-        while (kk.hasMoreElements()) {
-            String k = (String) kk.nextElement();
-            p.put(k, m_configuration.get(k));
+        Properties props = new Properties();
+        Enumeration keys = m_configuration.keys();
+        while (keys.hasMoreElements()) {
+            String key = (String) keys.nextElement();
+            props.put(key, m_configuration.get(key));
         }
         ComponentInstance instance = null;
-        instance = factory.createComponentInstance(p);
+        instance = factory.createComponentInstance(props);
         return instance;
     }
 
@@ -161,22 +162,17 @@
             if (provides[i].equals(m_specification)) {
                 // Check that the factory needs every properties contained in
                 // the configuration
-                org.apache.felix.ipojo.architecture.PropertyDescription[] props = desc.getProperties();
-                Enumeration e = m_configuration.keys();
-                while (e.hasMoreElements()) {
-                    String k = (String) e.nextElement();
-                    if (!containsProperty(k, props)) { return false; }
-                }
-
-                Properties p = new Properties();
+                PropertyDescription[] props = desc.getProperties();
+                Properties conf = new Properties();
                 Enumeration keys = m_configuration.keys();
                 while (keys.hasMoreElements()) {
-                    String k = (String) keys.nextElement();
-                    p.put(k, m_configuration.get(k));
+                    String key = (String) keys.nextElement();
+                    if (!containsProperty(key, props)) { return false; }
+                    conf.put(key, m_configuration.get(key));
                 }
 
                 Factory factory = (Factory) getService(fact);
-                return factory.isAcceptable(p);
+                return factory.isAcceptable(conf);
             }
         }
         return false;
@@ -209,14 +205,14 @@
      * @return the map of used references.
      */
     protected Map getMatchingFactories() {
-        return m_matchingFactories;
+        return m_factories;
     }
 
     /**
      * On Dependency Reconfiguration notification method.
      * @param departs : leaving service references.
      * @param arrivals : new injected service references.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])
+     * @see org.apache.felix.ipojo.util.DependencyModel#onDependencyReconfiguration(org.osgi.framework.ServiceReference[], org.osgi.framework.ServiceReference[])
      */
     public void onDependencyReconfiguration(ServiceReference[] departs, ServiceReference[] arrivals) {
         for (int i = 0; departs != null && i < departs.length; i++) {
@@ -232,14 +228,14 @@
      * A new service is injected.
      * This method create the sub-service instance in the composite.
      * @param ref : service reference.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onServiceArrival(org.osgi.framework.ServiceReference)
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
      */
     public void onServiceArrival(ServiceReference ref) {
         // The given factory matches.
         try {
             Factory fact = (Factory) getService(ref);
-            ComponentInstance ci = createInstance(fact);
-            m_matchingFactories.put(ref, ci);
+            ComponentInstance instance = createInstance(fact);
+            m_factories.put(ref, instance);
         } catch (UnacceptableConfiguration e) {
             m_handler.error("A matching factory refuse the actual configuration : " + e.getMessage());
             m_handler.getCompositeManager().stop();
@@ -258,13 +254,13 @@
      * A used service is leaving.
      * This method dispose the created instance.
      * @param ref : leaving service reference.
-     * @see org.apache.felix.ipojo.util.AbstractServiceDependency#onServiceDeparture(org.osgi.framework.ServiceReference)
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceDeparture(org.osgi.framework.ServiceReference)
      */
     public void onServiceDeparture(ServiceReference ref) {
         // Remove the reference is contained
-        Object o = m_matchingFactories.remove(ref);
-        if (o != null) {
-            ((ComponentInstance) o).dispose();
+        Object instance = m_factories.remove(ref);
+        if (instance != null) {
+            ((ComponentInstance) instance).dispose();
         }
     }
 

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionException.java Mon Mar  3 07:46:27 2008
@@ -24,32 +24,18 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class CompositionException extends Exception {
-
+    //TODO consider removing this class to use configuration exception.
     /**
      * serialVersionUID.
      */
     private static final long serialVersionUID = -3063353267573738105L;
 
     /**
-     * Message.
-     */
-    private String m_message;
-
-    /**
      * Constructor.
      * @param message : a message.
      */
     public CompositionException(String message) {
-        m_message = message;
-    }
-
-    /**
-     * Get the exception message.
-     * @return the message.
-     * @see java.lang.Throwable#getMessage()
-     */
-    public String getMessage() {
-        return m_message;
+        super(message);
     }
 
 }

Modified: felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java?rev=633138&r1=633137&r2=633138&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java (original)
+++ felix/sandbox/clement/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java Mon Mar  3 07:46:27 2008
@@ -58,7 +58,7 @@
     /**
      * Manipulation Metadata.
      */
-    private Element m_manipulationMetadata;
+    private Element m_manipulation;
 
     /**
      * Reference on the handler.
@@ -72,13 +72,13 @@
 
     /**
      * Constructor.
-     * @param bc : bundle context
+     * @param context : bundle context
      * @param description : 'provides' element
      * @param psh : parent handler 
      * @param name : name of the composition.
      */
-    public CompositionMetadata(BundleContext bc, Element description, ProvidedServiceHandler psh, String name) {
-        m_context = bc;
+    public CompositionMetadata(BundleContext context, Element description, ProvidedServiceHandler psh, String name) {
+        m_context = context;
         m_handler = psh;
         // Get the composition name
         m_name = description.getAttribute("specification") + name;
@@ -169,8 +169,8 @@
         buildAvailableMappingList();
 
         // Dependency closure is OK, now look for method delegation
-        Map/* <MethodMetadata, Mapping> */availableSvcMethods = new HashMap();
-        Map/* <MethodMetadata, Mapping> */availableInstMethods = new HashMap();
+        Map/* <MethodMetadata, Mapping> */svcMethods = new HashMap();
+        Map/* <MethodMetadata, Mapping> */instMethods = new HashMap();
 
         for (int i = 0; i < m_mappings.size(); i++) {
             Mapping map = (Mapping) m_mappings.get(i);
@@ -178,9 +178,9 @@
             for (int j = 0; j < spec.getMethods().size(); j++) {
                 MethodMetadata method = (MethodMetadata) spec.getMethods().get(j);
                 if (spec.isInterface()) {
-                    availableSvcMethods.put(method, map);
+                    svcMethods.put(method, map);
                 } else {
-                    availableInstMethods.put(method, map);
+                    instMethods.put(method, map);
                 }
             }
         }
@@ -188,26 +188,26 @@
         // For each needed method, search if available and store the mapping
         for (int j = 0; j < m_specification.getMethods().size(); j++) {
             MethodMetadata method = (MethodMetadata) m_specification.getMethods().get(j);
-            Set keys = availableInstMethods.keySet(); // Look first in methods contained in the glue code.
-            Iterator it = keys.iterator();
+            Set keys = instMethods.keySet(); // Look first in methods contained in the glue code.
+            Iterator iterator = keys.iterator();
             boolean found = false;
-            while (it.hasNext() & !found) {
-                MethodMetadata met = (MethodMetadata) it.next();
+            while (iterator.hasNext() & !found) {
+                MethodMetadata met = (MethodMetadata) iterator.next();
                 if (met.equals(method)) {
                     found = true;
-                    FieldMetadata field = ((Mapping) availableInstMethods.get(met)).getField();
+                    FieldMetadata field = ((Mapping) instMethods.get(met)).getField();
                     field.setUseful(true);
                     method.setDelegation(field);
                 }
             }
             if (!found) { // If not found looks inside method contained in services.
-                keys = availableSvcMethods.keySet(); // Look first in methods contained in the glue code
-                it = keys.iterator();
-                while (!found && it.hasNext()) {
-                    MethodMetadata met = (MethodMetadata) it.next();
+                keys = svcMethods.keySet(); // Look first in methods contained in the glue code
+                iterator = keys.iterator();
+                while (!found && iterator.hasNext()) {
+                    MethodMetadata met = (MethodMetadata) iterator.next();
                     if (met.equals(method)) {
                         found = true;
-                        FieldMetadata field = ((Mapping) availableSvcMethods.get(met)).getField();
+                        FieldMetadata field = ((Mapping) svcMethods.get(met)).getField();
                         field.setUseful(true);
                         method.setDelegation(field);
                         // Test optional
@@ -234,23 +234,23 @@
             return null;
         }
         byte[] pojo = POJOWriter.dump(clazz, m_name, getFieldList(), getMethodList());
-        Manipulator m = new Manipulator();
+        Manipulator manipulator = new Manipulator();
         try {
-            byte[] ff = m.manipulate(pojo);
-            m_manipulationMetadata = m.getManipulationMetadata();
-            return ff;
+            byte[] newclazz = manipulator.manipulate(pojo);
+            m_manipulation = manipulator.getManipulationMetadata();
+            return newclazz;
         } catch (IOException e) {
-            e.printStackTrace();
+            m_handler.error("An error occurs during the composite implementation creation : " + e.getMessage(), e);
         }
         return null;
     }
 
     /**
      * Build service implementation metadata.
-     * @param in : name of the future instance (used to avoid cycle)
+     * @param name : name of the future instance (used to avoid cycle)
      * @return Component Type metadata. 
      */
-    protected Element buildMetadata(String in) {
+    protected Element buildMetadata(String name) {
         Element elem = new Element("component", "");
         Attribute className = new Attribute("className", m_name);
         Attribute factory = new Attribute("factory", "false");
@@ -276,7 +276,7 @@
                 if (field.getSpecification().isOptional()) {
                     dep.addAttribute(new Attribute("optional", "true"));
                 }
-                dep.addAttribute(new Attribute("filter", "(!(instance.name=" + in + "))"));
+                dep.addAttribute(new Attribute("filter", "(!(instance.name=" + name + "))"));
                 elem.addElement(dep);
             }
         }
@@ -295,7 +295,7 @@
         }
 
         // Insert information to metadata
-        elem.addElement(m_manipulationMetadata);
+        elem.addElement(m_manipulation);
 
         return elem;
     }