You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2007/03/09 17:50:33 UTC

svn commit: r516458 [1/2] - in /incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo: ./ architecture/ handlers/configuration/ handlers/dependency/ handlers/dependency/nullable/ handlers/lifecycle/callback/ handlers/providedservice/ parser/...

Author: rickhall
Date: Fri Mar  9 08:50:30 2007
New Revision: 516458

URL: http://svn.apache.org/viewvc?view=rev&rev=516458
Log:
Applied patch (FELIX-222) to allow properties to be reconfigured and 
propagated to service registrations via ManagedServiceFactory.

Modified:
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Activator.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/DefaultServiceContext.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoContext.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceCreator.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ServiceContext.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/MethodSignatureVisitor.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/NullableObjectWriter.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/parser/ManifestMetadataParser.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/parser/ParseUtils.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/util/Callback.java
    incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/util/Logger.java

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Activator.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Activator.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Activator.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Activator.java Fri Mar  9 08:50:30 2007
@@ -75,9 +75,7 @@
             System.arraycopy(m_factories, 0, newFactory, 0, m_factories.length);
             newFactory[m_factories.length] = factory;
             m_factories = newFactory;
-        }
-        // Else create an array of size one with the new Factory
-        else { m_factories = new ComponentFactory[] {factory}; }
+        } else { m_factories = new ComponentFactory[] {factory}; }         // Else create an array of size one with the new Factory
     }
 
     /**
@@ -111,7 +109,7 @@
             ComponentFactory factory = m_factories[i];
             factory.stop();
         }
-        if(m_creator != null) { m_creator.stop(); }
+        if (m_creator != null) { m_creator.stop(); }
         m_factories = new ComponentFactory[0]; // Release all factories
     }
 
@@ -140,32 +138,32 @@
      */
     private void start() {
     	// Start the factories
-    	for(int j = 0; j < m_factories.length; j++) { m_factories[j].start(); }
+    	for (int j = 0; j < m_factories.length; j++) { m_factories[j].start(); }
     	
     	Dictionary[] outsiders = new Dictionary[0];
-    	for(int i = 0; i < m_configurations.length; i++) {
+    	for (int i = 0; i < m_configurations.length; i++) {
     		Dictionary conf = m_configurations[i];
     		boolean created = false;
-    		for(int j = 0; j < m_factories.length; j++) {
+    		for (int j = 0; j < m_factories.length; j++) {
     			String componentClass = m_factories[j].getComponentClassName();
     			String factoryName = m_factories[j].getFactoryName();
-    			if(conf.get("component") != null && (conf.get("component").equals(componentClass) || conf.get("component").equals(factoryName))) {
+    			if (conf.get("component") != null && (conf.get("component").equals(componentClass) || conf.get("component").equals(factoryName))) {
     				try {
 						m_factories[j].createComponentInstance(conf);
 	    				created = true;
 					} catch (UnacceptableConfiguration e) {
-						System.err.println("Cannot create the instance " + conf.get("name") +" : " + e.getMessage());
+						System.err.println("Cannot create the instance " + conf.get("name") + " : " + e.getMessage());
 					} 
     			}
     		}
-    		if(!created && conf.get("component") != null) {
+    		if (!created && conf.get("component") != null) {
     	        if (outsiders.length != 0) {
     	            Dictionary[] newList = new Dictionary[outsiders.length + 1];
     	            System.arraycopy(outsiders, 0, newList, 0, outsiders.length);
     	            newList[outsiders.length] = conf;
     	            outsiders = newList;
-    	        }
-    	        else { outsiders = new Dictionary[] {conf}; }
+    	        } else { outsiders = new Dictionary[] {conf}; }
+    	        
     		}
     	}
     	

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java Fri Mar  9 08:50:30 2007
@@ -94,7 +94,7 @@
     private ComponentDescription m_componentDesc;
     
     /**
-     * Logger for the factory (and all component instance)
+     * Logger for the factory (and all component instance).
      */
     private Logger m_logger;
 
@@ -103,7 +103,10 @@
      */
     private class FactoryClassloader extends ClassLoader  {
     	
-    	HashMap m_definedClasses = new HashMap();
+    	/**
+    	 * Map of defined classes [Name, Class Object].
+    	 */
+    	private HashMap m_definedClasses = new HashMap();
 
         /**
          * load the class.
@@ -150,7 +153,7 @@
          */
         public Class defineClass(String name, byte[] b,
                 ProtectionDomain domain) throws Exception {
-        	if(m_definedClasses.containsKey(name)) { return (Class) m_definedClasses.get(name); } 
+        	if (m_definedClasses.containsKey(name)) { return (Class) m_definedClasses.get(name); } 
             Class c = super.defineClass(name, b, 0, b.length, domain);
             m_definedClasses.put(name, c);
             return c;
@@ -184,8 +187,9 @@
         m_componentMetadata = cm;
         
         // Get factory PID :
-        if (m_componentMetadata.containsAttribute("factory") && !m_componentMetadata.getAttribute("factory").equalsIgnoreCase("no")) { m_factoryName = m_componentMetadata.getAttribute("factory"); }
-        else { m_factoryName = m_componentMetadata.getAttribute("className"); }
+        if (m_componentMetadata.containsAttribute("factory") && !m_componentMetadata.getAttribute("factory").equalsIgnoreCase("no")) { 
+        	m_factoryName = m_componentMetadata.getAttribute("factory");
+        } else { m_factoryName = m_componentMetadata.getAttribute("className"); }
         
         m_logger = new Logger(m_context, m_factoryName, Logger.WARNING);
     }
@@ -203,8 +207,9 @@
         m_componentMetadata = cm;
         
         // Get factory PID :
-        if (m_componentMetadata.containsAttribute("factory") && !m_componentMetadata.getAttribute("factory").equalsIgnoreCase("no")) { m_factoryName = m_componentMetadata.getAttribute("factory"); }
-        else { m_factoryName = m_componentMetadata.getAttribute("className"); }
+        if (m_componentMetadata.containsAttribute("factory") && !m_componentMetadata.getAttribute("factory").equalsIgnoreCase("no")) { 
+        	m_factoryName = m_componentMetadata.getAttribute("factory"); 
+        } else { m_factoryName = m_componentMetadata.getAttribute("className"); }
         
         m_logger = new Logger(m_context, m_factoryName, Logger.WARNING);
     }
@@ -217,7 +222,7 @@
         Iterator it = col.iterator();
         while (it.hasNext()) {
             ComponentInstance ci = (ComponentInstance) it.next();
-            if(ci.isStarted()) { ci.stop(); }
+            if (ci.isStarted()) { ci.stop(); }
         }
         m_componentInstances.clear();
         if (m_sr != null) { m_sr.unregister(); }
@@ -279,8 +284,16 @@
         return m_context.getBundle().loadClass(className);
     }
     
+    /**
+     * Define a class.
+     * @param name : qualified name of the class
+     * @param b : byte array of the class
+     * @param domain : protection domain of the class
+     * @return the defined class object
+     * @throws Exception : an exception occur during the definition
+     */
     public Class defineClass(String name, byte[] b, ProtectionDomain domain) throws Exception {
-    	if(m_classLoader == null) { m_classLoader = new FactoryClassloader(); }
+    	if (m_classLoader == null) { m_classLoader = new FactoryClassloader(); }
     	return m_classLoader.defineClass(name, b, domain);
     }
 
@@ -299,9 +312,9 @@
     public ComponentInstance createComponentInstance(Dictionary configuration)  throws UnacceptableConfiguration {
     	try {
     		_isAcceptable(configuration);
-    	} catch(UnacceptableConfiguration e) {
+    	} catch (UnacceptableConfiguration e) {
     		m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
-    		throw new UnacceptableConfiguration("The configuration " + configuration + " is not acceptable for " + m_factoryName + ": " + e.getMessage() );
+    		throw new UnacceptableConfiguration("The configuration " + configuration + " is not acceptable for " + m_factoryName + ": " + e.getMessage());
     	}
     	
         IPojoContext context = new IPojoContext(m_context);
@@ -310,8 +323,9 @@
         instance.configure(m_componentMetadata, configuration);
 
         String pid = null;
-        if (configuration.get("name") != null) { pid = (String) configuration.get("name"); }
-        else { pid = m_componentMetadata.getAttribute("className"); }
+        if (configuration.get("name") != null) { 
+        	pid = (String) configuration.get("name"); 
+        } else { pid = m_componentMetadata.getAttribute("className"); }
 
         m_componentInstances.put(pid, instance);
         instance.start();
@@ -324,9 +338,9 @@
     public ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration {
     	try {
     		_isAcceptable(configuration);
-    	} catch(UnacceptableConfiguration e) {
+    	} catch (UnacceptableConfiguration e) {
     		m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
-    		throw new UnacceptableConfiguration("The configuration " + configuration + " is not acceptable for " + m_factoryName + ": " + e.getMessage() );
+    		throw new UnacceptableConfiguration("The configuration " + configuration + " is not acceptable for " + m_factoryName + ": " + e.getMessage());
     	}
     	
     	IPojoContext context = new IPojoContext(m_context, serviceContext);
@@ -335,8 +349,11 @@
         instance.configure(m_componentMetadata, configuration);
 
         String pid = null;
-        if (configuration.get("name") != null) { pid = (String) configuration.get("name"); }
-        else { pid = m_componentMetadata.getAttribute("className"); }
+        if (configuration.get("name") != null) { 
+        	pid = (String) configuration.get("name"); 
+        } else { 
+        	pid = m_componentMetadata.getAttribute("className");
+        }
 
         m_componentInstances.put(pid, instance);
         instance.start();
@@ -350,8 +367,9 @@
      */
     public void deleted(String pid) {
         InstanceManager cm = (InstanceManager) m_componentInstances.remove(pid);
-        if (cm == null) { return;  } // do nothing, the component does not exist !
-        else { cm.stop(); }
+        if (cm == null) { 
+        	return; // do nothing, the component does not exist !  
+        } else { cm.stop(); }
     }
 
     /**
@@ -372,10 +390,7 @@
         		m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
         		throw new ConfigurationException(properties.toString(), e.getMessage());
         	} 
-        }
-        else {
-            cm.stop(); // Stop the component
-            
+        } else {            
             try {
             	properties.put("name", pid); // Add the name in the configuration
 				_isAcceptable(properties); // Test if the configuration is acceptable
@@ -383,9 +398,7 @@
 				m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
         		throw new ConfigurationException(properties.toString(), e.getMessage());
 			}
-			
-            cm.configure(m_componentMetadata, properties); // re-configure the component
-            cm.start(); // restart it
+            cm.reconfigure(properties); // re-configure the component
         }
     }
     
@@ -402,28 +415,47 @@
      */
     public boolean isAcceptable(Dictionary conf) {
     	// First check that the configuration contains a name : 
-    	if(conf.get("name") == null) { return false; }
+    	if (conf.get("name") == null) { return false; }
     	PropertyDescription[] props = m_componentDesc.getProperties();
-    	for(int i = 0; i < props.length; i++) {
+    	for (int i = 0; i < props.length; i++) {
     		PropertyDescription pd = props[i];
     		// Failed if the props has no default value and the configuration does not push a value 
-    		if(pd.getValue() == null && conf.get(pd.getName()) == null) {
+    		if (pd.getValue() == null && conf.get(pd.getName()) == null) {
     			return false;
     		}
     	}
     	return true;
     }
     
+    /**
+     * Test is a configuration is acceptable for the factory.
+     * @param conf : the configuration to test.
+     * @throws UnacceptableConfiguration : the configuration is not acceptable.
+     */
     private void _isAcceptable(Dictionary conf) throws UnacceptableConfiguration {
-    	if(conf == null || conf.get("name") == null) { throw new UnacceptableConfiguration("The configuration does not contains the \"name\" property"); }
+    	if (conf == null || conf.get("name") == null) { throw new UnacceptableConfiguration("The configuration does not contains the \"name\" property"); }
     	PropertyDescription[] props = m_componentDesc.getProperties();
-    	for(int i = 0; i < props.length; i++) {
+    	for (int i = 0; i < props.length; i++) {
     		PropertyDescription pd = props[i];
     		// Failed if the props has no default value and the configuration does not push a value 
-    		if(pd.getValue() == null && conf.get(pd.getName()) == null) {
+    		if (pd.getValue() == null && conf.get(pd.getName()) == null) {
     			throw new UnacceptableConfiguration("The configuration does not contains the \"" + pd.getName() + "\" property");
     		}
     	}
     }
 
+	/**
+	 * @see org.apache.felix.ipojo.Factory#reconfigure(java.util.Dictionary)
+	 */
+	public void reconfigure(Dictionary properties) throws UnacceptableConfiguration {
+		if (properties == null || properties.get("name") == null) { throw new UnacceptableConfiguration("The configuration does not contains the \"name\" property"); }
+		String name = (String) properties.get("name");
+		InstanceManager cm = (InstanceManager) m_componentInstances.get(name);
+        if (cm == null) { 
+        	return;  // The instance does not exist.
+        } else {
+            _isAcceptable(properties); // Test if the configuration is acceptable
+		}			
+        cm.reconfigure(properties); // re-configure the component
+	}
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentInstance.java Fri Mar  9 08:50:30 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.ipojo;
 
+import java.util.Dictionary;
+
 import org.apache.felix.ipojo.architecture.ComponentDescription;
 import org.osgi.framework.BundleContext;
 
@@ -85,6 +87,14 @@
      * @return true if getState returns INVALID or VALID.
      */
     boolean isStarted();
+    
+    /**
+     * Re-configurare an instance.
+     * Do nothing if the instance does not support dynamic reconfiguration.
+     * The reconfiguration does not stop the instance.
+     * @param configuration : the new configuration.
+     */
+    void reconfigure(Dictionary configuration);
 
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/DefaultServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/DefaultServiceContext.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/DefaultServiceContext.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/DefaultServiceContext.java Fri Mar  9 08:50:30 2007
@@ -26,64 +26,117 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
+/**
+ * Default iPOJO Service Context.
+ * this service context delegate all calls on the bundle context.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+/**
+ * @author Clement
+ *
+ */
 public class DefaultServiceContext implements ServiceContext {
 	
+	/**
+	 * The bundle context on which delegate.
+	 */
 	private BundleContext m_context;
 	
+	/**
+	 * Instance attached to this service context.
+	 */
 	private ComponentInstance m_instance;
 	
+	/**
+	 * Constructor. 
+	 * @param bc : the bundle context on which delegate.
+	 */
 	public DefaultServiceContext(BundleContext bc) { m_context = bc; }
 
-	public void addServiceListener(ServiceListener listener, String filter)
-			throws InvalidSyntaxException {
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
+	 */
+	public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
 		m_context.addServiceListener(listener, filter);
 	}
 	
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#addServiceListener(org.osgi.framework.ServiceListener)
+	 */
 	public void addServiceListener(ServiceListener listener) {
 		m_context.addServiceListener(listener);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#getAllServiceReferences(java.lang.String, java.lang.String)
+	 */
 	public ServiceReference[] getAllServiceReferences(String clazz,
 			String filter) throws InvalidSyntaxException {
 		return m_context.getAllServiceReferences(clazz, filter);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#getService(org.osgi.framework.ServiceReference)
+	 */
 	public Object getService(ServiceReference reference) {
 		return m_context.getService(reference);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#getServiceReference(java.lang.String)
+	 */
 	public ServiceReference getServiceReference(String clazz) {
 		return m_context.getServiceReference(clazz);
 	}
 
-	public ServiceReference[] getServiceReferences(String clazz, String filter)
-			throws InvalidSyntaxException {
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#getServiceReferences(java.lang.String, java.lang.String)
+	 */
+	public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
 		return m_context.getServiceReferences(clazz, filter);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
+	 */
 	public ServiceRegistration registerService(String[] clazzes,
 			Object service, Dictionary properties) {
 		return m_context.registerService(clazzes, service, properties);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#registerService(java.lang.String, java.lang.Object, java.util.Dictionary)
+	 */
 	public ServiceRegistration registerService(String clazz, Object service,
 			Dictionary properties) {
 		return m_context.registerService(clazz, service, properties);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#removeServiceListener(org.osgi.framework.ServiceListener)
+	 */
 	public void removeServiceListener(ServiceListener listener) {
 		m_context.removeServiceListener(listener);
 
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#ungetService(org.osgi.framework.ServiceReference)
+	 */
 	public boolean ungetService(ServiceReference reference) {
 		return m_context.ungetService(reference);
 	}
 
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#getComponentInstance()
+	 */
 	public ComponentInstance getComponentInstance() {
 		return m_instance;
 	}
 	
+	/**
+	 * @see org.apache.felix.ipojo.ServiceContext#setComponentInstance(org.apache.felix.ipojo.ComponentInstance)
+	 */
 	public void setComponentInstance(ComponentInstance ci) { m_instance =  ci; }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java Fri Mar  9 08:50:30 2007
@@ -62,5 +62,14 @@
      * @return the name of the factory.
      */
     String getName();
+    
+    
+    /**
+     * 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 tragetted instance.
+     */
+    void reconfigure(Dictionary conf) throws UnacceptableConfiguration;
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Handler.java Fri Mar  9 08:50:30 2007
@@ -34,6 +34,7 @@
      * Configure the handler.
      * @param im : the instance manager
      * @param metadata : the metadata of the component
+     * @param configuration : the instance configuration
      */
     public abstract void configure(InstanceManager im, Element metadata, Dictionary configuration);
 
@@ -84,4 +85,10 @@
      * @return the description of the handler..
      */
     public HandlerDescription getDescription() { return new HandlerDescription(this.getClass().getName(), isValid()); }
+
+	/**
+	 * The instance is reconfiguring.
+	 * @param configuration : New instance configuration.
+	 */
+	public void reconfigure(Dictionary configuration) { }
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoContext.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoContext.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoContext.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoContext.java Fri Mar  9 08:50:30 2007
@@ -34,18 +34,18 @@
 import org.osgi.framework.ServiceRegistration;
 
 /**
- * The iPOJO Context is a BundleContext implementation allowing the separation between Bundle context and Service (Bundle) Context
+ * The iPOJO Context is a BundleContext implementation allowing the separation between Bundle context and Service (Bundle) Context.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
 public class IPojoContext implements BundleContext {
 	
 	/**
-	 * BundleContext used to access bundle method
+	 * BundleContext used to access bundle method.
 	 */
 	private BundleContext m_bundleContext;
 	
 	/**
-	 * Service Context used to access service interaction 
+	 * Service Context used to access service interaction. 
 	 */
 	private ServiceContext m_serviceContext;
 	
@@ -83,8 +83,9 @@
 	/**
 	 * @see org.osgi.framework.BundleContext#addServiceListener(org.osgi.framework.ServiceListener, java.lang.String)
 	 */
-	public void addServiceListener(ServiceListener listener, String filter)
-			throws InvalidSyntaxException { m_serviceContext.addServiceListener(listener, filter); }
+	public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
+		m_serviceContext.addServiceListener(listener, filter); 
+	}
 
 	/**
 	 * @see org.osgi.framework.BundleContext#addServiceListener(org.osgi.framework.ServiceListener)
@@ -94,13 +95,16 @@
 	/**
 	 * @see org.osgi.framework.BundleContext#createFilter(java.lang.String)
 	 */
-	public Filter createFilter(String filter) throws InvalidSyntaxException { return m_bundleContext.createFilter(filter); }
+	public Filter createFilter(String filter) throws InvalidSyntaxException {
+		return m_bundleContext.createFilter(filter); 
+	}
 
 	/**
 	 * @see org.osgi.framework.BundleContext#getAllServiceReferences(java.lang.String, java.lang.String)
 	 */
-	public ServiceReference[] getAllServiceReferences(String clazz,
-			String filter) throws InvalidSyntaxException { return m_serviceContext.getAllServiceReferences(clazz, filter); }
+	public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+		return m_serviceContext.getAllServiceReferences(clazz, filter); 
+	}
 
 	/**
 	 * @see org.osgi.framework.BundleContext#getBundle()
@@ -140,8 +144,9 @@
 	/**
 	 * @see org.osgi.framework.BundleContext#getServiceReferences(java.lang.String, java.lang.String)
 	 */
-	public ServiceReference[] getServiceReferences(String clazz, String filter)
-			throws InvalidSyntaxException { return m_serviceContext.getServiceReferences(clazz, filter); }
+	public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException { 
+		return m_serviceContext.getServiceReferences(clazz, filter); 
+	}
 
 	/**
 	 * @see org.osgi.framework.BundleContext#installBundle(java.lang.String)
@@ -151,8 +156,9 @@
 	/**
 	 * @see org.osgi.framework.BundleContext#installBundle(java.lang.String, java.io.InputStream)
 	 */
-	public Bundle installBundle(String location, InputStream input)
-			throws BundleException { return m_bundleContext.installBundle(location, input); }
+	public Bundle installBundle(String location, InputStream input) throws BundleException { 
+		return m_bundleContext.installBundle(location, input); 
+	}
 
 	/**
 	 * @see org.osgi.framework.BundleContext#registerService(java.lang.String[], java.lang.Object, java.util.Dictionary)
@@ -187,10 +193,10 @@
 	public boolean ungetService(ServiceReference reference) { return m_serviceContext.ungetService(reference); }
 	
 	/**
-	 * Set the instance manager to the service context.
-	 * @param cm : the component manager
+	 * Set the instance to the service context.
+	 * @param ci : the component instance
 	 */
-	public void setComponentInstance(ComponentInstance ci) {m_serviceContext.setComponentInstance(ci); }
+	public void setComponentInstance(ComponentInstance ci) { m_serviceContext.setComponentInstance(ci); }
 	
 	/**
 	 * Get the instance manager from the service context.

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceCreator.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceCreator.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceCreator.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceCreator.java Fri Mar  9 08:50:30 2007
@@ -34,8 +34,14 @@
  */
 public class InstanceCreator implements ServiceListener {
 	
+	/**
+	 * Bundle Context.
+	 */
 	private BundleContext m_context;
 	
+	/**
+	 * Logger to log messages if error occurs.
+	 */
 	private Logger m_logger;
 	
 	/**
@@ -43,11 +49,53 @@
 	 * It stores all necessary information to create an instance and to track the factory.
 	 */
 	private class ManagedConfiguration {
-		Dictionary configuration;
-		String factoryName;
-		ComponentInstance instance;
+		/**
+		 * Configuration of the instance to create.
+		 */
+		private Dictionary m_configuration;
+		
+		/**
+		 * Factory name. 
+		 */
+		private String m_factoryName;
+		
+		/**
+		 * Created instance. 
+		 */
+		private ComponentInstance m_instance;
+		
+		/**
+		 * Constructor.
+		 * @param conf : the configuration to create.
+		 */
+		ManagedConfiguration(Dictionary conf) { m_configuration = conf; }
+		
+		/**
+		 * @return the configuration.
+		 */
+		Dictionary getConfiguration() { return m_configuration; }
+		
+		/**
+		 * @return the factory
+		 */
+		String getFactory() { return m_factoryName; }
+		
+		/**
+		 * @return the instance (or null if no instance are created).
+		 */
+		ComponentInstance getInstance() { return m_instance; }
 		
-		public ManagedConfiguration(Dictionary conf) { configuration = conf; }
+		/**
+		 * Set the factory name.
+		 * @param name : the factory name.
+		 */
+		void setFactory(String name) { m_factoryName = name; }
+		
+		/**
+		 * Set the instance object.
+		 * @param instance : the instance
+		 */
+		void setInstance(ComponentInstance instance) { m_instance = instance; }
 	}
 	
 	
@@ -56,26 +104,30 @@
 	 */
 	private ManagedConfiguration[] m_configurations;
 	
+	/**
+	 * Constructor.
+	 * @param context : the bundle context.
+	 * @param configurations : configuration set to create and maintain.
+	 */
 	public InstanceCreator(BundleContext context, Dictionary[] configurations) {
 		m_context = context;
-		m_logger = new Logger(context, "InstanceCreator"+context.getBundle().getBundleId(), Logger.WARNING);
+		m_logger = new Logger(context, "InstanceCreator" + context.getBundle().getBundleId(), Logger.WARNING);
 		m_configurations = new ManagedConfiguration[configurations.length];
-		for(int i = 0; i < configurations.length; i++) {
+		for (int i = 0; i < configurations.length; i++) {
 			ManagedConfiguration conf = new ManagedConfiguration(configurations[i]);
 			m_configurations[i] = conf;
 			
 			// Get the component type name :
-			String componentType = (String) conf.configuration.get("component");
+			String componentType = (String) conf.getConfiguration().get("component");
 			Factory fact = null;
 			
 			try {
 				String fil = "(|(" + org.osgi.framework.Constants.SERVICE_PID + "=" + componentType + ")(component.class=" + componentType + "))";
 				ServiceReference[] refs = context.getServiceReferences(org.apache.felix.ipojo.Factory.class.getName(), fil);
-				if(refs != null) { 
+				if (refs != null) { 
 					fact = (Factory) m_context.getService(refs[0]);
 					createInstance(fact, conf);					
-				}
-				else {
+				} else {
 					m_logger.log(Logger.WARNING, "No factory available for the type : " + componentType);
 				}
 			} catch (InvalidSyntaxException e) { m_logger.log(Logger.ERROR, "Invalid syntax filter for the type : " + componentType, e); }
@@ -83,28 +135,36 @@
 		
 		// Register a service listenner on Factory Service
 		try {
-			m_context.addServiceListener(this, "(objectClass="+Factory.class.getName() + ")");
+			m_context.addServiceListener(this, "(objectClass=" + Factory.class.getName() + ")");
 		} catch (InvalidSyntaxException e) { m_logger.log(Logger.ERROR, "Invalid syntax filter when registering a listener on Factory Service", e); }
 	}
 	
+	/**
+	 * Create an instance using the given factory and the given configuration.
+	 * @param fact : the facotry name to used.
+	 * @param config : the configuration.
+	 */
 	private void createInstance(Factory fact, ManagedConfiguration config) {
-		Dictionary conf = config.configuration;
+		Dictionary conf = config.getConfiguration();
 		try {
-				config.instance = fact.createComponentInstance(conf);
-				config.factoryName = fact.getName();
+			config.setInstance(fact.createComponentInstance(conf));
+			config.setFactory(fact.getName());
 		} catch (UnacceptableConfiguration e) {
 			m_logger.log(Logger.ERROR, "A factory is available for the configuration but the configuration is not acceptable", e);
 		}
 	}
 
+	/**
+	 * @see org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
+	 */
 	public void serviceChanged(ServiceEvent ev) {
 		ServiceReference ref = ev.getServiceReference();
 		String factoryName = (String) ref.getProperty(org.osgi.framework.Constants.SERVICE_PID);
 		String componentClass = (String) ref.getProperty("component.class");
 		
-		if(ev.getType() == ServiceEvent.REGISTERED) { //A new factory appears
-			for(int i = 0; i < m_configurations.length; i++) {
-				if(m_configurations[i].instance == null && (m_configurations[i].configuration.get("component").equals(factoryName) ||  m_configurations[i].configuration.get("component").equals(componentClass))) {
+		if (ev.getType() == ServiceEvent.REGISTERED) { //A new factory appears
+			for (int i = 0; i < m_configurations.length; i++) {
+				if (m_configurations[i].getInstance() == null && (m_configurations[i].getConfiguration().get("component").equals(factoryName) ||  m_configurations[i].getConfiguration().get("component").equals(componentClass))) {
 					Factory fact = (Factory) m_context.getService(ref);
 					createInstance(fact, m_configurations[i]);
 				}
@@ -112,27 +172,26 @@
 			return;
 		}
 		
-		if(ev.getType() == ServiceEvent.UNREGISTERING) {
-			for(int i = 0; i < m_configurations.length; i++) {
-				if(m_configurations[i].instance != null && m_configurations[i].factoryName.equals(factoryName)) {
-					m_configurations[i].instance = null;
-					m_configurations[i].factoryName = null;
+		if (ev.getType() == ServiceEvent.UNREGISTERING) {
+			for (int i = 0; i < m_configurations.length; i++) {
+				if (m_configurations[i].getInstance() != null && m_configurations[i].getFactory().equals(factoryName)) {
+					m_configurations[i].setInstance(null);
+					m_configurations[i].setFactory(null);
 					m_context.ungetService(ref);
 				}
 			}
 			return;
 		}
-		
-		//TODO manage modification ? normally a factory should not change its property.
 	}
 	
 	/**
-	 * Stop all created instances
+	 * Stop all created instances.
 	 */
 	public void stop() {
-		for(int i = 0; i < m_configurations.length; i++) {
-			if(m_configurations[i].instance != null) { m_configurations[i].instance.stop(); }
-			m_configurations[i].instance = null;
+		for (int i = 0; i < m_configurations.length; i++) {
+			if (m_configurations[i].getInstance() != null) { m_configurations[i].getInstance().stop(); }
+			m_configurations[i].setInstance(null);
+			m_configurations[i].setFactory(null);
 		}
 		m_configurations = null;
 	}

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/InstanceManager.java Fri Mar  9 08:50:30 2007
@@ -90,6 +90,7 @@
     /**
      * Construct a new Component Manager.
      * @param factory : the factory managing the instance manager
+     * @param bc : the bundle context to give to the instance
      */
     public InstanceManager(ComponentFactory factory, BundleContext bc) {
         m_factory = factory;
@@ -100,7 +101,8 @@
     /**
      * Configure the instance manager.
      * Stop the existings handler, clear the handler list, change the metadata, recreate the handlers
-     * @param cm
+     * @param cm : the component type metadata
+     * @param configuration : the configuration of the instance
      */
     public void configure(Element cm, Dictionary configuration) {
         // Stop all previous registred handler
@@ -150,10 +152,8 @@
                 } catch (IllegalAccessException e) {
                     m_factory.getLogger().log(Logger.ERROR, "[" + m_name + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
                 }
-
             }
         }
-
     }
 
     /**
@@ -161,6 +161,9 @@
      */
     public ComponentDescription getComponentDescription() { return m_componentDesc; }
     
+    /**
+     * @return the instance description.
+     */
     public InstanceDescription getInstanceDescription() {
     	int componentState = getState();
         InstanceDescription instanceDescription = new InstanceDescription(m_name, m_className, componentState, getContext().getBundle().getBundleId());
@@ -200,6 +203,9 @@
      */
     public String getComponentName() { return m_name; }
     
+    /**
+     * @return the implementation class name of the instance.
+     */
     public String getClassName() { return m_className; }
 
     // ===================== Lifecycle management =====================
@@ -208,7 +214,7 @@
      * Start the instance manager.
      */
     public void start() {
-    	if(m_state != STOPPED) { return; } // Instance already started
+    	if (m_state != STOPPED) { return; } // Instance already started
     	
         // Start all the handlers
         m_factory.getLogger().log(Logger.INFO, "[" + m_name + "] Start the instance manager with " + m_handlers.length + " handlers");
@@ -228,7 +234,7 @@
      * Stop the instance manager.
      */
     public void stop() {
-    	if(m_state == STOPPED) { return; } // Instance already stopped
+    	if (m_state == STOPPED) { return; } // Instance already stopped
     	
         setState(INVALID);
         // Stop all the handlers
@@ -311,8 +317,7 @@
             System.arraycopy(m_pojoObjects, 0, newInstances, 0, m_pojoObjects.length);
             newInstances[m_pojoObjects.length] = o;
             m_pojoObjects = newInstances;
-        }
-        else {
+        } else {
             m_pojoObjects = new Object[] {o};
         }
     }
@@ -328,12 +333,14 @@
         }
 
         if (idx >= 0) {
-            if ((m_pojoObjects.length - 1) == 0) { m_pojoObjects = new Element[0]; }
-            else {
+            if ((m_pojoObjects.length - 1) == 0) { 
+            	m_pojoObjects = new Element[0]; 
+            } else {
                 Object[] newInstances = new Object[m_pojoObjects.length - 1];
                 System.arraycopy(m_pojoObjects, 0, newInstances, 0, idx);
                 if (idx < newInstances.length) {
-                    System.arraycopy(m_pojoObjects, idx + 1, newInstances, idx, newInstances.length - idx); }
+                    System.arraycopy(m_pojoObjects, idx + 1, newInstances, idx, newInstances.length - idx); 
+                }
                 m_pojoObjects = newInstances;
             }
         }
@@ -366,8 +373,7 @@
                 Constructor constructor = m_clazz.getConstructor(new Class[] {InstanceManager.class, BundleContext.class});
                 constructor.setAccessible(true);
                 instance = constructor.newInstance(new Object[] {this, m_context});
-            }
-            catch (NoSuchMethodException e) { }
+            } catch (NoSuchMethodException e) { instance = null; }
 
             // Create an instance if no instance are already created with <init>()BundleContext
             if (instance == null) {
@@ -452,10 +458,13 @@
         for (int i = 0; i < fields.length; i++) {
             if (m_fieldRegistration.get(fields[i]) == null) {
                 m_fieldRegistration.put(fields[i], new Handler[] {h});
-            }
-            else {
+            } else {
                 Handler[] list = (Handler[]) m_fieldRegistration.get(fields[i]);
-                for (int j = 0; j < list.length; j++) { if (list[j] == h) { return; } }
+                for (int j = 0; j < list.length; j++) { 
+                	if (list[j] == h) { 
+                		return;
+                	} 
+                }
                 Handler[] newList = new Handler[list.length + 1];
                 System.arraycopy(list, 0, newList, 0, list.length);
                 newList[list.length] = h;
@@ -472,8 +481,9 @@
      */
     public void unregister(Handler h, String[] fields) {
         for (int i = 0; i < fields.length; i++) {
-            if (m_fieldRegistration.get(fields[i]) == null) { break; }
-            else {
+            if (m_fieldRegistration.get(fields[i]) == null) { 
+            	break;
+            } else {
                 Handler[] list = (Handler[]) m_fieldRegistration.get(fields[i]);
                 int idx = -1;
                 for (int j = 0; j < list.length; j++) {
@@ -486,8 +496,7 @@
                 if (idx >= 0) {
                     if ((list.length - 1) == 0) {
                         list = new Handler[0];
-                    }
-                    else {
+                    } else {
                         Handler[] newList = new Handler[list.length - 1];
                         System.arraycopy(list, 0, newList, 0, idx);
                         if (idx < newList.length)             {
@@ -518,8 +527,7 @@
         if (idx >= 0) {
             if ((m_handlers.length - 1) == 0) {
                 m_handlers = new Handler[0];
-            }
-            else {
+            } else {
                 Handler[] newList = new Handler[m_handlers.length - 1];
                 System.arraycopy(m_handlers, 0, newList, 0, idx);
                 if (idx < newList.length)             {
@@ -595,7 +603,19 @@
         if (isValid && m_state == INVALID) { setState(VALID); }
     }
 
+	/**
+	 * @see org.apache.felix.ipojo.ComponentInstance#getInstanceName()
+	 */
 	public String getInstanceName() { return m_name; }
+
+	/**
+	 * @see org.apache.felix.ipojo.ComponentInstance#reconfigure(java.util.Dictionary)
+	 */
+	public void reconfigure(Dictionary configuration) {
+		for (int i = 0; i < m_handlers.length; i++) {
+	        m_handlers[i].reconfigure(configuration);
+	    }
+	}
 
 
     // ======================= end Handlers Management =====================

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ServiceContext.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ServiceContext.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ServiceContext.java Fri Mar  9 08:50:30 2007
@@ -25,30 +25,89 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
+/**
+ * A service context give the access the a service registry.
+ * All service interaction should use this service context.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
 public interface ServiceContext {
 	
+	/**
+	 * @param listener
+	 * @param filter
+	 * @throws InvalidSyntaxException
+	 */
 	void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException;
 	
+	/**
+	 * @param listener
+	 */
 	void addServiceListener(ServiceListener listener);
 	
+	/**
+	 * @param clazz
+	 * @param filter
+	 * @return
+	 * @throws InvalidSyntaxException
+	 */
 	ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
 	
+	/**
+	 * @param reference
+	 * @return
+	 */
 	Object getService(ServiceReference reference);
 	
+	/**
+	 * @param clazz
+	 * @return
+	 */
 	ServiceReference getServiceReference(String clazz);
 	
+	/**
+	 * @param clazz
+	 * @param filter
+	 * @return
+	 * @throws InvalidSyntaxException
+	 */
 	ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
 	
+	/**
+	 * @param clazzes
+	 * @param service
+	 * @param properties
+	 * @return
+	 */
 	ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties);
 	
+	/**
+	 * @param clazz
+	 * @param service
+	 * @param properties
+	 * @return
+	 */
 	ServiceRegistration registerService(String clazz, Object service, Dictionary properties);
 	
+	/**
+	 * @param listener
+	 */
 	void removeServiceListener(ServiceListener listener);
 	
+	/**
+	 * @param reference
+	 * @return
+	 */
 	boolean ungetService(ServiceReference reference);
 	
+	/**
+	 * @return the component instance who use this service context.
+	 */
 	ComponentInstance getComponentInstance();
 	
+	/**
+	 * Set the component instance using the service context.
+	 * @param ci
+	 */
 	void setComponentInstance(ComponentInstance ci);
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/UnacceptableConfiguration.java Fri Mar  9 08:50:30 2007
@@ -1,9 +1,19 @@
 package org.apache.felix.ipojo;
 
+/**
+ * UnacceptableConfiguration is throwed when a factory refuses to create an instance.  
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
 public class UnacceptableConfiguration extends Exception {
 
+	/**
+	 * 
+	 */
 	private static final long serialVersionUID = 2998931848886223965L;
 	
+	/**
+	 * @param message : message indicating the error.
+	 */
 	public UnacceptableConfiguration(String message) { super(message); }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/ComponentDescription.java Fri Mar  9 08:50:30 2007
@@ -75,8 +75,8 @@
      * @param pd : the property to add
      */
     public void addProperty(PropertyDescription pd) { 
-    	for(int i = 0; i < m_properties.length; i++) {
-    		if(m_properties[i].getName().equals(pd.getName())) { return; }
+    	for (int i = 0; i < m_properties.length; i++) {
+    		if (m_properties[i].getName().equals(pd.getName())) { return; }
     	}
     	
     	PropertyDescription[] newProps = new PropertyDescription[m_properties.length + 1];
@@ -95,10 +95,10 @@
      * @param serviceSpecification : the provided service to add (interface name)
      */
     public void addProvidedServiceSpecification(String serviceSpecification) { 
-            String[] newSs = new String[m_providedServiceSpecification.length + 1];
-            System.arraycopy(m_providedServiceSpecification, 0, newSs, 0, m_providedServiceSpecification.length);
-            newSs[m_providedServiceSpecification.length] = serviceSpecification;
-            m_providedServiceSpecification = newSs;
+        String[] newSs = new String[m_providedServiceSpecification.length + 1];
+        System.arraycopy(m_providedServiceSpecification, 0, newSs, 0, m_providedServiceSpecification.length);
+        newSs[m_providedServiceSpecification.length] = serviceSpecification;
+        m_providedServiceSpecification = newSs;
     }
     
     

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java Fri Mar  9 08:50:30 2007
@@ -57,8 +57,10 @@
 
     /**
      * Constructor.
-     * @param name : the name of the component (the class name).
-     * @param state : the state of the component.
+     * @param name : the name of the component instance.
+     * @param state : the state of the instance.
+     * @param className : implementation class name.
+     * @param bundleId : bundle id owning this instance.
      */
     public InstanceDescription(String name, String className, int state, long bundleId) {
         m_name = name;
@@ -106,10 +108,10 @@
             }
         }
             // The component Description is not in the array, add it
-            HandlerDescription[] newHd = new HandlerDescription[m_handlers.length + 1];
-            System.arraycopy(m_handlers, 0, newHd, 0, m_handlers.length);
-            newHd[m_handlers.length] = hd;
-            m_handlers = newHd;
+        HandlerDescription[] newHd = new HandlerDescription[m_handlers.length + 1];
+        System.arraycopy(m_handlers, 0, newHd, 0, m_handlers.length);
+        newHd[m_handlers.length] = hd;
+        m_handlers = newHd;
     }
 
     /**

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/PropertyDescription.java Fri Mar  9 08:50:30 2007
@@ -70,8 +70,11 @@
      * @see java.lang.Object#toString()
      */
     public String toString() {
-        if (m_value != null) { return getName() + " - " + getType() + " - " + getValue(); }
-        else { return getName() + " - " + getType() + " - REQUIRED"; }
+        if (m_value != null) { 
+        	return getName() + " - " + getType() + " - " + getValue(); 
+        } else { 
+        	return getName() + " - " + getType() + " - REQUIRED"; 
+        }
     }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurableProperty.java Fri Mar  9 08:50:30 2007
@@ -59,10 +59,12 @@
      */
     public ConfigurableProperty(String name, String field, String value, String type, ConfigurationHandler ch) {
         m_handler = ch;
-        if (name != null) { m_name = name; }
-        else { m_name = field; }
+        if (name != null) { 
+        	m_name = name; 
+        } else { 
+        	m_name = field; 
+        }
         m_field = field;
-
         if (value != null) { setValue(m_field, value, type); }
 
     }
@@ -173,12 +175,14 @@
             float[] fl = new float[values.length];
             for (int i = 0; i < values.length; i++) { fl[i] = new Float(values[i]).floatValue(); }
             m_value = fl;
-            return; }
+            return; 
+        }
         if (internalType.equals("double")) {
             double[] dl = new double[values.length];
             for (int i = 0; i < values.length; i++) { dl[i] = new Double(values[i]).doubleValue(); }
             m_value = dl;
-            return; }
+            return;
+        }
 
         // Else it is a neither a primitive type neither a String -> create the object by calling a constructor with a string in argument.
         try {

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/configuration/ConfigurationHandler.java Fri Mar  9 08:50:30 2007
@@ -29,17 +29,13 @@
 import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandler;
 import org.apache.felix.ipojo.metadata.Element;
 import org.apache.felix.ipojo.util.Logger;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 
 /**
  * Handler managing the Configuration Admin.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ConfigurationHandler extends Handler implements ManagedService {
+public class ConfigurationHandler extends Handler {
 
     /**
      * Reference on the instance manager.
@@ -61,14 +57,15 @@
      * Properties propagated at the last "updated".
      */
     private Dictionary m_propagated = new Properties();
-
+    
+    
     /**
-     * PID of the component.
+     * Properties to propage.
      */
-    private String m_pid;
+    private Dictionary m_toPropagate = new Properties();
 
     /**
-     * should the component provided ManagedService ?
+     * should the component propagate configuration ?
      */
     private boolean m_isConfigurable;
 
@@ -97,20 +94,28 @@
 
         // Check if the component is dynamically configurable
         m_isConfigurable = false;
-        if (confs[0].containsAttribute("configurable") && confs[0].getAttribute("configurable").equalsIgnoreCase("true")) { m_isConfigurable = true; }
+        if (confs[0].containsAttribute("configurable") && confs[0].getAttribute("configurable").equalsIgnoreCase("true")) { m_isConfigurable = true; m_toPropagate = configuration; }
 
         Element[] configurables = confs[0].getElements("Property");
 
         for (int i = 0; i < configurables.length; i++) {
             String fieldName = configurables[i].getAttribute("field");
             String name = null;
-            if (configurables[i].containsAttribute("name")) { name = configurables[i].getAttribute("name"); }
-            else { name = fieldName; }
+            if (configurables[i].containsAttribute("name")) { 
+            	name = configurables[i].getAttribute("name"); 
+            } else { 
+            	name = fieldName; 
+            }
             String value = null;
             if (configurables[i].containsAttribute("value")) { value = configurables[i].getAttribute("value"); }
 
-            if (name != null && configuration.get(name) != null && configuration.get(name) instanceof String) { value = (String) configuration.get(name); }
-            else { if (fieldName != null &&  configuration.get(fieldName) != null && configuration.get(fieldName) instanceof String) { value = (String) configuration.get(fieldName); } }
+            if (name != null && configuration.get(name) != null && configuration.get(name) instanceof String) { 
+            	value = (String) configuration.get(name); 
+            } else { 
+            	if (fieldName != null &&  configuration.get(fieldName) != null && configuration.get(fieldName) instanceof String) { 
+            		value = (String) configuration.get(fieldName); 
+            	} 
+            }
 
             // Detect the type of the property 
             Element manipulation = metadata.getElements("Manipulation")[0];
@@ -124,19 +129,15 @@
             
             ConfigurableProperty cp = new ConfigurableProperty(name, fieldName, value, type, this);
             
-            if (cp.getValue() != null) { cd.addProperty(new PropertyDescription(name, type, cp.getValue().toString())); }
-            else { cd.addProperty(new PropertyDescription(name, type, null)); }
+            if (cp.getValue() != null) { 
+            	cd.addProperty(new PropertyDescription(name, type, cp.getValue().toString())); 
+            } else { 
+            	cd.addProperty(new PropertyDescription(name, type, null)); 
+            }
 
             addProperty(cp);
         }
 
-        // Get the PID in the configuration name :
-        if (configuration.get("name") != null) { m_pid = (String) configuration.get("name"); }
-        else { m_pid = metadata.getAttribute("className"); }
-
-        // Get the provided service handler :
-        m_providedServiceHandler = (ProvidedServiceHandler) m_manager.getHandler(ProvidedServiceHandler.class.getName());
-
         if (configurables.length > 0) {
             String[] fields = new String[m_configurableProperties.length];
             for (int k = 0; k < m_configurableProperties.length; k++) {
@@ -145,42 +146,36 @@
                 // Check if the instance configuration contains value for the current property :
                 String name = m_configurableProperties[k].getName();
                 String fieldName = m_configurableProperties[k].getField();
-                if (name != null && configuration.get(name) != null && !(configuration.get(name) instanceof String)) { m_configurableProperties[k].setValue(configuration.get(name)); }
-                else { if (fieldName != null &&  configuration.get(fieldName) != null && !(configuration.get(fieldName) instanceof String)) { m_configurableProperties[k].setValue(configuration.get(fieldName)); } }
+                if (name != null && configuration.get(name) != null && !(configuration.get(name) instanceof String)) { 
+                	m_configurableProperties[k].setValue(configuration.get(name)); 
+                } else { 
+                	if (fieldName != null &&  configuration.get(fieldName) != null && !(configuration.get(fieldName) instanceof String)) { 
+                		m_configurableProperties[k].setValue(configuration.get(fieldName)); 
+                	} 
+                }
             }
             m_manager.register(this, fields);
         }
-        else { return; }
     }
 
     /**
      * @see org.apache.felix.ipojo.Handler#stop()
      */
-    public void stop() {
-        // Unregister the service
-        if (m_isConfigurable && m_sr != null) {
-            m_manager.getFactory().getLogger().log(Logger.INFO, "[" + m_manager.getClassName() + "] Unregister Managed Service");
-            m_sr.unregister();
-            m_sr = null;
-        }
-
-    }
+    public void stop() {    }
 
     /**
      * @see org.apache.felix.ipojo.Handler#start()
      */
     public void start() {
-        // Unregister the service if already registred (it should not happen )
-        if (m_isConfigurable && m_sr != null) { m_sr.unregister(); }
+        // Get the provided service handler :
+        m_providedServiceHandler = (ProvidedServiceHandler) m_manager.getHandler(ProvidedServiceHandler.class.getName());
 
-        // Register the ManagedService
+        // Propagation
         if (m_isConfigurable) {
-            BundleContext bc = m_manager.getContext();
-            Dictionary properties = new Properties();
-            properties.put(Constants.SERVICE_PID, m_pid);
-
-            m_manager.getFactory().getLogger().log(Logger.INFO, "[" + m_manager.getClassName() + "] Register Managed Service");
-            m_sr = bc.registerService(ManagedService.class.getName(), this, properties);
+        	for (int i = 0; i < m_configurableProperties.length; i++) {
+        		m_toPropagate.put(m_configurableProperties[i].getName(), m_configurableProperties[i].getValue());
+        	}
+        	reconfigure(m_toPropagate);
         }
     }
 
@@ -229,47 +224,6 @@
     }
 
     /**
-     * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
-     */
-    public void updated(Dictionary np) throws ConfigurationException {
-        Properties toPropagate = new Properties();
-        if (np != null) {
-            Enumeration keysEnumeration = np.keys();
-            while (keysEnumeration.hasMoreElements()) {
-                String name = (String) keysEnumeration.nextElement();
-                Object value = np.get(name);
-                boolean find = false;
-                // Check if the field is a configurable property
-                for (int i = 0; !find && i < m_configurableProperties.length; i++) {
-                    if (m_configurableProperties[i].getName().equals(name)) {
-                        // Check if the value has change
-                        if (m_configurableProperties[i].getValue() == null || !m_configurableProperties[i].getValue().equals(value)) {
-                            m_manager.setterCallback(m_configurableProperties[i].getField(), value); // says that the value has change
-                        }
-                        find = true;
-                        // Else do nothing
-                    }
-                }
-                if (!find) {
-                    //The property is not a configurable property
-                    m_manager.getFactory().getLogger().log(Logger.INFO, "[" + m_manager.getClassName() + "] The property " + name + " will be propagated to service registrations");
-                    toPropagate.put(name, value);
-                }
-            }
-        }
-        else { m_manager.getFactory().getLogger().log(Logger.WARNING, "[" + m_manager.getClassName() + "] The pushed configuration is null for " + m_pid); }
-
-        // Propagation of the properties to service registrations :
-        if (m_providedServiceHandler != null && !toPropagate.isEmpty()) {
-            m_manager.getFactory().getLogger().log(Logger.INFO, "[" + m_manager.getClassName() + "] Properties will be propagated");
-            m_providedServiceHandler.removeProperties(m_propagated);
-            m_providedServiceHandler.addProperties(toPropagate);
-            m_propagated = toPropagate;
-        }
-
-    }
-
-    /**
      * Add the given property metadata to the property metadata list.
      * @param p : property metdata to add
      */
@@ -283,8 +237,7 @@
             System.arraycopy(m_configurableProperties, 0, newProp, 0, m_configurableProperties.length);
             newProp[m_configurableProperties.length] = p;
             m_configurableProperties = newProp;
-        }
-        else {
+        } else {
             m_configurableProperties = new ConfigurableProperty[] {p};
         }
     }
@@ -299,6 +252,45 @@
             if (m_configurableProperties[i].getName().equals(name)) { return true; }
         }
         return false;
+    }
+    
+    /**
+     * @see org.apache.felix.ipojo.Handler#reconfigure(java.util.Dictionary)
+     */
+    public void reconfigure(Dictionary np) {
+    	Properties toPropagate = new Properties();
+        Enumeration keysEnumeration = np.keys();
+        while (keysEnumeration.hasMoreElements()) {
+            String name = (String) keysEnumeration.nextElement();
+            Object value = np.get(name);
+            boolean find = false;
+            // Check if the field is a configurable property
+            for (int i = 0; !find && i < m_configurableProperties.length; i++) {
+                if (m_configurableProperties[i].getName().equals(name)) {
+                    // Check if the value has change
+                    if (m_configurableProperties[i].getValue() == null || !m_configurableProperties[i].getValue().equals(value)) {
+                        m_manager.setterCallback(m_configurableProperties[i].getField(), value); // says that the value has changed
+                    }
+                    find = true;
+                    // Else do nothing
+                }
+            }
+            if (!find) {
+                //The property is not a configurable property
+                toPropagate.put(name, value);
+            }
+        }
+
+        // Propagation of the properties to service registrations :
+        if (m_providedServiceHandler != null && !toPropagate.isEmpty()) {
+            m_providedServiceHandler.removeProperties(m_propagated);
+            
+            // Remove to name props
+            toPropagate.remove("name");
+            
+            m_providedServiceHandler.addProperties(toPropagate);
+            m_propagated = toPropagate;
+        }
     }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java Fri Mar  9 08:50:30 2007
@@ -123,7 +123,10 @@
     /**
      * Dependency contructor. After the creation the dependency is not started.
      * @param dh : the dependency handler managing this dependency
-     * @param dm : the depednency metadata
+     * @param field : field of the dependency
+     * @param spec : required specification
+     * @param filter : LDAP filter of the dependency
+     * @param isOptional : is the dependency an optional dependency ?
      */
     public Dependency(DependencyHandler dh, String field, String spec, String filter, boolean isOptional) {
         m_handler = dh;
@@ -174,12 +177,14 @@
             System.arraycopy(m_callbacks, 0, newCallbacks, 0, m_callbacks.length);
             newCallbacks[m_callbacks.length] = cb;
             m_callbacks = newCallbacks;
-        }
-        else {
+        } else {
             m_callbacks = new DependencyCallback[] {cb};
         }
     }
     
+    /**
+     * @return the filter attached to the dependency.
+     */
     public String getFilter() { return m_strFilter; }
 
     /**
@@ -224,9 +229,9 @@
             if (!m_change) {
                 if (!m_isMultiple) {
                     if (m_services.length > 0) {
-                        return m_services[0]; }
-                }
-                else {
+                        return m_services[0]; 
+                    }
+                } else {
                     return m_services;
                 }
             }
@@ -266,18 +271,18 @@
              //       m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Nullable object created for " + getMetadata().getServiceSpecification() + " -> " + instance);
                     return instance;
                 }
-            }
-            else { // Multiple dependency
+            } else { // Multiple dependency
                 return m_services;
             }
         } catch (Exception e) {
             // There is a problem in the dependency resolving (like in stopping method)
             if (!m_isMultiple) {
                 m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Return null, an exception was throwed in the get method", e);
-                return null; }
-            else {
+                return null; 
+            } else {
                 m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Return an empty array, an exception was throwed in the get method", e);
-                return Array.newInstance(m_clazz, 0); }
+                return Array.newInstance(m_clazz, 0); 
+            }
         }
     }
 
@@ -298,19 +303,23 @@
 
             // If a service arrives
             if (event.getType() == ServiceEvent.REGISTERED) {
-                if (m_filter.match(event.getServiceReference())) { arrivalManagement(event.getServiceReference()); return; }
-                else { return; }
+                if (m_filter.match(event.getServiceReference())) { 
+                	arrivalManagement(event.getServiceReference());
+                }
+                return;
             }
-
             // If a service is modified
             if (event.getType() == ServiceEvent.MODIFIED) {
                 if (m_filter.match(event.getServiceReference())) {
                     m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] A service with a filter matching is arrived -> " + event.getServiceReference().getBundle());
-                    if (!containsSR(event.getServiceReference())) { arrivalManagement(event.getServiceReference()); }
-                }
-                else {
+                    if (!containsSR(event.getServiceReference())) { 
+                    	arrivalManagement(event.getServiceReference()); 
+                    }
+                } else {
                     m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] A service with a filter matching has gone -> " + event.getServiceReference().getBundle());
-                    if (containsSR(event.getServiceReference())) { departureManagement(event.getServiceReference()); }
+                    if (containsSR(event.getServiceReference())) { 
+                    	departureManagement(event.getServiceReference()); 
+                    }
                 }
                 return;
             }
@@ -569,8 +578,7 @@
         String filter = "";
         if (!m_strFilter.equals("")) {
             filter = "(&" + classnamefilter + m_strFilter + ")";
-        }
-        else {
+        } else {
             filter = classnamefilter;
         }
 
@@ -596,8 +604,7 @@
             m_filter = m_handler.getInstanceManager().getContext().createFilter(filter); // Store the filter
             m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Create a filter from : " + filter);
             m_change = true;
-        }
-        catch (InvalidSyntaxException e1) {
+        } catch (InvalidSyntaxException e1) {
             m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] A filter is malformed : " + filter);
             e1.printStackTrace();
         }
@@ -626,7 +633,7 @@
      * @return the state of the dependency (1 : valid, 2 : invalid)
      */
     public int getState() {
-        return ( m_isOptional ) ? 1 : m_state;
+        return (m_isOptional) ? 1 : m_state;
     }
 
     /**
@@ -653,8 +660,7 @@
             System.arraycopy(m_ref, 0, newSR, 0, m_ref.length);
             newSR[m_ref.length] = r;
             m_ref = newSR;
-        }
-        else {
+        } else {
             m_ref = new ServiceReference[] {r};
         }
     }
@@ -695,9 +701,7 @@
             // If this is the module, then point to empty list.
             if ((m_ref.length - 1) == 0) {
                 m_ref = new ServiceReference[0];
-            }
-            // Otherwise, we need to do some array copying.
-            else {
+            } else { // Otherwise, we need to do some array copying.
                 ServiceReference[] newSR = new ServiceReference[m_ref.length - 1];
                 System.arraycopy(m_ref, 0, newSR, 0, idx);
                 if (idx < newSR.length)             {

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java Fri Mar  9 08:50:30 2007
@@ -53,12 +53,12 @@
     private String m_callback;
     
     /**
-     * Is the callback a static callback
+     * Is the callback a static callback.
      */
     private boolean m_isStatic;
     
     /**
-     * The instance manager
+     * The instance manager.
      */
     private InstanceManager m_manager;
 
@@ -92,8 +92,9 @@
     	Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {});
     	method.setAccessible(true);
     	
-        if (m_isStatic) { method.invoke(null, new Object[] {}); }
-        else {
+        if (m_isStatic) { 
+        	method.invoke(null, new Object[] {}); 
+        } else {
             // Two cases :
             // - if instances already exists : call on each instances
             // - if no instance exists : create an instance
@@ -120,8 +121,9 @@
     	Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {ServiceReference.class});
     	method.setAccessible(true);
     	
-        if (m_isStatic) { method.invoke(null, new Object[] {ref}); }
-        else {
+        if (m_isStatic) { 
+        	method.invoke(null, new Object[] {ref}); 
+        } else {
             // Two cases :
             // - if instances already exists : call on each instances
             // - if no instance exists : create an instance
@@ -148,8 +150,9 @@
     	Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {Object.class});
     	method.setAccessible(true);
     	
-        if (m_isStatic) { method.invoke(null, new Object[] {o}); }
-        else {
+        if (m_isStatic) { 
+        	method.invoke(null, new Object[] {o}); 
+        } else {
             // Two cases :
             // - if instances already exists : call on each instances
             // - if no instance exists : create an instance

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java Fri Mar  9 08:50:30 2007
@@ -71,8 +71,7 @@
             System.arraycopy(m_dependencies, 0, newDep, 0, m_dependencies.length);
             newDep[m_dependencies.length] = dep;
             m_dependencies = newDep;
-        }
-        else {
+        } else {
             m_dependencies = new Dependency[] {dep};
         }
     }
@@ -92,8 +91,7 @@
             System.arraycopy(m_nullableClasses, 0, newClass, 0, m_nullableClasses.length);
             newClass[m_nullableClasses.length] = clazz;
             m_nullableClasses = newClass;
-        }
-        else {
+        } else {
             m_nullableClasses = new Class[] {clazz};
         }
     }
@@ -179,8 +177,7 @@
                 m_manager.getFactory().getLogger().log(Logger.WARNING, "[DependencyHandler on " + m_manager.getClassName() + "] The field type [" + type + "] and the needed service interface [" + dep.getSpecification() + "] are not the same");
                 dep.setSpecification(type);
             }
-        }
-        else {
+        } else {
             m_manager.getFactory().getLogger().log(Logger.WARNING, "[DependencyHandler on " + m_manager.getClassName() + "] The declared dependency " + dep.getField() + "  does not exist in the code");
         }
         return true;
@@ -210,16 +207,22 @@
             Dependency dep = new Dependency(this, field, serviceSpecification, filter, optional);
             // Check the dependency :
             Element manipulation = componentMetadata.getElements("Manipulation")[0];
-            if (checkDependency(dep, manipulation)) { addDependency(dep); }
-            else { m_manager.getFactory().getLogger().log(Logger.ERROR, "[DependencyHandler on " + m_manager.getClassName() + "] The dependency on " + dep.getField() + " is not valid"); }
+            if (checkDependency(dep, manipulation)) { 
+            	addDependency(dep); 
+            } else { 
+            	m_manager.getFactory().getLogger().log(Logger.ERROR, "[DependencyHandler on " + m_manager.getClassName() + "] The dependency on " + dep.getField() + " is not valid");
+            }
 
             // Look for dependency callback :
             for (int j = 0; j < (deps[i].getElements("Callback", "")).length; j++) {
                 String method = deps[i].getElements("Callback", "")[j].getAttribute("method");
                 String type = deps[i].getElements("Callback", "")[j].getAttribute("type");
                 int methodType = 0;
-                if (type.equals("bind")) { methodType = DependencyCallback.BIND; }
-                else { methodType = DependencyCallback.UNBIND; }
+                if (type.equals("bind")) { 
+                	methodType = DependencyCallback.BIND; 
+                } else { 
+                	methodType = DependencyCallback.UNBIND;
+                }
                 boolean isStatic = false;
                 if (deps[i].getElements("Callback", "")[j].containsAttribute("isStatic") && deps[i].getElements("Callback", "")[j].getAttribute("isStatic").equals("true")) { isStatic = true; }
                 DependencyCallback dc = new DependencyCallback(dep, method, methodType, isStatic);
@@ -245,7 +248,7 @@
         
         //String[] segment = dep.getMetadata().getServiceSpecification().split("[.]");
         //String className = "org/apache/felix/ipojo/" + segment[segment.length - 1] + "Nullable";
-		String className = dep.getSpecification()+"Nullable";
+		String className = dep.getSpecification() + "Nullable";
         String resource = dep.getSpecification().replace('.', '/') + ".class";
         URL url =  m_manager.getContext().getBundle().getResource(resource);
 
@@ -254,8 +257,9 @@
             Class c = null;
             try {
             	c = m_manager.getFactory().defineClass(className, b, null);
+            } catch (Exception e) { 
+            	System.err.println("Cannot define !!!");
             }
-            catch(Exception e) { System.err.println("Cannot define !!!");}
             addNullableClass(c); 
             m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Nullable class created for " + dep.getSpecification());
         } catch (Exception e2) {
@@ -357,6 +361,9 @@
         return valide;
     }
     
+    /**
+     * @see org.apache.felix.ipojo.Handler#getDescription()
+     */
     public HandlerDescription getDescription() {
         DependencyHandlerDescription dhd = new DependencyHandlerDescription(isValid());
         for (int j = 0; j < getDependencies().length; j++) {

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/MethodSignatureVisitor.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/MethodSignatureVisitor.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/MethodSignatureVisitor.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/MethodSignatureVisitor.java Fri Mar  9 08:50:30 2007
@@ -78,8 +78,7 @@
             System.arraycopy(list, 0, newList, 0, list.length);
             newList[list.length] = method;
             return newList;
-        }
-        else {
+        } else {
             list = new MethodSignature[] {method};
             return list;
         }
@@ -88,36 +87,61 @@
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visit(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
+     * @param arg0 : version
+     * @param arg1 : access
+     * @param arg2 : name
+     * @param arg3 : signature
+     * @param arg4 : superName
+     * @param arg5 : interfaces 
      */
     public void visit(int arg0, int arg1, String arg2, String arg3, String arg4, String[] arg5) { }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitSource(java.lang.String, java.lang.String)
+     * @param arg0 : source
+     * @param arg1 : debug
      */
     public void visitSource(String arg0, String arg1) { }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitOuterClass(java.lang.String, java.lang.String, java.lang.String)
+     * @param arg0 : owner
+     * @param arg1 : name
+     * @param arg2 : desc
      */
     public void visitOuterClass(String arg0, String arg1, String arg2) { }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
+     * @param arg0 : desc
+     * @param arg1 : visible
+     * @return annotationvisitor
      */
     public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) { return null; }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitAttribute(org.objectweb.asm.Attribute)
+     * @param arg0 : Attribute
      */
     public void visitAttribute(Attribute arg0) { }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int)
+     * @param arg0 : name
+     * @param arg1 : outerclass
+     * @param arg2 : innerclass
+     * @param arg3 : access
      */
     public void visitInnerClass(String arg0, String arg1, String arg2, int arg3) { }
 
     /**
      * @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
+     * @param arg0 : access
+     * @param arg1 : name
+     * @param arg2 : desc
+     * @param arg3 : signature
+     * @param arg4 : value
+     * @return the field visitor
      */
     public FieldVisitor visitField(int arg0, String arg1, String arg2, String arg3, Object arg4) { return null; }
 

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/NullableObjectWriter.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/NullableObjectWriter.java?view=diff&rev=516458&r1=516457&r2=516458
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/NullableObjectWriter.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/nullable/NullableObjectWriter.java Fri Mar  9 08:50:30 2007
@@ -57,7 +57,7 @@
 
             //String[] segment = contractName.split("[.]");
             //String className = "org/apache/felix/ipojo/" + segment[segment.length - 1] + "Nullable";
-            String className=contractName.replace('.', '/')+"Nullable";
+            String className = contractName.replace('.', '/') + "Nullable";
 
 
             // Create the class
@@ -65,12 +65,12 @@
                     "java/lang/Object", new String[]{contractName.replace('.', '/'), "org/apache/felix/ipojo/Nullable"});
 
             // Inject a constructor <INIT>()V
-                MethodVisitor cst = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
-                cst.visitVarInsn(ALOAD, 0);
-                cst.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
-                cst.visitInsn(RETURN);
-                cst.visitMaxs(0, 0);
-                cst.visitEnd();
+            MethodVisitor cst = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+            cst.visitVarInsn(ALOAD, 0);
+            cst.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
+            cst.visitInsn(RETURN);
+            cst.visitMaxs(0, 0);
+            cst.visitEnd();
 
             // Methods Generation :
             MethodSignature[] methods = msv.getMethods();
@@ -87,7 +87,7 @@
                 Type returnType = Type.getReturnType(desc);
                     // TODO : manage the other type primitive for Nullable
                     // Primitive type :
-                    switch (returnType.getSort()) {
+                switch (returnType.getSort()) {
                     case Type.BOOLEAN:
                     case Type.INT:
                     case Type.BYTE:
@@ -117,7 +117,7 @@
                     default :
                         System.err.println("Type not yet managed : " + returnType);
                     	break;
-                    }
+                }
                 mv.visitMaxs(0, 0);
                 mv.visitEnd();
             }