felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r469182 [2/6] - in /incubator/felix/trunk: ipojo.metadata/ ipojo.metadata/src/main/java/org/apache/felix/ipojo/metadata/ ipojo.plugin/ ipojo.plugin/src/main/java/org/apache/felix/ipojo/manipulation/ ipojo.plugin/src/main/java/org/apache/fel...
Date Mon, 30 Oct 2006 16:36:06 GMT
Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManager.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManager.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManager.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManager.java Mon Oct 30 08:36:04 2006
@@ -1,496 +1,70 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
-
-import org.apache.felix.ipojo.metadata.Element;
-import org.osgi.framework.BundleContext;
-
 /**
- * The component manager class manage one "version" of a component.
- * It manages component lifecycle, component instance creation and handlers.
+ * The component manager class manages one instance of a component type.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ComponentManager {
-
-	// STATIC PART
+public interface ComponentManager {
 
-	/**
+    /**
      * Component State : INVALID.
      * The component is invalid when it start or when a component dependency is unvalid.
      */
-    public static final int INVALID = 1;
+    int INVALID = 1;
 
     /**
      * Component State : VALID.
      * The component is resolved when it is running and all its component dependencies are valid.
      */
-    public static final int VALID = 2;
+    int VALID = 2;
 
-    // END STATIC PART
+    /**
+     * Start the component manager.
+     */
+    void start();
 
-	/**
-	 * Parent factory (ComponentManagerFactory).
-	 */
-	private ComponentManagerFactory m_factory;
-
-	/**
-	 * Attached metadata of the managed component.
-	 */
-	private ComponentMetadata m_metadata;
-
-	/**
-	 * The context of the component.
-	 */
-	private BundleContext m_context;
-
-	/**
-	 * Handler list.
-	 */
-	private Handler[] m_handlers = new Handler[0];
-
-	/**
-	 * Component state (STOPPED at the beginning).
-	 */
-	private int m_state = INVALID;
-
-	// Fields use for the manipulation, the loading of the class and for the instance creation
-
-	/**
-	 * Manipulatd clazz.
-	 */
-	private Class m_clazz;
-
-	/**
-	 * Instances of the components.
-	 */
-	private Object[] m_instances = new Object[0];
+    /**
+     * Stop the component manager.
+     */
+    void stop();
+
+    /**
+     * @return the actual state of the component.
+     */
+    int getState();
 
-    // Constructor
     /**
-     * Construct a new Component Manager.
-     * @param factory : the factory managing the component manager
+     * @return the component type information.
      */
-    public ComponentManager(ComponentManagerFactory factory) {
-    	m_factory = factory;
-    	m_context = factory.getBundleContext();
-    	Activator.getLogger().log(Level.INFO, "[Bundle " + m_context.getBundle().getBundleId() + "] Create a component manager from the factory " + m_factory);
-    }
-
-	/**
-	 * Configure the component manager.
-	 * Stop the existings handler, clear the handler list, change the metadata, recreate the handlers
-	 * @param cm
-	 */
-	public void configure(Element cm) {
-		Activator.getLogger().log(Level.INFO, "[Bundle " + m_context.getBundle().getBundleId() + "] Configure the component manager " + cm.getAttribute("className"));
-
-		// Stop all previous registred handler
-		if (m_handlers.length != 0) { stop(); }
-
-		// Clear the handler list
-		m_handlers = new Handler[0];
-
-		// Change the metadata
-		m_metadata = new ComponentMetadata(cm);
-
-		// Create the standard handlers and add these handlers to the list
-		for (int i = 0; i < IPojoConfiguration.INTERNAL_HANDLERS.length; i++) {
-			// Create a new instance
-			try {
-				Handler h = (Handler)IPojoConfiguration.INTERNAL_HANDLERS[i].newInstance();
-				h.configure(this, cm);
-			} catch (InstantiationException e) {
-				Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
-			} catch (IllegalAccessException e) {
-				Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
-			}
-		}
-
-		// Look for namespaces
-		for (int i = 0; i < cm.getNamespaces().length; i++) {
-			if (!cm.getNamespaces()[i].equals("")) {
-				Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Look for class for the namespace : " + cm.getNamespaces()[i]);
-				// It is not an internal handler, try to load it
-				try {
-					Class c = m_context.getBundle().loadClass(cm.getNamespaces()[i]);
-					Handler h = (Handler) c.newInstance();
-					h.configure(this, cm);
-				} catch (ClassNotFoundException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
-				} catch (InstantiationException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
-				} catch (IllegalAccessException e) {
-					Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
-				}
-
-			}
-		}
-	}
-
-	/**
-	 * @return the component metadata.
-	 */
-	public ComponentMetadata getComponentMetatada() { return m_metadata; }
-
-	/**
-	 * @return the list of the registred handlers.
-	 */
-	public Handler[] getRegistredHandlers() { return m_handlers; }
-
-	/**
-	 * Return a specified handler.
-	 * @param name : class name of the handler to find
-	 * @return : the handler, or null if not found
-	 */
-	public Handler getHandler(String name) {
-		for (int i = 0; i < m_handlers.length; i++) {
-			if (m_handlers[i].getClass().getName().equalsIgnoreCase(name)) { return m_handlers[i]; }
-		}
-		return null;
-	}
-
-	// ===================== Lifecycle management =====================
-
-	/**
-	 * Start the component manager.
-	 */
-	public void start() {
-		// Start all the handlers
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Start the component manager with " + m_handlers.length + " handlers");
-
-		// The new state of the component is UNRESOLVED
-		m_state = INVALID;
-
-		for (int i = 0; i < m_handlers.length; i++) {
-			m_handlers[i].start();
-		}
-
-		// Defines the state of the component :
-		check();
-	}
-
-	/**
-	 * Stop the component manager.
-	 */
-	public void stop() {
-		setState(INVALID);
-		// Stop all the handlers
-		for (int i = m_handlers.length - 1; i > -1; i--) {
-			m_handlers[i].stop();
-		}
-		m_instances = new Object[0];
-	}
-
-	/**
-	 * Set the state of the component.
-	 * if the state changed call the stateChanged(int) method on the handlers
-	 */
-	public void setState(int state) {
-		if (m_state != state) {
-
-			// Log the state change
-			if (state == INVALID) { Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component " + m_metadata.getClassName() + " State -> UNRESOLVED"); }
-			if (state == VALID) { Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component " + m_metadata.getClassName() + " State -> VALID"); }
-
-			// The state changed call the handler stateChange method
-			m_state = state;
-			for (int i = m_handlers.length - 1; i > -1; i--) {
-				m_handlers[i].stateChanged(state);
-			}
-		}
-	}
-
-	/**
-	 * @return the actual state of the component
-	 */
-	public int getState() {
-		return m_state;
-	}
-
-	// ===================== end Lifecycle management =====================
-
-	// ================== Class & Instance management ===================
-
-	/**
-	 * @return the factory of the component
-	 */
-	public ComponentManagerFactory getFactory() { return m_factory; }
-
-	/**
-	 * Load the manipulated class.
-	 */
-	private void load() {
-        try {
-        	m_clazz = m_factory.loadClass(m_metadata.getClassName());
-        } catch (ClassNotFoundException  e) {
-            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Class not found during the loading phase : " + e.getMessage());
-            return;
-        }
-	}
-
-	/**
-	 * @return true if the class is loaded
-	 */
-	private boolean isLoaded() {
-		return (m_clazz != null);
-	}
-
-	private void addInstance(Object o) {
-        for (int i = 0; (m_instances != null) && (i < m_instances.length); i++) {
-            if (m_instances[i] == o) { return; }
-        }
-
-        if (m_instances.length > 0) {
-            Object[] newInstances = new Object[m_instances.length + 1];
-            System.arraycopy(m_instances, 0, newInstances, 0, m_instances.length);
-            newInstances[m_instances.length] = o;
-            m_instances = newInstances;
-        }
-        else {
-        	m_instances = new Object[] {o};
-        }
-	}
-
-	private void removeInstance(Object o) {
-		int idx = -1;
-        for (int i = 0; i < m_instances.length; i++) {
-            if (m_instances[i] == o) { idx = i; break; }
-        }
-
-        if (idx >= 0) {
-            if ((m_instances.length - 1) == 0) { m_instances = new Element[0]; }
-            else {
-                Object[] newInstances = new Object[m_instances.length - 1];
-                System.arraycopy(m_instances, 0, newInstances, 0, idx);
-                if (idx < newInstances.length) {
-                    System.arraycopy(m_instances, idx + 1, newInstances, idx, newInstances.length - idx); }
-                m_instances = newInstances;
-            }
-        }
-	}
-
-	/**
-	 * @return the created instance of the component.
-	 */
-	public Object[] getInstances() { return m_instances; }
-
-	/**
-	 * Delete the created instance (remove it from the list, to allow the garbage collector to eat the instance).
-	 * @param o : the instance to delete
-	 */
-	public void deleteInstance(Object o) { removeInstance(o); }
-
-	/**
-	 * Create an instance of the component.
-	 * This method need to be called one time only for singleton provided service
-	 * @return a new instance
-	 */
-	public Object createInstance() {
-
-		if (!isLoaded()) { load(); }
-		Object instance = null;
-		try {
-			Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Try to find the constructor");
-
-			// Try to find if there is a constructor with a bundle context as parameter :
-			try {
-				Constructor constructor = m_clazz.getConstructor(new Class[] {ComponentManager.class, BundleContext.class});
-				constructor.setAccessible(true);
-				instance = constructor.newInstance(new Object[] {this, m_factory.getBundleContext()});
-			}
-			catch (NoSuchMethodException e) {
-				Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> No constructor with a bundle context");
-			}
-
-			// Create an instance if no instance are already created with <init>()BundleContext
-			Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Try to create the object with an empty constructor");
-			if (instance == null) {
-				Constructor constructor = m_clazz.getConstructor(new Class[] {ComponentManager.class});
-				constructor.setAccessible(true);
-				instance = constructor.newInstance(new Object[] {this});
-				}
-
-		} catch (InstantiationException e) {
-			Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance cannot be instancied : " + e.getMessage());
-			e.printStackTrace();
-		} catch (IllegalAccessException e) {
-			Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance is not accessible : " + e.getMessage());
-			e.printStackTrace();
-		} catch (SecurityException e) {
-			Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance is not accessible (security reason) : " + e.getMessage());
-			e.printStackTrace();
-		} catch (InvocationTargetException e) {
-			Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> Cannot invoke the constructor method (illegal target) : " + e.getMessage());
-			e.printStackTrace();
-		} catch (NoSuchMethodException e) {
-			Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage());
-			e.printStackTrace();
-		}
-
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Return the instance " + instance);
-
-		// Register the new instance
-		addInstance(instance);
-		return instance;
-	}
-
-	/**
-	 * @return the instance of the component to use for singleton component
-	 */
-	public Object getInstance() {
-		if (m_instances.length == 0) { createInstance(); }
-		return m_instances[0];
-	}
-
-	/**
-	 * @return the manipulated class
-	 */
-	public Class getClazz() {
-		if (!isLoaded()) { load(); }
-		return m_clazz;
-	}
-
-	//	================== end Class & Instance management ================
-
-	//  ======================== Handlers Management ======================
-
-	/**
-     * Register the given handler to the current component manager.
-	 * @param h : the handler to register
-	 */
-	public void register(Handler h) {
-        for (int i = 0; (m_handlers != null) && (i < m_handlers.length); i++) {
-            if (m_handlers[i] == h) {
-                return;
-            }
-        }
-
-        if (m_handlers != null) {
-            Handler[] newList = new Handler[m_handlers.length + 1];
-            System.arraycopy(m_handlers, 0, newList, 0, m_handlers.length);
-            newList[m_handlers.length] = h;
-            m_handlers = newList;
-        }
-	}
-
-	/**
-     * Unregister the given handler.
-	 * @param h : the handler to unregiter
-	 */
-	public void unregister(Handler h) {
-        int idx = -1;
-        for (int i = 0; i < m_handlers.length; i++) {
-            if (m_handlers[i] == h) {
-                idx = i;
-                break;
-            }
-        }
-
-        if (idx >= 0) {
-            if ((m_handlers.length - 1) == 0) {
-                m_handlers = new Handler[0];
-            }
-            else {
-                Handler[] newList = new Handler[m_handlers.length - 1];
-                System.arraycopy(m_handlers, 0, newList, 0, idx);
-                if (idx < newList.length)             {
-                    System.arraycopy(
-                            m_handlers, idx + 1, newList, idx, newList.length - idx);
-                }
-                m_handlers = newList;
-            }
-        }
-	}
-
-	/**
-	 * This method is called by the manipulated class each time that a GETFIELD instruction is found.
-	 * The method ask to each handler which value need to be returned.
-	 * @param fieldName : the field name on which the GETFIELD instruction is called
-	 * @param initialValue : the value of the field in the code
-	 * @return the value decided by the last asked handler (throw a warining if two fields decide two different values)
-	 */
-	public Object getterCallback(String fieldName, Object initialValue) {
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Call the getterCallbackMethod on " + fieldName +  " with " + initialValue);
-		Object result = null;
-		for (int i = 0; i < m_handlers.length; i++) {
-			Object handlerResult = m_handlers[i].getterCallback(fieldName, initialValue);
-			if (handlerResult != initialValue) { result = handlerResult; }
-		}
-
-		if (result != null) {
-			Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] getterCallbackMethod return for " + fieldName +  " -> " + result);
-			return result;
-		} else {
-			Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] getterCallbackMethod return for " + fieldName +  " -> " + initialValue);
-			return initialValue;
-		}
-	}
-
-	/**
-	 * This method is called by the manipulated class each time that a PUTFILED instruction is found.
-	 * the method send to each handler the new value.
-	 * @param fieldName : the field name on which the PUTFIELD instruction is called
-	 * @param objectValue : the value of the field
-	 */
-	public void setterCallback(String fieldName, Object objectValue) {
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Call the setterCallbackMethod on " + fieldName +  " with " + objectValue);
-
-		for (int i = 0; i < m_handlers.length; i++) {
-			m_handlers[i].setterCallback(fieldName, objectValue);
-		}
-	}
-
-	/**
-	 * @return the context of the component.
-	 */
-	public BundleContext getContext() { return m_context; }
-
-	/**
-	 * Check the state of all handlers.
-	 */
-	public void check() {
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Check the component state");
-		boolean isValid = true;
-		for (int i = 0; i < m_handlers.length; i++) {
-			boolean b = m_handlers[i].isValid();
-			Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Validity of the handler : " + m_handlers[i] + " = " + b);
-			isValid = isValid && b;
-		}
-
-		// Update the component state if necessary
-		if (!isValid && m_state == VALID) {
-			// Need to update the state to UNRESOLVED
-			setState(INVALID);
-			m_instances = new Object[0];
-			return;
-		}
-		if (isValid && m_state == INVALID) {
-			setState(VALID);
-			if (m_metadata.isImmediate() && m_instances.length == 0) { createInstance(); }
-		}
+    ComponentInfo getComponentInfo();
 
-		Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component Manager : " + m_state);
-	}
+    /**
+     * @return the component metadata.
+     */
+    ComponentMetadata getComponentMetatada();
 
+    /**
+     * @return the factory of the component
+     */
+    ComponentManagerFactory getFactory();
 
-	// ======================= end Handlers Management =====================
 
-}
\ No newline at end of file
+}

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerFactory.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerFactory.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerFactory.java Mon Oct 30 08:36:04 2006
@@ -1,270 +1,318 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 
 import java.io.IOException;
 import java.net.URL;
 import java.security.ProtectionDomain;
+import java.util.Collection;
+import java.util.Dictionary;
 import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Properties;
 import java.util.logging.Level;
 
 import org.apache.felix.ipojo.metadata.Element;
 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.ManagedServiceFactory;
 
 /**
  * The component manager factory class manages component manager object.
+ * This class could export Factory and ManagedServiceFactory services.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public class ComponentManagerFactory {
+public class ComponentManagerFactory implements Factory, ManagedServiceFactory {
+
+    // Fields :
+    /**
+     * List of the managed component manager.
+     * The key of tis hashmap is the name (pid) of the component created
+     */
+    private HashMap m_componentManagers = new HashMap();
+
+    /**
+     * The bundle context reference.
+     */
+    private BundleContext m_bundleContext = null;
+
+    /**
+     * Component class.
+     */
+    private byte[] m_clazz = null;
+
+    /**
+     * Component Class Name.
+     */
+    private String m_componentClassName = null;
+
+    /**
+     * Classloader to delegate loading.
+     */
+    private FactoryClassloader m_classLoader = null;
+
+    /**
+     * Component Type provided by this factory.
+     */
+    private Element m_componentMetadata;
+
+    /**
+     * Service Registration of this factory (Facotry & ManagedServiceFactory).
+     */
+    private ServiceRegistration m_sr;
 
-	// Fields :
-	/**
-	 * List of the managed component manager.
-	 */
-	private ComponentManager[] m_componentManagers = new ComponentManager[0];
-
-	/**
-	 * The bundle context reference.
-	 */
-	private BundleContext m_bundleContext = null;
-
-	/**
-	 * Component class.
-	 */
-	private byte[] m_clazz = null;
-
-	/**
-	 * Component Class Name.
-	 */
-	private String m_componentClassName = null;
-
-	/**
-	 * Classloader to delegate loading.
-	 */
-	private FactoryClassloader m_classLoader = null;
-
-	//End field
-
-	/**
-	 * FactoryClassloader.
-	 */
-	private class FactoryClassloader extends ClassLoader {
-
-	    /**
-	     * load the class.
-	     * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
-	     * @param name : the name of the class
-	     * @param resolve : should be the class resolve now ?
-	     * @return : the loaded class
-	     * @throws ClassNotFoundException : the class to load is not found
-	     */
-	    protected synchronized Class loadClass(final String name,
-	            final boolean resolve) throws ClassNotFoundException {
-	       return m_bundleContext.getBundle().loadClass(name);
-	    }
-
-
-	    /**
-	     * Return the URL of the asked ressource.
-	     * @param arg : the name of the resource to find.
-	     * @return the URL of the resource.
-	     * @see java.lang.ClassLoader#getResource(java.lang.String)
-	     */
-	    public URL getResource(String arg) {
-	        return m_bundleContext.getBundle().getResource(arg);
-	    }
-
-	    /**
-	     * .
-	     * @param arg : resource to find
-	     * @return : the enumeration found
-	     * @throws IOException : if the lookup failed.
-	     * @see java.lang.ClassLoader#getResources(java.lang.String)
-	     */
-	    public Enumeration getRessources(String arg) throws IOException {
-	        return m_bundleContext.getBundle().getResources(arg);
-	    }
-
-	    /**
-	     * The defineClass method.
-	     * @param name : name of the class
-	     * @param b : the byte array of the class
-	     * @param domain : the protection domain
-	     * @return : the defined class.
-	     * @throws Exception : if a problem is detected during the loading
-	     */
-	    public Class defineClass(String name, byte[] b,
-	            ProtectionDomain domain) throws Exception {
-	    	return super.defineClass(name, b, 0, b.length, domain);
-	    }
-	}
-
-	// Field accessors
-
-	 /**
-     * Add a component manager factory to the component manager list.
-     * @param cm : the new component metadata.
-     */
-    private void addComponent(ComponentManager cm) {
-
-    	// If the component manager array is not empty add the new factory at the end
-        if (m_componentManagers.length != 0) {
-        	ComponentManager[] newCM = new ComponentManager[m_componentManagers.length + 1];
-            System.arraycopy(m_componentManagers, 0, newCM, 0, m_componentManagers.length);
-            newCM[m_componentManagers.length] = cm;
-            m_componentManagers = newCM;
+    /**
+     * Component-Type info exposed by the factory service.
+     */
+    private ComponentInfo m_componentInfo;
+
+    //End field
+
+    /**
+     * FactoryClassloader.
+     */
+    private class FactoryClassloader extends ClassLoader  {
+
+        /**
+         * load the class.
+         * @see java.lang.ClassLoader#loadClass(java.lang.String, boolean)
+         * @param name : the name of the class
+         * @param resolve : should be the class resolve now ?
+         * @return : the loaded class
+         * @throws ClassNotFoundException : the class to load is not found
+         */
+        protected synchronized Class loadClass(final String name,
+                final boolean resolve) throws ClassNotFoundException {
+            return m_bundleContext.getBundle().loadClass(name);
         }
-        // Else create an array of size one with the new component manager
-        else {
-            m_componentManagers = new ComponentManager[] {cm};
+
+
+        /**
+         * Return the URL of the asked ressource.
+         * @param arg : the name of the resource to find.
+         * @return the URL of the resource.
+         * @see java.lang.ClassLoader#getResource(java.lang.String)
+         */
+        public URL getResource(String arg) {
+            return m_bundleContext.getBundle().getResource(arg);
+        }
+
+        /**
+         * .
+         * @param arg : resource to find
+         * @return : the enumeration found
+         * @throws IOException : if the lookup failed.
+         * @see java.lang.ClassLoader#getResources(java.lang.String)
+         */
+        public Enumeration getRessources(String arg) throws IOException {
+            return m_bundleContext.getBundle().getResources(arg);
+        }
+
+        /**
+         * The defineClass method.
+         * @param name : name of the class
+         * @param b : the byte array of the class
+         * @param domain : the protection domain
+         * @return : the defined class.
+         * @throws Exception : if a problem is detected during the loading
+         */
+        public Class defineClass(String name, byte[] b,
+                ProtectionDomain domain) throws Exception {
+            return super.defineClass(name, b, 0, b.length, domain);
+        }
+    }
+
+
+    /**
+     * @return the iPOJO activator reference
+     */
+    public BundleContext getBundleContext() { return m_bundleContext; }
+
+    /**
+     * @return the class name of the component-type provided by this factory.
+     */
+    protected String getComponentClassName() { return m_componentClassName; }
+
+    /**
+     * Create a component manager factory.
+     * @param bc : bundle context
+     * @param cm : metadata of the component to create
+     */
+    public ComponentManagerFactory(BundleContext bc, Element cm) {
+        m_bundleContext = bc;
+        m_componentClassName = cm.getAttribute("className");
+        m_componentMetadata = cm;
+    }
+
+    /**
+     * Create a component manager factory. The class is given in parameter.
+     * @param bc : bundle context
+     * @param clazz : the component class
+     * @param cm : metadata of the component
+     */
+    public ComponentManagerFactory(BundleContext bc, byte[] clazz, Element cm) {
+        m_bundleContext = bc;
+        m_clazz = clazz;
+        m_componentClassName = cm.getAttribute("className");
+        m_componentMetadata = cm;
+    }
+
+    /**
+     * Create a component manager factory, no component manager are created.
+     * @param bc
+     */
+    public ComponentManagerFactory(BundleContext bc) { m_bundleContext = bc; }
+
+
+    // Factory lifecycle management
+
+    /**
+     * Stop all the component managers.
+     */
+    public void stop() {
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Stop the component factory");
+        Collection col = m_componentManagers.values();
+        Iterator it = col.iterator();
+        while (it.hasNext()) {
+            ComponentManagerImpl cm = (ComponentManagerImpl) it.next();
+            cm.stop();
         }
+        m_componentManagers.clear();
+        if (m_sr != null) { m_sr.unregister(); }
+        m_sr = null;
+    }
+
+    /**
+     * Start all the component managers.
+     */
+    public void start() {
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Start the component factory");
+
+        // Check if the factory should be exposed
+        if (m_componentMetadata.containsAttribute("factory") && m_componentMetadata.getAttribute("factory").equalsIgnoreCase("no")) { return; }
+        Properties props = new Properties();
+        props.put("component.class", m_componentClassName);
+
+        // create a ghost component
+        ComponentManagerImpl ghost = new ComponentManagerImpl(this);
+        ghost.configure(m_componentMetadata, new Properties());
+        m_componentInfo = ghost.getComponentInfo();
+
+        props.put("component.providedServiceSpecifications", m_componentInfo.getprovidedServiceSpecification());
+        props.put("component.properties", m_componentInfo.getProperties());
+        props.put("component.information", m_componentInfo.toString());
+
+        // Get factory PID :
+        if (m_componentMetadata.containsAttribute("name")) { props.put(Constants.SERVICE_PID, m_componentMetadata.getAttribute("name")); }
+        else { props.put(Constants.SERVICE_PID, m_componentMetadata.getAttribute("className")); }
+
+        // Exposition of the factory service
+        m_sr = m_bundleContext.registerService(new String[] {Factory.class.getName(), ManagedServiceFactory.class.getName()}, this, props);
     }
 
     /**
-     * Remove the component manager for m the list.
-     * @param cm : the component manager to remove
+     * @see org.apache.felix.ipojo.Factory#getComponentInfo()
      */
-    public void removeComponent(ComponentManager cm) {
-    	cm.stop();
-    	int idx = -1;
-
-    	for (int i = 0; i < m_componentManagers.length; i++) {
-    		if (m_componentManagers[i] == cm) { idx = i; }
-    	}
-
-        if (idx >= 0) {
-            if ((m_componentManagers.length - 1) == 0) { m_componentManagers = new ComponentManager[0]; }
-            else {
-            	ComponentManager[] newCMList = new ComponentManager[m_componentManagers.length - 1];
-                System.arraycopy(m_componentManagers, 0, newCMList, 0, idx);
-                if (idx < newCMList.length) {
-                    System.arraycopy(m_componentManagers, idx + 1, newCMList, idx, newCMList.length - idx); }
-                m_componentManagers = newCMList;
+    public ComponentInfo getComponentInfo() { return m_componentInfo; }
+
+    /**
+     * Load a class.
+     * @param className : name of the class to load
+     * @return the resulting Class object
+     * @throws ClassNotFoundException : happen when the class is not found
+     */
+    public Class loadClass(String className) throws ClassNotFoundException {
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] In load for : " + className);
+        if (m_clazz != null && className.equals(m_componentClassName)) {
+            if (m_classLoader == null) {
+                Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Create the FactoryClassLoader for : " + className);
+                m_classLoader = new FactoryClassloader();
             }
+            try {
+                Class c = m_classLoader.defineClass(m_componentClassName, m_clazz, null);
+                Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Return " + c + " for " + className);
+                return c;
+            } catch (Exception e) {
+                Activator.getLogger().log(Level.SEVERE, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Cannot define the class : " + className);
+                return null;
             }
-       }
+        }
+        return m_bundleContext.getBundle().loadClass(className);
+    }
 
     /**
-     * @return the iPOJO activator reference
+     * Return the URL of a resource.
+     * @param resName : resource name
+     * @return the URL of the resource
      */
-    public BundleContext getBundleContext() { return m_bundleContext; }
+    public URL getResource(String resName) {
+        return m_bundleContext.getBundle().getResource(resName);
+    }
 
-	// End field accessors
+    /**
+     * @see org.apache.felix.ipojo.Factory#createComponent(java.util.Dictionary)
+     */
+    public ComponentManager createComponent(Dictionary configuration) {
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Create a component and start it");
+        ComponentManagerImpl component = new ComponentManagerImpl(this);
+        component.configure(m_componentMetadata, configuration);
+
+        String pid = null;
+        if (configuration.get("name") != null) { pid = (String) configuration.get("name"); }
+        else { pid = m_componentMetadata.getAttribute("className"); }
+
+        m_componentManagers.put(pid, component);
+        component.start();
+        return component;
+    }
 
-	/**
-	 * Create a component manager factory and create a component manager with the given medatada.
-	 * @param bc : bundle context
-	 * @param cm : metadata of the component to create
-	 */
-	public ComponentManagerFactory(BundleContext bc, Element cm) {
-		m_bundleContext = bc;
-		createComponentManager(cm);
-		m_componentClassName = cm.getAttribute("className");
-	}
-
-	/**
-	 * Create a component manager factory and create a component manager with the given medatada.
-	 * @param bc : bundle context
-	 * @param clazz : the component class
-	 * @param cm : metadata of the component
-	 */
-	public ComponentManagerFactory(BundleContext bc, byte[] clazz, Element cm) {
-		m_bundleContext = bc;
-		m_clazz = clazz;
-		m_componentClassName = cm.getAttribute("className");
-		createComponentManager(cm);
-	}
-
-	/**
-	 * Create a component manager factory, no component manager are created.
-	 * @param bc
-	 */
-	public ComponentManagerFactory(BundleContext bc) {
-		m_bundleContext = bc;
-	}
-
-	/**
-	 * Create a component manager form the component metadata.
-	 * @param cm : Component Metadata
-	 * @return a component manager configured with the metadata
-	 */
-	public ComponentManager createComponentManager(Element cm) {
-		ComponentManager component = new ComponentManager(this);
-		component.configure(cm);
-		addComponent(component);
-		return component;
-	}
-
-	// Factory lifecycle management
-
-	/**
-	 * Stop all the component managers.
-	 */
-	public void stop() {
-		Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Stop the component factory");
-		for (int i = 0; i < m_componentManagers.length; i++) {
-			ComponentManager cm = m_componentManagers[i];
-			cm.stop();
-		}
-	}
-
-	/**
-	 * Start all the component managers.
-	 */
-	public void start() {
-		Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Start the component factory");
-		for (int i = 0; i < m_componentManagers.length; i++) {
-			ComponentManager cm = m_componentManagers[i];
-			cm.start();
-		}
-	}
-
-	/**
-	 * Load a class.
-	 * @param className : name of the class to load
-	 * @return the resulting Class object
-	 * @throws ClassNotFoundException : happen when the class is not found
-	 */
-	public Class loadClass(String className) throws ClassNotFoundException {
-		Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] In load for : " + className);
-		if (m_clazz != null && className.equals(m_componentClassName)) {
-			if (m_classLoader == null) {
-				Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Create the FactoryClassLoader for : " + className);
-				m_classLoader = new FactoryClassloader();
-				}
-			try {
-				Class c = m_classLoader.defineClass(m_componentClassName, m_clazz, null);
-				Activator.getLogger().log(Level.INFO, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Return " + c + " for " + className);
-				return c;
-			} catch (Exception e) {
-				Activator.getLogger().log(Level.SEVERE, "[Bundle " + m_bundleContext.getBundle().getBundleId() + "] Cannot define the class : " + className);
-				return null;
-			}
-		}
-		return m_bundleContext.getBundle().loadClass(className);
-	}
-
-	/**
-	 * Return the URL of a resource.
-	 * @param resName : resource name
-	 * @return the URL of the resource
-	 */
-	public URL getResource(String resName) {
-		return m_bundleContext.getBundle().getResource(resName);
-	}
+    /**
+     * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
+     */
+    public void deleted(String pid) {
+        ComponentManagerImpl cm = (ComponentManagerImpl) m_componentManagers.remove(pid);
+        if (cm == null) { return;  } // do nothing, the component does not exist !
+        else { cm.stop(); }
+    }
+
+    /**
+     * @see org.osgi.service.cm.ManagedServiceFactory#getName()
+     */
+    public String getName() {
+        if (m_componentMetadata.containsAttribute("name")) { return m_componentMetadata.getAttribute("name"); }
+        else { return m_componentMetadata.getAttribute("className"); }
+    }
+
+    /**
+     * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
+     */
+    public void updated(String pid, Dictionary properties) throws ConfigurationException {
+        ComponentManagerImpl cm = (ComponentManagerImpl) m_componentManagers.get(pid);
+        if (cm == null) { createComponent(properties); } // Create the component
+        else {
+            cm.stop(); // Stop the component
+            cm.configure(m_componentMetadata, properties); // re-configure the component
+            cm.start(); // restart it
+        }
+    }
 
 }

Added: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerImpl.java?view=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerImpl.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerImpl.java Mon Oct 30 08:36:04 2006
@@ -0,0 +1,579 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.logging.Level;
+
+import org.apache.felix.ipojo.metadata.Element;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The component manager implementation class manages one instance of a component type.
+ * It manages component lifecycle, component instance creation and handlers.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class ComponentManagerImpl implements ComponentManager {
+
+    /**
+     * Parent factory (ComponentManagerFactory).
+     */
+    private ComponentManagerFactory m_factory;
+
+    /**
+     * Attached metadata of the managed component.
+     */
+    private ComponentMetadata m_metadata;
+
+    /**
+     * The context of the component.
+     */
+    private BundleContext m_context;
+
+    /**
+     * Handler list.
+     */
+    private Handler[] m_handlers = new Handler[0];
+
+    /**
+     * Map [field, handler list] storing handlers interested by the field.
+     */
+    private HashMap m_fieldRegistration = new HashMap();
+
+    /**
+     * Component state (STOPPED at the beginning).
+     */
+    private int m_state = INVALID;
+
+    // Fields use for the manipulation, the loading of the class and for the instance creation
+
+    /**
+     * Manipulatd clazz.
+     */
+    private Class m_clazz;
+
+    /**
+     * Instances of the components.
+     */
+    private Object[] m_instances = new Object[0];
+
+    /**
+     * Component type information.
+     */
+    private ComponentInfo m_componentInfo;
+
+    // Constructor
+    /**
+     * Construct a new Component Manager.
+     * @param factory : the factory managing the component manager
+     */
+    public ComponentManagerImpl(ComponentManagerFactory factory) {
+        m_factory = factory;
+        m_context = factory.getBundleContext();
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_context.getBundle().getBundleId() + "] Create a component manager from the factory " + m_factory);
+    }
+
+    /**
+     * Configure the component manager.
+     * Stop the existings handler, clear the handler list, change the metadata, recreate the handlers
+     * @param cm
+     */
+    public void configure(Element cm, Dictionary configuration) {
+        Activator.getLogger().log(Level.INFO, "[Bundle " + m_context.getBundle().getBundleId() + "] Configure the component manager " + cm.getAttribute("className"));
+
+        // Stop all previous registred handler
+        if (m_handlers.length != 0) { stop(); }
+
+        // Clear the handler list
+        m_handlers = new Handler[0];
+
+        // Change the metadata
+        m_metadata = new ComponentMetadata(cm);
+
+        // COmponentInfo initialization
+        m_componentInfo = new ComponentInfo();
+        m_componentInfo.setClassName(m_metadata.getClassName());
+
+        // Create the standard handlers and add these handlers to the list
+        for (int i = 0; i < IPojoConfiguration.INTERNAL_HANDLERS.length; i++) {
+            // Create a new instance
+            try {
+                Handler h = (Handler) IPojoConfiguration.INTERNAL_HANDLERS[i].newInstance();
+                h.configure(this, cm, configuration);
+            } catch (InstantiationException e) {
+                Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
+            } catch (IllegalAccessException e) {
+                Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + IPojoConfiguration.INTERNAL_HANDLERS[i] + " : " + e.getMessage());
+            }
+        }
+
+        // Look for namespaces
+        for (int i = 0; i < cm.getNamespaces().length; i++) {
+            if (!cm.getNamespaces()[i].equals("")) {
+                Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Look for class for the namespace : " + cm.getNamespaces()[i]);
+                // It is not an internal handler, try to load it
+                try {
+                    Class c = m_context.getBundle().loadClass(cm.getNamespaces()[i]);
+                    Handler h = (Handler) c.newInstance();
+                    h.configure(this, cm, configuration);
+                } catch (ClassNotFoundException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                } catch (InstantiationException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                } catch (IllegalAccessException e) {
+                    Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Cannot instantiate the handler " + cm.getNamespaces()[i] + " : " + e.getMessage());
+                }
+
+            }
+        }
+
+    }
+
+    /**
+     * @return the component type information.
+     */
+    public ComponentInfo getComponentInfo() { return m_componentInfo; }
+
+    /**
+     * @return the component metadata.
+     */
+    public ComponentMetadata getComponentMetatada() { return m_metadata; }
+
+    /**
+     * @return the list of the registred handlers.
+     */
+    public Handler[] getRegistredHandlers() { return m_handlers; }
+
+    /**
+     * Return a specified handler.
+     * @param name : class name of the handler to find
+     * @return : the handler, or null if not found
+     */
+    public Handler getHandler(String name) {
+        for (int i = 0; i < m_handlers.length; i++) {
+            if (m_handlers[i].getClass().getName().equalsIgnoreCase(name)) { return m_handlers[i]; }
+        }
+        return null;
+    }
+
+    // ===================== Lifecycle management =====================
+
+    /**
+     * Start the component manager.
+     */
+    public void start() {
+        // Start all the handlers
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Start the component manager with " + m_handlers.length + " handlers");
+
+        // The new state of the component is UNRESOLVED
+        m_state = INVALID;
+
+        for (int i = 0; i < m_handlers.length; i++) {
+            m_handlers[i].start();
+        }
+
+        // Defines the state of the component :
+        checkComponentState();
+    }
+
+    /**
+     * Stop the component manager.
+     */
+    public void stop() {
+        setState(INVALID);
+        // Stop all the handlers
+        for (int i = m_handlers.length - 1; i > -1; i--) {
+            m_handlers[i].stop();
+        }
+        m_instances = new Object[0];
+    }
+
+    /**
+     * Set the state of the component.
+     * if the state changed call the stateChanged(int) method on the handlers
+     */
+    public void setState(int state) {
+        if (m_state != state) {
+
+            // Log the state change
+            if (state == INVALID) { Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component " + m_metadata.getClassName() + " State -> UNRESOLVED"); }
+            if (state == VALID) { Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component " + m_metadata.getClassName() + " State -> VALID"); }
+
+            // The state changed call the handler stateChange method
+            m_state = state;
+            for (int i = m_handlers.length - 1; i > -1; i--) {
+                m_handlers[i].stateChanged(state);
+            }
+        }
+    }
+
+    /**
+     * @return the actual state of the component.
+     */
+    public int getState() {
+        return m_state;
+    }
+
+    // ===================== end Lifecycle management =====================
+
+    // ================== Class & Instance management ===================
+
+    /**
+     * @return the factory of the component
+     */
+    public ComponentManagerFactory getFactory() { return m_factory; }
+
+    /**
+     * Load the manipulated class.
+     */
+    private void load() {
+        try {
+            m_clazz = m_factory.loadClass(m_metadata.getClassName());
+        } catch (ClassNotFoundException  e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] Class not found during the loading phase : " + e.getMessage());
+            return;
+        }
+    }
+
+    /**
+     * @return true if the class is loaded
+     */
+    private boolean isLoaded() {
+        return (m_clazz != null);
+    }
+
+    /**
+     * Add an instance to the created instance list.
+     * @param o : the instance to add
+     */
+    private void addInstance(Object o) {
+        for (int i = 0; (m_instances != null) && (i < m_instances.length); i++) {
+            if (m_instances[i] == o) { return; }
+        }
+
+        if (m_instances.length > 0) {
+            Object[] newInstances = new Object[m_instances.length + 1];
+            System.arraycopy(m_instances, 0, newInstances, 0, m_instances.length);
+            newInstances[m_instances.length] = o;
+            m_instances = newInstances;
+        }
+        else {
+            m_instances = new Object[] {o};
+        }
+    }
+
+    /**
+     * Remove an instance from the created instance list. The instance will be eated by the garbage collector.
+     * @param o : the instance to remove
+     */
+    private void removeInstance(Object o) {
+        int idx = -1;
+        for (int i = 0; i < m_instances.length; i++) {
+            if (m_instances[i] == o) { idx = i; break; }
+        }
+
+        if (idx >= 0) {
+            if ((m_instances.length - 1) == 0) { m_instances = new Element[0]; }
+            else {
+                Object[] newInstances = new Object[m_instances.length - 1];
+                System.arraycopy(m_instances, 0, newInstances, 0, idx);
+                if (idx < newInstances.length) {
+                    System.arraycopy(m_instances, idx + 1, newInstances, idx, newInstances.length - idx); }
+                m_instances = newInstances;
+            }
+        }
+    }
+
+    /**
+     * @return the created instance of the component.
+     */
+    public Object[] getInstances() { return m_instances; }
+
+    /**
+     * Delete the created instance (remove it from the list, to allow the garbage collector to eat the instance).
+     * @param o : the instance to delete
+     */
+    public void deleteInstance(Object o) { removeInstance(o); }
+
+    /**
+     * Create an instance of the component.
+     * This method need to be called one time only for singleton provided service
+     * @return a new instance
+     */
+    public Object createInstance() {
+
+        if (!isLoaded()) { load(); }
+        Object instance = null;
+        try {
+            Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Try to find the constructor");
+
+            // Try to find if there is a constructor with a bundle context as parameter :
+            try {
+                Constructor constructor = m_clazz.getConstructor(new Class[] {ComponentManagerImpl.class, BundleContext.class});
+                constructor.setAccessible(true);
+                instance = constructor.newInstance(new Object[] {this, m_factory.getBundleContext()});
+            }
+            catch (NoSuchMethodException e) {
+                Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> No constructor with a bundle context");
+            }
+
+            // Create an instance if no instance are already created with <init>()BundleContext
+            Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Try to create the object with an empty constructor");
+            if (instance == null) {
+                Constructor constructor = m_clazz.getConstructor(new Class[] {ComponentManagerImpl.class});
+                constructor.setAccessible(true);
+                instance = constructor.newInstance(new Object[] {this});
+            }
+
+        } catch (InstantiationException e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance cannot be instancied : " + e.getMessage());
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance is not accessible : " + e.getMessage());
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> The Component Instance is not accessible (security reason) : " + e.getMessage());
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> Cannot invoke the constructor method (illegal target) : " + e.getMessage());
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            Activator.getLogger().log(Level.SEVERE, "[" + m_metadata.getClassName() + "] createInstance -> Cannot invoke the constructor (method not found) : " + e.getMessage());
+            e.printStackTrace();
+        }
+
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] createInstance -> Return the instance " + instance);
+
+        // Register the new instance
+        addInstance(instance);
+        // Call createInstance on Handlers :
+        for (int i = 0; i < m_handlers.length; i++) { m_handlers[i].createInstance(instance); }
+        return instance;
+    }
+
+    /**
+     * @return the instance of the component to use for singleton component
+     */
+    public Object getInstance() {
+        if (m_instances.length == 0) { createInstance(); }
+        return m_instances[0];
+    }
+
+    /**
+     * @return the manipulated class
+     */
+    public Class getClazz() {
+        if (!isLoaded()) { load(); }
+        return m_clazz;
+    }
+
+    //  ================== end Class & Instance management ================
+
+    //  ======================== Handlers Management ======================
+
+    /**
+     * Register the given handler to the current component manager.
+     * @param h : the handler to register
+     */
+    public void register(Handler h) {
+        for (int i = 0; (m_handlers != null) && (i < m_handlers.length); i++) {
+            if (m_handlers[i] == h) {
+                return;
+            }
+        }
+
+        if (m_handlers != null) {
+            Handler[] newList = new Handler[m_handlers.length + 1];
+            System.arraycopy(m_handlers, 0, newList, 0, m_handlers.length);
+            newList[m_handlers.length] = h;
+            m_handlers = newList;
+        }
+    }
+
+    /**
+     * Register an handler.
+     * The handler will be notified of event on each field given in the list.
+     * @param h : the handler to register
+     * @param fields : the fields list
+     */
+    public void register(Handler h, String[] fields) {
+        register(h);
+        for (int i = 0; i < fields.length; i++) {
+            if (m_fieldRegistration.get(fields[i]) == null) {
+                m_fieldRegistration.put(fields[i], new Handler[] {h});
+            }
+            else {
+                Handler[] list = (Handler[]) m_fieldRegistration.get(fields[i]);
+                for (int j = 0; j < list.length; i++) { if (list[i] == h) { return; } }
+                Handler[] newList = new Handler[list.length + 1];
+                System.arraycopy(list, 0, newList, 0, list.length);
+                newList[list.length] = h;
+                m_fieldRegistration.put(fields[i], newList);
+            }
+        }
+    }
+
+    /**
+     * Unregister an handler for the field list.
+     * The handler will not be notified of field access but is allways register on the component manager.
+     * @param h : the handler to unregister.
+     * @param fields : the fields list
+     */
+    public void unregister(Handler h, String[] fields) {
+        for (int i = 0; i < fields.length; i++) {
+            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++) {
+                    if (list[j] == h) {
+                        idx = j;
+                        break;
+                    }
+                }
+
+                if (idx >= 0) {
+                    if ((list.length - 1) == 0) {
+                        list = new Handler[0];
+                    }
+                    else {
+                        Handler[] newList = new Handler[list.length - 1];
+                        System.arraycopy(list, 0, newList, 0, idx);
+                        if (idx < newList.length)             {
+                            System.arraycopy(
+                                    list, idx + 1, newList, idx, newList.length - idx);
+                        }
+                        list = newList;
+                    }
+                    m_fieldRegistration.put(fields[i], list);
+                }
+            }
+        }
+    }
+
+    /**
+     * Unregister the given handler.
+     * @param h : the handler to unregiter
+     */
+    public void unregister(Handler h) {
+        int idx = -1;
+        for (int i = 0; i < m_handlers.length; i++) {
+            if (m_handlers[i] == h) {
+                idx = i;
+                break;
+            }
+        }
+
+        if (idx >= 0) {
+            if ((m_handlers.length - 1) == 0) {
+                m_handlers = new Handler[0];
+            }
+            else {
+                Handler[] newList = new Handler[m_handlers.length - 1];
+                System.arraycopy(m_handlers, 0, newList, 0, idx);
+                if (idx < newList.length)             {
+                    System.arraycopy(
+                            m_handlers, idx + 1, newList, idx, newList.length - idx);
+                }
+                m_handlers = newList;
+            }
+        }
+    }
+
+    /**
+     * This method is called by the manipulated class each time that a GETFIELD instruction is found.
+     * The method ask to each handler which value need to be returned.
+     * @param fieldName : the field name on which the GETFIELD instruction is called
+     * @param initialValue : the value of the field in the code
+     * @return the value decided by the last asked handler (throw a warining if two fields decide two different values)
+     */
+    public Object getterCallback(String fieldName, Object initialValue) {
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Call the getterCallbackMethod on " + fieldName +  " with " + initialValue);
+        Object result = null;
+        // Get the list of registered handlers
+        Handler[] list = (Handler[]) m_fieldRegistration.get(fieldName);
+        for (int i = 0; list != null && i < list.length; i++) {
+            Object handlerResult = list[i].getterCallback(fieldName, initialValue);
+            if (handlerResult != initialValue) { result = handlerResult; }
+        }
+
+        if (result != null) {
+            Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] getterCallbackMethod return for " + fieldName +  " -> " + result);
+            return result;
+        } else {
+            Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] getterCallbackMethod return for " + fieldName +  " -> " + initialValue);
+            return initialValue;
+        }
+    }
+
+    /**
+     * This method is called by the manipulated class each time that a PUTFILED instruction is found.
+     * the method send to each handler the new value.
+     * @param fieldName : the field name on which the PUTFIELD instruction is called
+     * @param objectValue : the value of the field
+     */
+    public void setterCallback(String fieldName, Object objectValue) {
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Call the setterCallbackMethod on " + fieldName +  " with " + objectValue);
+        // Get the list of registered handlers
+        Handler[] list = (Handler[]) m_fieldRegistration.get(fieldName);
+
+        for (int i = 0; list != null && i < list.length; i++) {
+            m_handlers[i].setterCallback(fieldName, objectValue);
+        }
+    }
+
+    /**
+     * @return the context of the component.
+     */
+    public BundleContext getContext() { return m_context; }
+
+    /**
+     * Check the state of all handlers.
+     */
+    public void checkComponentState() {
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Check the component state");
+        boolean isValid = true;
+        for (int i = 0; i < m_handlers.length; i++) {
+            boolean b = m_handlers[i].isValid();
+            Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Validity of the handler : " + m_handlers[i] + " = " + b);
+            isValid = isValid && b;
+        }
+
+        // Update the component state if necessary
+        if (!isValid && m_state == VALID) {
+            // Need to update the state to UNRESOLVED
+            setState(INVALID);
+            m_instances = new Object[0];
+            return;
+        }
+        if (isValid && m_state == INVALID) {
+            setState(VALID);
+            if (m_metadata.isImmediate() && m_instances.length == 0) { createInstance(); }
+        }
+
+        Activator.getLogger().log(Level.INFO, "[" + m_metadata.getClassName() + "] Component Manager : " + m_state);
+    }
+
+
+    // ======================= end Handlers Management =====================
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentMetadata.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentMetadata.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/ComponentMetadata.java Mon Oct 30 08:36:04 2006
@@ -1,18 +1,20 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 
@@ -26,48 +28,48 @@
  */
 public class ComponentMetadata {
 
-	/**
-	 * Class name of the component.
-	 */
-	private String m_className;
-
-	/**
-	 * Is the component an immediate component ?
-	 */
-	private boolean m_isImmediate = false;
-
-    /**
-	 * Metadata of the component.
-	 */
-	private Element m_metadata;
+    /**
+     * Class name of the component.
+     */
+    private String m_className;
+
+    /**
+     * Is the component an immediate component ?
+     */
+    private boolean m_isImmediate = false;
+
+    /**
+     * Metadata of the component.
+     */
+    private Element m_metadata;
 
-	/**
+    /**
      * Constructor.
-	 * @param metadata : metadata of the component
-	 */
-	public ComponentMetadata(Element metadata) {
-		m_metadata = metadata;
-		m_className = metadata.getAttribute("className");
-		if (m_className == null) {
-			Activator.getLogger().log(Level.SEVERE, "The class name of ths component cannot be setted, it does not exist in the metadata");
-		}
-		if (metadata.containsAttribute("immediate") && metadata.getAttribute("immediate").equals("true")) { m_isImmediate = true; }
-	}
-
-	// Getter
-	/**
-	 * @return the class name
-	 */
-	public String getClassName() { return m_className; }
-
-	/**
-	 * @return the component metadata
-	 */
-	public Element getMetadata() { return m_metadata; }
-
-	/**
-	 * @return true if its an immediate component
-	 */
-	public boolean isImmediate() { return m_isImmediate; }
+     * @param metadata : metadata of the component
+     */
+    public ComponentMetadata(Element metadata) {
+        m_metadata = metadata;
+        m_className = metadata.getAttribute("className");
+        if (m_className == null) {
+            Activator.getLogger().log(Level.SEVERE, "The class name of ths component cannot be setted, it does not exist in the metadata");
+        }
+        if (metadata.containsAttribute("immediate") && metadata.getAttribute("immediate").equals("true")) { m_isImmediate = true; }
+    }
+
+    // Getter
+    /**
+     * @return the class name
+     */
+    public String getClassName() { return m_className; }
+
+    /**
+     * @return the component metadata
+     */
+    public Element getMetadata() { return m_metadata; }
+
+    /**
+     * @return true if its an immediate component.
+     */
+    public boolean isImmediate() { return m_isImmediate; }
 
 }

Added: 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=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java Mon Oct 30 08:36:04 2006
@@ -0,0 +1,43 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo;
+
+import java.util.Dictionary;
+
+/**
+ * Component Type Factory Service.
+ * This service is exposed by a component manager factory, and allows the dynamic creation of component instance.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public interface Factory {
+
+    /**
+     * Create a component manager (i.e. component type instance).
+     * @param configuration : the configuration property for this component.
+     * @return the created component manager.
+     */
+    ComponentManager createComponent(Dictionary configuration);
+
+    /**
+     * Get the component type information containing provided service, configuration properties ...
+     * @return the compionent type information.
+     */
+    ComponentInfo getComponentInfo();
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Factory.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=469182&r1=469181&r2=469182
==============================================================================
--- 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 Mon Oct 30 08:36:04 2006
@@ -1,72 +1,81 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 
+import java.util.Dictionary;
+
 import org.apache.felix.ipojo.metadata.Element;
 
 /**
- * Handler Interface.
+ * Handler Abstract Class.
  * An handler need implements tese method to be notifed of lifecycle change, getfield operation and putfield operation
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
-public interface Handler {
-
-	/**
-	 * Configure the handler.
-	 * @param cm : the component manager
-	 * @param metadata : the metadata of the component
-	 */
-	void configure(ComponentManager cm, Element metadata);
-
-	/**
-	 * Stop the handler : stop the management.
-	 */
-	void stop();
-
-	/**
-	 * Start the handler : start the management.
-	 */
-	void start();
-
-	/**
-	 * This method is called when a PUTFIELD operation is detected.
-	 * @param fieldName : the field name
-	 * @param value : the value passed to the field
-	 */
-	void setterCallback(String fieldName, Object value);
-
-	/**
-	 * This method is called when a GETFIELD operation is detected.
-	 * @param fieldName : the field name
-	 * @param value : the value passed to the field (by the previous handler)
-	 * @return : the managed value of the field
-	 */
-	Object getterCallback(String fieldName, Object value);
-
-	/**
-	 * Is the actual state valid for this handler ?
-	 * @return true is the state seems valid for the handler
-	 */
-	boolean isValid();
-
-	/**
-	 * This method is called when the component state changed.
-	 * @param state : the new state
-	 */
-	void stateChanged(int state);
+public abstract class Handler {
 
+    /**
+     * Configure the handler.
+     * @param cm : the component manager
+     * @param metadata : the metadata of the component
+     */
+    public abstract void configure(ComponentManagerImpl cm, Element metadata, Dictionary configuration);
+
+    /**
+     * Stop the handler : stop the management.
+     */
+    public abstract void stop();
+
+    /**
+     * Start the handler : start the management.
+     */
+    public abstract void start();
+
+    /**
+     * This method is called when a PUTFIELD operation is detected.
+     * @param fieldName : the field name
+     * @param value : the value passed to the field
+     */
+    public void setterCallback(String fieldName, Object value) { }
+
+    /**
+     * This method is called when a GETFIELD operation is detected.
+     * @param fieldName : the field name
+     * @param value : the value passed to the field (by the previous handler)
+     * @return : the managed value of the field
+     */
+    public Object getterCallback(String fieldName, Object value) { return value; }
+
+    /**
+     * Is the actual state valid for this handler ?
+     * @return true is the state seems valid for the handler
+     */
+    public boolean isValid() { return true; }
+
+    /**
+     * This method is called when the component state changed.
+     * @param state : the new state
+     */
+    public void stateChanged(int state) { }
+
+    /**
+     * This method is called when an instance of the component is created, but before someone can use it.
+     * @param instance : the created instance
+     */
+    public void createInstance(Object instance) { }
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoConfiguration.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoConfiguration.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/IPojoConfiguration.java Mon Oct 30 08:36:04 2006
@@ -1,18 +1,20 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 
@@ -32,20 +34,20 @@
  */
 public class IPojoConfiguration {
 
-	/**
-	 * iPOJO logger log level.
-	 */
-	public static final Level LOG_LEVEL = Level.WARNING;
+    /**
+     * iPOJO logger log level.
+     */
+    public static final Level LOG_LEVEL = Level.WARNING;
 
-	/**
-	 * Available handlers in the iPOJO bundle.
-	 */
-	public static final Class[] INTERNAL_HANDLERS = new Class[] {
-		DependencyHandler.class,
-		ProvidedServiceHandler.class,
-		ConfigurationHandler.class,
-		LifecycleCallbackHandler.class,
-		ArchitectureHandler.class
-	};
+    /**
+     * Available handlers in the iPOJO bundle.
+     */
+    public static final Class[] INTERNAL_HANDLERS = new Class[] {
+        DependencyHandler.class,
+        ProvidedServiceHandler.class,
+        ConfigurationHandler.class,
+        LifecycleCallbackHandler.class,
+        ArchitectureHandler.class
+    };
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Nullable.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Nullable.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Nullable.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/Nullable.java Mon Oct 30 08:36:04 2006
@@ -1,18 +1,20 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo;
 

Added: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/PropertyInfo.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/PropertyInfo.java?view=auto&rev=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/PropertyInfo.java (added)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/PropertyInfo.java Mon Oct 30 08:36:04 2006
@@ -0,0 +1,77 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo;
+
+/**
+ * Property Information.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class PropertyInfo {
+
+    /**
+     * Name of the property.
+     */
+    private String m_name;
+
+    /**
+     * Type of the property.
+     */
+    private String m_type;
+
+    /**
+     * Default value of the property.
+     */
+    private String m_value = null;
+
+    /**
+     * Constructor.
+     * @param name : name of the property
+     * @param type : type of the property
+     * @param value : default value of the property
+     */
+    public PropertyInfo(String name, String type, String value) {
+        m_name = name;
+        m_type = type;
+        m_value = value;
+    }
+
+    /**
+     * @return the property name.
+     */
+    public String getName() { return m_name; }
+
+    /**
+     * @return the property type.
+     */
+    public String getType() { return m_type; }
+
+    /**
+     * @return the default value for the property.
+     */
+    public String getValue() { return m_value; }
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        if (m_value != null) { return getName() + " - " + getType() + " - " + getValue(); }
+        else { return getName() + " - " + getType() + " - CONFIGURABLE"; }
+    }
+
+}

Propchange: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/PropertyInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/Architecture.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/Architecture.java?view=diff&rev=469182&r1=469181&r2=469182
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/Architecture.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/architecture/Architecture.java Mon Oct 30 08:36:04 2006
@@ -1,24 +1,26 @@
-/*
- *   Copyright 2006 The Apache Software Foundation
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *   Licensed under the Apache License, Version 2.0 (the "License");
- *   you may not use this file except in compliance with the License.
- *   You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.felix.ipojo.architecture;
 
 /**
  * Architecture service.
- * Allows to have information of the service delivery about GenSD component.
+ * Allows to have information on the component.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
 public interface Architecture {



Mime
View raw message