felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r487682 [3/4] - in /incubator/felix/trunk: ipojo.arch/src/main/java/org/apache/felix/ipojo/arch/ ipojo.plugin/ ipojo.plugin/src/main/java/org/apache/felix/ipojo/manipulation/ ipojo.plugin/src/main/java/org/apache/felix/ipojo/plugin/ ipojo.p...
Date Fri, 15 Dec 2006 21:56:13 GMT
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=487682&r1=487681&r2=487682
==============================================================================
--- 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 Dec 15 13:56:11 2006
@@ -21,10 +21,9 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
-import java.util.logging.Level;
 
-import org.apache.felix.ipojo.Activator;
-import org.apache.felix.ipojo.ComponentManagerImpl;
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.util.Logger;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
@@ -148,8 +147,8 @@
      * @return null or a service object or a list of service object according to the dependency.
      */
     protected Object get() {
-        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Call get for a dependency on : " + m_metadata.getServiceSpecification()
-                + " Multiple : " + m_metadata.isMultiple() + " Optional : " + m_metadata.isOptional());
+       // m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Call get for a dependency on : " + m_metadata.getServiceSpecification()
+       //         + " Multiple : " + m_metadata.isMultiple() + " Optional : " + m_metadata.isOptional());
         try {
 
             // 1 : Test if there is any change in the reference list :
@@ -164,15 +163,15 @@
             }
 
             // 2 : Else there is a change in the list -> recompute the m_services array
-            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Create a service array of " + m_clazz.getName());
+            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Create a service array of " + m_clazz.getName());
             m_services = (Object[]) Array.newInstance(m_clazz, m_ref.length);
 
             for (int i = 0; i < m_ref.length; i++) {
-                m_services[i] = m_handler.getComponentManager().getContext().getService(m_ref[i]);
+                m_services[i] = m_handler.getInstanceManager().getContext().getService(m_ref[i]);
             }
 
             m_change = false;
-            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Create an array with the size " + m_services.length);
+   //         m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Create an array with the size " + m_services.length);
 
 
             // 3 : The service object list is populated, I return either the first service object, either the array.
@@ -184,17 +183,17 @@
                     // Load the nullable class
                     String[] segment = m_metadata.getServiceSpecification().split("[.]");
                     String className = "org.apache.felix.ipojo." + segment[segment.length - 1] + "Nullable";
-                    Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Try to load the nullable class for " + getMetadata().getServiceSpecification() + " -> " + className);
+            //        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Try to load the nullable class for " + getMetadata().getServiceSpecification() + " -> " + className);
                     Class nullableClazz = m_handler.getNullableClass(className);
 
                     if (nullableClazz == null) {
-                        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Cannot load the nullable class to return a dependency object for " + m_metadata.getField() + " -> " + m_metadata.getServiceSpecification());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Cannot load the nullable class to return a dependency object for " + m_metadata.getField() + " -> " + m_metadata.getServiceSpecification());
                         return null;
                     }
 
                     // The nullable class is loaded, create the object and return it
                     Object instance = nullableClazz.newInstance();
-                    Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Nullable object created for " + getMetadata().getServiceSpecification() + " -> " + instance);
+             //       m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Nullable object created for " + getMetadata().getServiceSpecification() + " -> " + instance);
                     return instance;
                 }
             }
@@ -204,10 +203,10 @@
         } catch (Exception e) {
             // There is a problem in the dependency resolving (like in stopping method)
             if (!m_metadata.isMultiple()) {
-                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Return null, an exception was throwed in the get method -> " + e.getMessage());
+                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 {
-                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Return an empty array, an exception was throwed in the get method" + e.getMessage());
+                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); }
         }
     }
@@ -222,7 +221,7 @@
 
             // If a service goes way.
             if (event.getType() == ServiceEvent.UNREGISTERING) {
-                Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] A service is gone -> " + event.getServiceReference().getBundle());
+                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] A service is gone -> " + event.getServiceReference().getBundle());
                 if (containsSR(event.getServiceReference())) { departureManagement(event.getServiceReference()); }
                 return;
             }
@@ -236,11 +235,11 @@
             // If a service is modified
             if (event.getType() == ServiceEvent.MODIFIED) {
                 if (m_filter.match(event.getServiceReference())) {
-                    Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] A service with a filter matching is arrived -> " + event.getServiceReference().getBundle());
+                    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 {
-                    Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] A service with a filter matching has gone -> " + event.getServiceReference().getBundle());
+                    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()); }
                 }
                 return;
@@ -255,7 +254,7 @@
      */
     private void arrivalManagement(ServiceReference ref) {
         // Add the new service inside the ref list
-        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Add a service for a dependency");
+        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Add a service for a dependency");
         addReference(ref);
         if (isSatisfied()) {
             m_state = RESOLVED;
@@ -274,7 +273,7 @@
         if (m_metadata.isMultiple()) { callUnbindMethod(ref); }
 
         // Unget the service reference
-        m_handler.getComponentManager().getContext().ungetService(ref);
+        m_handler.getInstanceManager().getContext().ungetService(ref);
         int index = removeReference(ref);
 
         // Is the state valid or invalid
@@ -301,7 +300,7 @@
      * @param ref : reference to send (if accepted) to the method
      */
     private void callUnbindMethod(ServiceReference ref) {
-        if (m_handler.getComponentManager().getState() == ComponentManagerImpl.VALID) {
+        if (m_handler.getInstanceManager().getState() == InstanceManager.VALID) {
             for (int i = 0; i < m_metadata.getCallbacks().length; i++) {
                 if (m_metadata.getCallbacks()[i].getMethodType() == DependencyCallback.UNBIND) {
                     // Try to call the bind method with a service reference inside
@@ -314,30 +313,30 @@
                         } catch (NoSuchMethodException e1) {
                             // The method was not found : try with the service object
                             try {
-                                m_metadata.getCallbacks()[i].call(new Object[] {m_handler.getComponentManager().getContext().getService(ref)});
+                                m_metadata.getCallbacks()[i].call(new Object[] {m_handler.getInstanceManager().getContext().getService(ref)});
                             } catch (NoSuchMethodException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Unbind method not found : " + e1.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Unbind method not found", e2);
                                 return;
                             } catch (IllegalAccessException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on unbind method : " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on unbind method", e2);
                                 return;
                             } catch (InvocationTargetException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the unbind method " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the unbind method", e2);
                                 return;
                             }
                         } catch (IllegalAccessException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on unbind method : " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on unbind method", e1);
                             return;
                         } catch (InvocationTargetException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the unbind method " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the unbind method", e1);
                             return;
                         }
 
                     } catch (IllegalAccessException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e);
                         return;
                     } catch (InvocationTargetException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e);
                         return;
                     }
                 }
@@ -368,29 +367,29 @@
                             } catch (NoSuchMethodException e1) {
                                 // The method was not found : try with the service object
                                 try {
-                                    m_metadata.getCallbacks()[j].call(instance, new Object[] {m_handler.getComponentManager().getContext().getService(m_ref[i])});
+                                    m_metadata.getCallbacks()[j].call(instance, new Object[] {m_handler.getInstanceManager().getContext().getService(m_ref[i])});
                                 } catch (NoSuchMethodException e2) {
-                                    Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Bind method not found : " + e1.getMessage());
+                                    m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Bind method not found", e2);
                                     return;
                                 } catch (IllegalAccessException e2) {
-                                    Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e2.getMessage());
+                                    m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e2);
                                     return;
                                 } catch (InvocationTargetException e2) {
-                                    Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e2.getMessage());
+                                    m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e2);
                                     return;
                                 }
                             } catch (IllegalAccessException e1) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e1.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e1);
                                 return;
                             } catch (InvocationTargetException e1) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e1.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e1);
                                 return;
                             }
                         } catch (IllegalAccessException e) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e);
                             return;
                         } catch (InvocationTargetException e) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method" + e);
                             return;
                         }
                     }
@@ -405,35 +404,34 @@
                     } catch (NoSuchMethodException e) {
                         // The method was not found : try without service reference
                         try {
-                            Activator.getLogger().log(Level.WARNING, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Call the Bind method");
                             m_metadata.getCallbacks()[j].call(instance);
                         } catch (NoSuchMethodException e1) {
                             // The method was not found : try with the service object
                             try {
-                                m_metadata.getCallbacks()[j].call(new Object[] {m_handler.getComponentManager().getContext().getService(m_ref[0])});
+                                m_metadata.getCallbacks()[j].call(new Object[] {m_handler.getInstanceManager().getContext().getService(m_ref[0])});
                             } catch (NoSuchMethodException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Bind method not found : " + e1.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Bind method not found", e2);
                                 return;
                             } catch (IllegalAccessException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e2);
                                 return;
                             } catch (InvocationTargetException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e2);
                                 return;
                             }
                         } catch (IllegalAccessException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e1);
                             return;
                         } catch (InvocationTargetException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e1);
                             return;
                         }
 
                     } catch (IllegalAccessException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e);
                         return;
                     } catch (InvocationTargetException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e);
                         return;
                     }
                 }
@@ -447,7 +445,7 @@
      */
     private void callBindMethod(ServiceReference ref) {
         // call bind method :
-        if (m_handler.getComponentManager().getState() == ComponentManagerImpl.VALID) {
+        if (m_handler.getInstanceManager().getState() == InstanceManager.VALID) {
             for (int i = 0; i < m_metadata.getCallbacks().length; i++) {
                 if (m_metadata.getCallbacks()[i].getMethodType() == DependencyCallback.BIND) {
                     // Try to call the bind method with a service reference inside
@@ -456,35 +454,35 @@
                     } catch (NoSuchMethodException e) {
                         // The method was not found : try without service reference
                         try {
-                            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Call the Bind method");
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Call the Bind method");
                             m_metadata.getCallbacks()[i].call();
                         } catch (NoSuchMethodException e1) {
                             // The method was not found : try with the service object
                             try {
-                                m_metadata.getCallbacks()[i].call(new Object[] {m_handler.getComponentManager().getContext().getService(ref)});
+                                m_metadata.getCallbacks()[i].call(new Object[] {m_handler.getInstanceManager().getContext().getService(ref)});
                             } catch (NoSuchMethodException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Bind method not found : " + e1.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Bind method not found", e2);
                                 return;
                             } catch (IllegalAccessException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e2);
                                 return;
                             } catch (InvocationTargetException e2) {
-                                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e2.getMessage());
+                                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e2);
                                 return;
                             }
                         } catch (IllegalAccessException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e1);
                             return;
                         } catch (InvocationTargetException e1) {
-                            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e1.getMessage());
+                            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e1);
                             return;
                         }
 
                     } catch (IllegalAccessException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Illegal access on bind method : " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Illegal access on bind method", e);
                         return;
                     } catch (InvocationTargetException e) {
-                        Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method " + e.getMessage());
+                        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Dependency Callback Error : Invocation Target Exception in the bind method", e);
                         return;
                     }
                 }
@@ -506,11 +504,11 @@
             filter = classnamefilter;
         }
 
-        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Start a dependency on : " + m_metadata.getServiceSpecification() + " with " + m_metadata.getFilter());
+        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Start a dependency on : " + m_metadata.getServiceSpecification() + " with " + m_metadata.getFilter());
         m_state = UNRESOLVED;
 
         try {
-            m_clazz = m_handler.getComponentManager().getContext().getBundle().loadClass(m_metadata.getServiceSpecification());
+            m_clazz = m_handler.getInstanceManager().getContext().getBundle().loadClass(m_metadata.getServiceSpecification());
         } catch (ClassNotFoundException e) {
             System.err.println("Cannot load the interface class for the dependency " + m_metadata.getField() + " [" + m_metadata.getServiceSpecification() + "]");
             e.printStackTrace();
@@ -518,20 +516,20 @@
 
         try {
             // Look if the service is already present :
-            ServiceReference[] sr = m_handler.getComponentManager().getContext().getServiceReferences(
+            ServiceReference[] sr = m_handler.getInstanceManager().getContext().getServiceReferences(
                     m_metadata.getServiceSpecification(), filter);
             if (sr != null) {
                 for (int i = 0; i < sr.length; i++) { addReference(sr[i]); }
                 m_state = RESOLVED;
             }
             // Register a listener :
-            m_handler.getComponentManager().getContext().addServiceListener(this);
-            m_filter = m_handler.getComponentManager().getContext().createFilter(filter); // Store the filter
-            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Create a filter from : " + filter);
+            m_handler.getInstanceManager().getContext().addServiceListener(this);
+            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) {
-            Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] A filter is malformed : " + filter);
+            m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] A filter is malformed : " + filter);
             e1.printStackTrace();
         }
     }
@@ -540,16 +538,16 @@
      * Stop the dependency.
      */
     public void stop() {
-        Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Stop a dependency on : " + m_metadata.getServiceSpecification() + " with " + m_metadata.getFilter());
+        m_handler.getInstanceManager().getFactory().getLogger().log(Logger.INFO, "[" + m_handler.getInstanceManager().getClassName() + "] Stop a dependency on : " + m_metadata.getServiceSpecification() + " with " + m_metadata.getFilter());
         m_state = UNRESOLVED;
 
         // Unget all services references
         for (int i = 0; i < m_ref.length; i++) {
-            m_handler.getComponentManager().getContext().ungetService(m_ref[i]);
+            m_handler.getInstanceManager().getContext().ungetService(m_ref[i]);
         }
 
         m_ref = new ServiceReference[0];
-        m_handler.getComponentManager().getContext().removeServiceListener(this);
+        m_handler.getInstanceManager().getContext().removeServiceListener(this);
         m_clazz = null;
         m_services = null;
     }

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=487682&r1=487681&r2=487682
==============================================================================
--- 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 Dec 15 13:56:11 2006
@@ -20,7 +20,7 @@
 
 import java.lang.reflect.InvocationTargetException;
 
-import org.apache.felix.ipojo.Callback;
+import org.apache.felix.ipojo.util.Callback;
 
 
 /**
@@ -59,7 +59,7 @@
      */
     public DependencyCallback(Dependency dep, String method, int methodType, boolean isStatic) {
         m_methodType = methodType;
-        m_callback = new Callback(method, isStatic, dep.getDependencyHandler().getComponentManager());
+        m_callback = new Callback(method, isStatic, dep.getDependencyHandler().getInstanceManager());
     }
 
     /**

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=487682&r1=487681&r2=487682
==============================================================================
--- 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 Dec 15 13:56:11 2006
@@ -21,13 +21,12 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.Dictionary;
-import java.util.logging.Level;
 
-import org.apache.felix.ipojo.Activator;
-import org.apache.felix.ipojo.ComponentManagerImpl;
 import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.handlers.dependency.nullable.NullableObjectWriter;
 import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.util.Logger;
 
 /**
  * The dependency handler manages a list of dependencies.
@@ -36,9 +35,9 @@
 public class DependencyHandler extends Handler {
 
     /**
-     * The component manager using this handler.
+     * The instance manager using this handler.
      */
-    private ComponentManagerImpl m_componentManager;
+    private InstanceManager m_manager;
 
     /**
      * List of depednencies of the component.
@@ -110,9 +109,9 @@
     public Dependency[] getDependencies() { return m_dependencies; }
 
     /**
-     * @return the component manager
+     * @return the instance manager
      */
-    protected ComponentManagerImpl getComponentManager() { return m_componentManager; }
+    protected InstanceManager getInstanceManager() { return m_manager; }
 
 //  ===================== Handler implementation =====================
 
@@ -123,7 +122,7 @@
 
         synchronized (this) {
 
-            Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Check Context ...");
+            m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Check Context ...");
 
             // Store the initial state
             int initialState = m_state;
@@ -131,19 +130,19 @@
             // Check the component dependencies
             if (!validateComponentDependencies()) {
                 // The dependencies are not valid
-                if (initialState == ComponentManagerImpl.VALID) {
+                if (initialState == InstanceManager.VALID) {
                     //There is a state change
-                    m_state = ComponentManagerImpl.INVALID;
-                    m_componentManager.checkComponentState();
+                    m_state = InstanceManager.INVALID;
+                    m_manager.checkInstanceState();
                 }
                 // Else do nothing, the component state stay UNRESOLVED
             }
             else {
                 // The dependencies are valid
-                if (initialState == ComponentManagerImpl.INVALID) {
+                if (initialState == InstanceManager.INVALID) {
                     //There is a state change
-                    m_state = ComponentManagerImpl.VALID;
-                    m_componentManager.checkComponentState();
+                    m_state = InstanceManager.VALID;
+                    m_manager.checkInstanceState();
                 }
                 // Else do nothing, the component state stay VALID
             }
@@ -156,11 +155,10 @@
      * @param dep : the dependency to check
      * @return true if the dependency is valid
      */
-    private boolean checkDependency(Dependency dep) {
+    private boolean checkDependency(Dependency dep, Element manipulation) {
         // Check the internal type of dependency
         String field = dep.getMetadata().getField();
 
-        Element manipulation = m_componentManager.getComponentMetatada().getMetadata().getElements("Manipulation")[0];
         String type = null;
         for (int i = 0; i < manipulation.getElements("Field").length; i++) {
             if (field.equals(manipulation.getElements("Field")[i].getAttribute("name"))) {
@@ -170,7 +168,7 @@
         }
 
         if (type == null) {
-            Activator.getLogger().log(Level.SEVERE, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] A declared dependency was not found in the class : " + dep.getMetadata().getField());
+            m_manager.getFactory().getLogger().log(Logger.ERROR, "[DependencyHandler on " + m_manager.getClassName() + "] A declared dependency was not found in the class : " + dep.getMetadata().getField());
             return false;
         }
 
@@ -184,23 +182,22 @@
             if (dep.getMetadata().getServiceSpecification() == null) { dep.getMetadata().setServiceSpecification(type); }
 
             if (!dep.getMetadata().getServiceSpecification().equals(type)) {
-                Activator.getLogger().log(Level.WARNING, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] The field type [" + type + "] and the needed service interface [" + dep.getMetadata().getServiceSpecification() + "] are not the same");
+                m_manager.getFactory().getLogger().log(Logger.WARNING, "[DependencyHandler on " + m_manager.getClassName() + "] The field type [" + type + "] and the needed service interface [" + dep.getMetadata().getServiceSpecification() + "] are not the same");
                 dep.getMetadata().setServiceSpecification(type);
             }
         }
         else {
-            Activator.getLogger().log(Level.WARNING, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] The declared dependency " + dep.getMetadata().getField() + "  does not exist in the code");
+            m_manager.getFactory().getLogger().log(Logger.WARNING, "[DependencyHandler on " + m_manager.getClassName() + "] The declared dependency " + dep.getMetadata().getField() + "  does not exist in the code");
         }
         return true;
     }
 
 
     /**
-     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManagerImpl, org.apache.felix.ipojo.metadata.Element)
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.InstanceManager, org.apache.felix.ipojo.metadata.Element)
      */
-    public void configure(ComponentManagerImpl cm, Element componentMetadata, Dictionary configuration) {
-        // Fix the component manager
-        m_componentManager = cm;
+    public void configure(InstanceManager im, Element componentMetadata, Dictionary configuration) {
+        m_manager = im;
         m_dependencies = new Dependency[0];
         m_nullableClasses = new Class[0];
 
@@ -220,8 +217,9 @@
 
             Dependency dep = new Dependency(this, dm);
             // Check the dependency :
-            if (checkDependency(dep)) { addDependency(dep); }
-            else { Activator.getLogger().log(Level.SEVERE, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] The dependency on " + dep.getMetadata().getField() + " is not valid"); }
+            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.getMetadata().getField() + " is not valid"); }
 
             // Look for dependency callback :
             for (int j = 0; j < (deps[i].getElements("Callback", "")).length; j++) {
@@ -242,10 +240,11 @@
             for (int k = 0; k < m_dependencies.length; k++) {
                 fields[k] = m_dependencies[k].getMetadata().getField();
             }
-            m_componentManager.register(this, fields);
+            m_manager.register(this, fields);
 
             // Create the nullable classloader
-            m_classloader = new NullableClassloader(m_componentManager.getContext().getBundle());
+            // TODO why do not use the factory class loader ?
+            m_classloader = new NullableClassloader(m_manager.getContext().getBundle());
 
         }
     }
@@ -255,13 +254,13 @@
      * @param dep : the dependency
      */
     private void createNullableClass(Dependency dep) {
-        Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Try to load the nullable class for " + dep.getMetadata().getServiceSpecification());
+        m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Try to load the nullable class for " + dep.getMetadata().getServiceSpecification());
         // Try to load the nullable object :
         String[] segment = dep.getMetadata().getServiceSpecification().split("[.]");
         String className = "org/apache/felix/ipojo/" + segment[segment.length - 1] + "Nullable";
 
         String resource = dep.getMetadata().getServiceSpecification().replace('.', '/') + ".class";
-        URL url =  m_componentManager.getContext().getBundle().getResource(resource);
+        URL url =  m_manager.getContext().getBundle().getResource(resource);
 
         try {
             byte[] b = NullableObjectWriter.dump(url,  dep.getMetadata().getServiceSpecification());
@@ -279,12 +278,12 @@
 //          }
 
             addNullableClass(m_classloader.defineClass(className.replace('/', '.'), b, null));
-            Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Nullable class created for " + dep.getMetadata().getServiceSpecification());
+            m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Nullable class created for " + dep.getMetadata().getServiceSpecification());
 
         } catch (IOException e1) {
-            Activator.getLogger().log(Level.SEVERE, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Cannot open a stream of an interface to generate the nullable class for " + dep.getMetadata().getServiceSpecification() + " -> " + e1.getMessage());
+            m_manager.getFactory().getLogger().log(Logger.ERROR, "[DependencyHandler on " + m_manager.getClassName() + "] Cannot open a stream of an interface to generate the nullable class for " + dep.getMetadata().getServiceSpecification(), e1);
         } catch (Exception e2) {
-            Activator.getLogger().log(Level.SEVERE, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Cannot load the nullable class for  " + dep.getMetadata().getServiceSpecification() + " -> " + e2.getMessage());
+            m_manager.getFactory().getLogger().log(Logger.ERROR, "[DependencyHandler on " + m_manager.getClassName() + "] Cannot load the nullable class for  " + dep.getMetadata().getServiceSpecification(), e2);
         }
     }
 
@@ -307,7 +306,7 @@
      * @see org.apache.felix.ipojo.Handler#getterCallback(java.lang.String, java.lang.Object)
      */
     public Object getterCallback(String fieldName, Object value) {
-        //TODO : non performant
+        //TODO : non effiecent
         for (int i = 0; i < m_dependencies.length; i++) {
             Dependency dep = m_dependencies[i];
             if (dep.getMetadata().getField().equals(fieldName)) {
@@ -323,14 +322,14 @@
      * @see org.apache.felix.ipojo.Handler#isValid()
      */
     public boolean isValid() {
-        return (m_state == ComponentManagerImpl.VALID);
+        return (m_state == InstanceManager.VALID);
     }
 
     /**
      * @see org.apache.felix.ipojo.Handler#start()
      */
     public void start() {
-        Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Start the dependency handler");
+        m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Start the dependency handler");
 
         // Start the dependencies, for optional dependencies create Nullable class
         for (int i = 0; i < m_dependencies.length; i++) {
@@ -339,7 +338,7 @@
             dep.start();
         }
         // Check the state
-        m_state = m_componentManager.getState();
+        m_state = m_manager.getState();
         checkContext();
     }
 
@@ -373,11 +372,11 @@
             Dependency dep = m_dependencies[i];
             valide = valide & dep.isSatisfied();
             if (!valide) {
-                Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Component Dependencies are not valid : " + dep.getMetadata().getServiceSpecification());
+                m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Component Dependencies are not valid : " + dep.getMetadata().getServiceSpecification());
                 return false;
             }
         }
-        Activator.getLogger().log(Level.INFO, "[DependencyHandler on " + m_componentManager.getComponentMetatada().getClassName() + "] Component Dependencies are valid");
+        m_manager.getFactory().getLogger().log(Logger.INFO, "[DependencyHandler on " + m_manager.getClassName() + "] Component Dependencies are valid");
         return valide;
     }
 

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=487682&r1=487681&r2=487682
==============================================================================
--- 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 Dec 15 13:56:11 2006
@@ -84,7 +84,7 @@
                 MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, name, desc, sign, exc);
 
                 Type returnType = Type.getReturnType(desc);
-                    // TODO : manage the other type primitive
+                    // TODO : manage the other type primitive for Nullable
                     // Primitive type :
                     switch (returnType.getSort()) {
                     case Type.BOOLEAN:

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java?view=diff&rev=487682&r1=487681&r2=487682
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallback.java Fri Dec 15 13:56:11 2006
@@ -19,40 +19,49 @@
 package org.apache.felix.ipojo.handlers.lifecycle.callback;
 
 import java.lang.reflect.InvocationTargetException;
-import org.apache.felix.ipojo.Callback;
+
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.util.Callback;
 
 /**
  * This class is the implementation of callback on lifecycle transition.
  * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
  */
 public class LifecycleCallback {
-
+	
+	 /**
+     * Initial state of the transition.
+     */
+    private int m_initialState;
 
     /**
-     * Metadata of the callback.
+     * Final state of the transition.
      */
-    private LifecycleCallbackMetadata m_metadata;
+    private int m_finalState;
 
     /**
      * Callback object.
      */
     private Callback m_callback;
+    
+    /**
+     * Method called by the callback.
+     */
+    private String m_method;
 
     /**
      * LifecycleCallback constructor.
      * @param hh : the callback handler calling the callback
      * @param hm : the callback metadata
      */
-    public LifecycleCallback(LifecycleCallbackHandler hh, LifecycleCallbackMetadata hm) {
-        m_metadata = hm;
-        m_callback = new Callback(hm.getMethod(), hm.isStatic(), hh.getComponentManager());
-    }
-
-    /**
-     * @return : the metadata of the hook
-     */
-    public LifecycleCallbackMetadata getMetadata() {
-        return m_metadata;
+    public LifecycleCallback(LifecycleCallbackHandler hh, String initialState, String finalState, String method, boolean isStatic) {
+    	if (initialState.equals("VALID")) { m_initialState = InstanceManager.VALID; }
+        if (initialState.equals("INVALID")) { m_initialState = InstanceManager.INVALID; }
+        if (finalState.equals("VALID")) { m_finalState = InstanceManager.VALID; }
+        if (finalState.equals("INVALID")) { m_finalState = InstanceManager.INVALID; }
+        
+        m_method = method;
+        m_callback = new Callback(method, isStatic, hh.getInstanceManager());
     }
 
     /**
@@ -64,5 +73,24 @@
     protected void call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         m_callback.call();
     }
+    
+    /**
+     * @return Returns the m_finalState.
+     */
+    public int getFinalState() {
+        return m_finalState;
+    }
+
+    /**
+     * @return Returns the m_initialState.
+     */
+    public int getInitialState() {
+        return m_initialState;
+    }
+    
+    /**
+     * @return the method called by this callback.
+     */
+    public String getMethod() { return m_method; }
 
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java?view=diff&rev=487682&r1=487681&r2=487682
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/lifecycle/callback/LifecycleCallbackHandler.java Fri Dec 15 13:56:11 2006
@@ -20,12 +20,11 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.util.Dictionary;
-import java.util.logging.Level;
 
-import org.apache.felix.ipojo.Activator;
-import org.apache.felix.ipojo.ComponentManagerImpl;
 import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.util.Logger;
 
 /**
  * Lifecycle callback handler.
@@ -39,14 +38,14 @@
     private LifecycleCallback[] m_callbacks = new LifecycleCallback[0];
 
     /**
-     * State of the component manager (unresolved at the beginning).
+     * State of the instance manager (unresolved at the beginning).
      */
-    private int m_state = ComponentManagerImpl.INVALID;
+    private int m_state = InstanceManager.INVALID;
 
     /**
-     * The component manager.
+     * The instance manager.
      */
-    private ComponentManagerImpl m_componentManager;
+    private InstanceManager m_manager;
 
     /**
      * Add the given Hook to the hook list.
@@ -70,10 +69,10 @@
     }
 
     /**
-     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.ComponentManagerImpl, org.apache.felix.ipojo.metadata.Element)
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.InstanceManager, org.apache.felix.ipojo.metadata.Element)
      */
-    public void configure(ComponentManagerImpl cm, Element metadata, Dictionary configuration) {
-        m_componentManager = cm;
+    public void configure(InstanceManager cm, Element metadata, Dictionary configuration) {
+        m_manager = cm;
         m_callbacks = new LifecycleCallback[0];
 
         Element[] hooksMetadata = metadata.getElements("callback");
@@ -85,12 +84,10 @@
             boolean isStatic = false;
             if (hooksMetadata[i].containsAttribute("isStatic") && hooksMetadata[i].getAttribute("isStatic").equals("true")) { isStatic = true; }
 
-            LifecycleCallbackMetadata hm = new LifecycleCallbackMetadata(initialState, finalState, method, isStatic);
-
-            LifecycleCallback hk = new LifecycleCallback(this, hm);
+            LifecycleCallback hk = new LifecycleCallback(this, initialState, finalState, method, isStatic);
             addCallback(hk);
         }
-        if (m_callbacks.length > 0) { m_componentManager.register(this); }
+        if (m_callbacks.length > 0) { m_manager.register(this); }
     }
 
     /**
@@ -102,31 +99,29 @@
      * @see org.apache.felix.ipojo.Handler#stop()
      */
     public void stop() {
-        m_state = ComponentManagerImpl.INVALID;
+        m_state = InstanceManager.INVALID;
     }
 
     /**
-     * @return the component manager
+     * @return the instance manager
      */
-    protected ComponentManagerImpl getComponentManager() { return m_componentManager; }
+    protected InstanceManager getInstanceManager() { return m_manager; }
 
     /**
      * When the state change call the associated hooks.
      * @see org.apache.felix.ipojo.Handler#stateChanged(int)
      */
     public void stateChanged(int state) {
-        Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] State changed in callback handler, check " + m_callbacks.length + " callbacks. Transition : " + m_state + " -> " + state);
         for (int i = 0; i < m_callbacks.length; i++) {
-            if (m_callbacks[i].getMetadata().getInitialState() == m_state && m_callbacks[i].getMetadata().getFinalState() == state) {
+            if (m_callbacks[i].getInitialState() == m_state && m_callbacks[i].getFinalState() == state) {
                 try {
-                    Activator.getLogger().log(Level.INFO, "[" + m_componentManager.getComponentMetatada().getClassName() + "] Call the callback : " + m_callbacks[i].getMetadata().getMethod());
                     m_callbacks[i].call();
                 } catch (NoSuchMethodException e) {
-                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not found : " + e.getMessage());
+                    m_manager.getFactory().getLogger().log(Logger.ERROR, "[" + m_manager.getClassName() + "] The callback method " + m_callbacks[i].getMethod() + " is not found", e);
                 } catch (IllegalAccessException e) {
-                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " is not accessible : " + e.getMessage());
+                	m_manager.getFactory().getLogger().log(Logger.ERROR, "[" + m_manager.getClassName() + "] The callback method " + m_callbacks[i].getMethod() + " is not accessible", e);
                 } catch (InvocationTargetException e) {
-                    Activator.getLogger().log(Level.SEVERE, "[" + m_componentManager.getComponentMetatada().getClassName() + "] The callback method " + m_callbacks[i].getMetadata().getMethod() + " has throws an exception : " + e.getMessage() + " -> " + e.getCause());
+                	m_manager.getFactory().getLogger().log(Logger.ERROR, "[" + m_manager.getClassName() + "] The callback method " + m_callbacks[i].getMethod() + " has throws an exception : " + e.getMessage() + " -> " + e.getCause());
                 }
             }
         }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java?view=diff&rev=487682&r1=487681&r2=487682
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/Property.java Fri Dec 15 13:56:11 2006
@@ -21,10 +21,9 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.util.logging.Level;
 
-import org.apache.felix.ipojo.Activator;
 import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.util.Logger;
 
 /**
  * Represent a property i.e. a set : [name, type, value].
@@ -46,37 +45,57 @@
      * Value of the property (before we know the type).
      */
     private Object m_value;
+    
+    /**
+     * Field of the property.
+     */
+    private String m_field;
 
     /**
-     * Metadata of the property.
+     * Name of the property.
      */
-    private PropertyMetadata m_metadata;
+    private String m_name;
+
+    /**
+     * Type of the property.
+     */
+    private String m_type;
+
+    /**
+     * String value of the property (initial value).
+     */
+    private String m_initialValue;
 
     /**
      * Property constructor.
      * @param ps : the provided service
      * @param pm : metadata of the property
      */
-    public Property(ProvidedService ps, PropertyMetadata pm) {
+    public Property(ProvidedService ps, String name, String field, String type, String value, Element manipulation) {
         m_providedService = ps;
-        m_metadata = pm;
-
-        // Fix the type of the property if null
-        if (pm.getType() == null) {
-            // If the type is not found, it is a dynamic property
-            Element manipulation = m_providedService.getComponentManager().getComponentMetatada().getMetadata().getElements("Manipulation")[0];
-            String type = null;
-            String field = m_metadata.getField();
-            for (int i = 0; i < manipulation.getElements("Field").length; i++) {
-                if (field.equals(manipulation.getElements("Field")[i].getAttribute("name"))) {
-                    type = manipulation.getElements("Field")[i].getAttribute("type");
-                    break;
+        m_name = name;
+        m_field = field;
+        m_type = type;
+        m_initialValue = value;
+
+        // Dynamic property case :
+        if (m_field != null) {
+            if (m_name == null) { m_name = m_field; }
+        }
+        
+        // Check type if not already set
+        if(m_type == null) {
+        	if(field == null) { ps.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "The property "+ m_name + " has neither type neither field."); return; }
+                for (int j = 0; j < manipulation.getElements("Field").length; j++) {
+                    if (field.equals(manipulation.getElements("Field")[j].getAttribute("name"))) {
+                        m_type = manipulation.getElements("Field")[j].getAttribute("type");
+                        break;
+                    }
                 }
-            }
-            pm.setType(type);
+                if (m_type == null) { m_providedService.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + ps.getInstanceManager().getClassName() + "] A declared property was not found in the class : " + m_field); }
         }
-
-        if (pm.getValue() != null) { setValue(pm.getValue()); }
+        
+        if (m_initialValue != null) { setValue(m_initialValue); }
     }
 
     /**
@@ -88,27 +107,15 @@
      */
     public Property(ProvidedService ps, String name, Object value) {
         m_providedService = ps;
-        m_metadata = new PropertyMetadata(name, null, value.getClass().getName(), null);
+        m_name = name;
+        m_type = value.getClass().getName();
         m_value = value;
     }
 
     /**
      * @return the Object value of the property
      */
-    protected Object get() {
-        if (m_value == null) {
-            Activator.getLogger().log(Level.INFO, "[" + m_providedService.getComponentManager().getComponentMetatada().getClassName() + "] A property " + m_metadata.getName() + " can not be returned : no value assigned");
-        }
-        return m_value;
-    }
-
-
-    /**
-     * @return the property metadata.
-     */
-    public PropertyMetadata getMetadata() {
-        return m_metadata;
-    }
+    protected Object get() { return m_value; }
 
     /**
      * This method is automaticaly called when the value of the property is changed.
@@ -143,13 +150,10 @@
      * @param value : value of the property (String)
      */
     private void setValue(String value) {
-        String type = m_metadata.getType();
-
-        Activator.getLogger().log(Level.INFO, "[" + m_providedService.getComponentManager().getComponentMetatada().getClassName() + "] Set the value of the property " + m_metadata.getName() + " [" + m_metadata.getType() + "] " + " with the value : " + value);
 
         // Array :
-        if (type.endsWith("[]")) {
-            String internalType = type.substring(0, type.length() - 2);
+        if (m_type.endsWith("[]")) {
+            String internalType = m_type.substring(0, m_type.length() - 2);
             value = value.substring(1, value.length() - 1);
             String[] values = value.split(",");
             setArrayValue(internalType, values);
@@ -157,40 +161,39 @@
         }
 
         // Simple :
-
-        if (type.equals("string") || type.equals("String")) { m_value = new String(value); return; }
-        if (type.equals("boolean")) { m_value = new Boolean(value); return; }
-        if (type.equals("byte")) { m_value = new Byte(value); return; }
-        if (type.equals("short")) { m_value = new Short(value); return; }
-        if (type.equals("int")) { m_value = new Integer(value); return; }
-        if (type.equals("long")) { m_value = new Long(value); return; }
-        if (type.equals("float")) { m_value = new Float(value); return; }
-        if (type.equals("double")) { m_value = new Double(value); return; }
+        if (m_type.equals("string") || m_type.equals("String")) { m_value = new String(value); return; }
+        if (m_type.equals("boolean")) { m_value = new Boolean(value); return; }
+        if (m_type.equals("byte")) { m_value = new Byte(value); return; }
+        if (m_type.equals("short")) { m_value = new Short(value); return; }
+        if (m_type.equals("int")) { m_value = new Integer(value); return; }
+        if (m_type.equals("long")) { m_value = new Long(value); return; }
+        if (m_type.equals("float")) { m_value = new Float(value); return; }
+        if (m_type.equals("double")) { m_value = new Double(value); 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 {
-            Class c = m_providedService.getComponentManager().getContext().getBundle().loadClass(type);
+            Class c = m_providedService.getInstanceManager().getContext().getBundle().loadClass(m_type);
             //Class string = m_providedService.getComponentManager().getContext().getBundle().loadClass("java.lang.String");
             Constructor cst = c.getConstructor(new Class[] {String.class});
             m_value = cst.newInstance(new Object[] {value});
         } catch (ClassNotFoundException e) {
-            System.err.println("Class not found exception in setValue on " + type);
+            System.err.println("Class not found exception in setValue on " + m_type);
             e.printStackTrace();
         } catch (SecurityException e) {
             e.printStackTrace();
         } catch (NoSuchMethodException e) {
-            System.err.println("Constructor not found exeption in setValue on " + type);
+            System.err.println("Constructor not found exeption in setValue on " + m_type);
             e.printStackTrace();
         } catch (IllegalArgumentException e) {
-            System.err.println("Argument problem to call the constructor of the type " + type);
+            System.err.println("Argument problem to call the constructor of the type " + m_type);
             e.printStackTrace();
         } catch (InstantiationException e) {
-            System.err.println("Instantiation problem  " + type);
+            System.err.println("Instantiation problem  " + m_type);
             e.printStackTrace();
         } catch (IllegalAccessException e) {
             e.printStackTrace();
         } catch (InvocationTargetException e) {
-            System.err.println("Invocation problem " + type);
+            System.err.println("Invocation problem " + m_type);
             e.printStackTrace();
         }
     }
@@ -245,7 +248,7 @@
 
         // Else it is a neither a primitive type neither a String -> create the object by calling a constructor with a string in argument.
         try {
-            Class c = m_providedService.getComponentManager().getContext().getBundle().loadClass(internalType);
+            Class c = m_providedService.getInstanceManager().getContext().getBundle().loadClass(internalType);
             Constructor cst = c.getConstructor(new Class[] {String.class});
             Object[] ob = (Object[]) Array.newInstance(c, values.length);
             for (int i = 0; i < values.length; i++) {
@@ -279,4 +282,31 @@
      * @return the value of the property.
      */
     public Object getValue() { return m_value; }
+    
+    /**
+     * @return the name of the property
+     */
+    public String getName() { return m_name; }
+    
+    /**
+     * @return the field name of the property (null if the property has no field).
+     */
+    protected String getField() { return m_field; }
+
+	/**
+	 * Set the type of the property.
+	 * @param type : the type to attached to the property
+	 */
+	public void setType(String type) { m_type = type; }
+	
+	/**
+	 * @return the type of the property.
+	 */
+	public String getType() { return m_type; }
+
+	/**
+	 * @return the initial value of the property.
+	 */
+	public String getInitialValue() { return m_initialValue; }
+	
 }

Modified: incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java?view=diff&rev=487682&r1=487681&r2=487682
==============================================================================
--- incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java (original)
+++ incubator/felix/trunk/ipojo/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java Fri Dec 15 13:56:11 2006
@@ -21,10 +21,9 @@
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Properties;
-import java.util.logging.Level;
 
-import org.apache.felix.ipojo.ComponentManagerImpl;
-import org.apache.felix.ipojo.Activator;
+import org.apache.felix.ipojo.InstanceManager;
+import org.apache.felix.ipojo.util.Logger;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceReference;
@@ -58,6 +57,16 @@
     public static final int SERVICE_FACTORY = 1;
 
     /**
+     * At this time, it is only the java interface full name.
+     */
+    private String[] m_serviceSpecification = new String[0];
+
+    /**
+     * Factory policy.
+     */
+    private int m_factoryPolicy = SINGLETON_FACTORY;
+
+    /**
      * The service registration.
      * is null when the service is not registred.
      * m_serviceRegistration : ServiceRegistration
@@ -65,17 +74,12 @@
     private ServiceRegistration m_serviceRegistration;
 
     /**
-     * Link to the component manager.
-     * m_handler : ComponentManager
+     * Link to the owner handler.
+     * m_handler : Provided Service Handler
      */
     private ProvidedServiceHandler m_handler;
 
     /**
-     * Provided service metadata.
-     */
-    private ProvidedServiceMetadata m_metadata;
-
-    /**
      * State of the provided service.
      */
     private int m_state;
@@ -91,19 +95,26 @@
      * @param handler : the provided service handler.
      * @param psm : the provided service metadata.
      */
-    public ProvidedService(ProvidedServiceHandler handler, ProvidedServiceMetadata psm) {
+    public ProvidedService(ProvidedServiceHandler handler, String[] specification, int factoryPolicy) {
         m_handler = handler;
-        m_metadata = psm;
-        for (int i = 0; i < psm.getProperties().length; i++) {
-            Property prop = new Property(this, ((PropertyMetadata) psm.getProperties()[i]));
-            addProperty(prop);
-        }
+        
+        m_serviceSpecification = specification;
+        m_factoryPolicy = factoryPolicy;
+        
         //Add service pid and factory pid
-        //TODO : test this 
-        PropertyMetadata pid_meta = new PropertyMetadata(org.osgi.framework.Constants.SERVICE_PID, null, "java.lang.String", handler.getComponentManager().getComponentName()); 
-        PropertyMetadata factory_meta = new PropertyMetadata("factory.pid", null, "java.lang.String", handler.getComponentManager().getFactory().getFactoryName());
-        addProperty(new Property(this, pid_meta));
-        addProperty(new Property(this, factory_meta));
+        addProperty(new Property(this, org.osgi.framework.Constants.SERVICE_PID, handler.getInstanceManager().getInstanceName()));
+        addProperty(new Property(this, "factory.pid", handler.getInstanceManager().getFactory().getFactoryName()));
+    }
+    
+    //TODO check if we need to erase previous props or add to the previous props.
+    /**
+     * Add properties to the provided service.
+     * @param props : the properties to attached to the service registration
+     */
+    protected void setProperties(Property[] props) { 
+    	for(int i = 0; i < props.length; i++) {
+    		addProperty(props[i]);
+    	}
     }
 
     /**
@@ -131,7 +142,7 @@
     private synchronized void removeProperty(String name) {
         int idx = -1;
         for (int i = 0; i < m_properties.length; i++) {
-            if (m_properties[i].getMetadata().getName() == name) { idx = i; break; }
+            if (m_properties[i].getName() == name) { idx = i; break; }
         }
 
         if (idx >= 0) {
@@ -163,16 +174,16 @@
      */
     public Object getService(Bundle bundle, ServiceRegistration registration) {
 
-        switch(m_metadata.getFactoryPolicy()) {
+        switch(m_factoryPolicy) {
 
             case SINGLETON_FACTORY :
-                return m_handler.getComponentManager().getInstance();
+                return m_handler.getInstanceManager().getPojoObject();
 
             case SERVICE_FACTORY :
-                return m_handler.getComponentManager().createInstance();
+                return m_handler.getInstanceManager().createPojoObject();
 
             default :
-                Activator.getLogger().log(Level.SEVERE, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Unknown factory policy for " + m_metadata.getServiceSpecification() + " : " + m_metadata.getFactoryPolicy());
+                m_handler.getInstanceManager().getFactory().getLogger().log(Logger.ERROR, "[" + m_handler.getInstanceManager().getClassName() + "] Unknown factory policy for " + m_serviceSpecification + " : " + m_factoryPolicy);
             return null;
         }
 
@@ -189,24 +200,6 @@
         //Nothing to do
     }
 
-//  /**
-//  * Validate the service dependencies of the current provided service.
-//  * @return true if the service dependencies are valid
-//  */
-//  public boolean validate() {
-//  boolean valide = true;
-//  for (int i = 0; i < m_dependencies.length; i++) {
-//  Dependency dep = m_dependencies[i];
-//  valide = valide & dep.isSatisfied();
-//  if (!valide) {
-//  ComponentManager.getLogger().log(Level.INFO, "Service Dependency  for " + m_interface + " not valid : " + dep.getInterface());
-//  return false;
-//  }
-//  }
-//  ComponentManager.getLogger().log(Level.INFO, "Service dependencies for " + m_interface + " are valid");
-//  return valide;
-//  }
-
     /**
      * Register the service.
      * The service object must be able to serve this service.
@@ -215,18 +208,17 @@
     protected void registerService() {
         if (m_state != REGISTERED) {
             String spec = "";
-            for (int i = 0; i < m_metadata.getServiceSpecification().length; i++) {
-                spec = spec + m_metadata.getServiceSpecification()[i] + ", ";
+            for (int i = 0; i < m_serviceSpecification.length; i++) {
+                spec = spec + m_serviceSpecification[i] + ", ";
             }
-            Activator.getLogger().log(Level.INFO, "[" + m_handler.getComponentManager().getComponentMetatada().getClassName() + "] Register the service : " + spec);
             // Contruct the service properties list
             Properties serviceProperties = getServiceProperties();
 
             m_state = REGISTERED;
             synchronized (this) {
                 m_serviceRegistration =
-                    m_handler.getComponentManager().getContext().registerService(
-                            m_metadata.getServiceSpecification(), this, serviceProperties);
+                    m_handler.getInstanceManager().getContext().registerService(
+                    		m_serviceSpecification, this, serviceProperties);
             }
         }
     }
@@ -252,10 +244,10 @@
     }
 
     /**
-     * @return the component manager.
+     * @return the instance manager.
      */
-    protected ComponentManagerImpl getComponentManager() {
-        return m_handler.getComponentManager();
+    protected InstanceManager getInstanceManager() {
+        return m_handler.getInstanceManager();
     }
 
     /**
@@ -268,7 +260,7 @@
         Properties serviceProperties = new Properties();
         for (int i = 0; i < m_properties.length; i++) {
             if (m_properties[i].get() != null) {
-                serviceProperties.put(m_properties[i].getMetadata().getName(), m_properties[i].get().toString());
+                serviceProperties.put(m_properties[i].getName(), m_properties[i].get());
             }
         }
         return serviceProperties;
@@ -299,13 +291,6 @@
     }
 
     /**
-     * @return the propvided service metadata.
-     */
-    public ProvidedServiceMetadata getMetadata() {
-        return m_metadata;
-    }
-
-    /**
      * Add properties to the list.
      * @param props : properties to add
      */
@@ -332,5 +317,10 @@
         }
         update();
     }
+
+	/**
+	 * @return the list of provided service specifications (i.e. java interface).
+	 */
+	public String[] getServiceSpecification() { return m_serviceSpecification; }
 
 }



Mime
View raw message