Author: clement
Date: Thu Jul  3 07:46:02 2008
New Revision: 673693

URL: http://svn.apache.org/viewvc?rev=673693&view=rev
Log:
Fix the Felix-622 issue
This change avoid iPOJO to use twice the same factory to fulfill a service 
instance.

Modified:
    
felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java

Modified: 
felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java?rev=673693&r1=673692&r2=673693&view=diff
==============================================================================
--- 
felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
 (original)
+++ 
felix/trunk/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/instantiator/SvcInstance.java
 Thu Jul  3 07:46:02 2008
@@ -104,6 +104,7 @@
             ServiceReference ref = (ServiceReference) iterator.next();
             Object object = m_factories.get(ref);
             if (object != null) {
+                m_handler.info("Dispose a service instance when stopping the 
handler " + ((ComponentInstance) object).getInstanceName());
                 ((ComponentInstance) object).dispose();
             }
         }
@@ -142,6 +143,7 @@
         }
         ComponentInstance instance = null;
         instance = factory.createComponentInstance(props);
+        m_handler.info("Creation of a service instance " + 
instance.getInstanceName());
         return instance;
     }
 
@@ -234,8 +236,13 @@
         // The given factory matches.
         try {
             Factory fact = (Factory) getService(ref);
-            ComponentInstance instance = createInstance(fact);
-            m_factories.put(ref, instance);
+            if (m_factories.get(ref) == null) {
+               ComponentInstance instance = createInstance(fact);
+               m_factories.put(ref, instance);
+            } else {
+               m_handler.info("An arriving factory is already used, ignore the 
creation : " + fact.getName());
+            }
+            
         } catch (UnacceptableConfiguration e) {
             m_handler.error("A matching factory refuse the actual 
configuration : " + e.getMessage());
             m_handler.getCompositeManager().stop();
@@ -260,6 +267,7 @@
         // Remove the reference is contained
         Object instance = m_factories.remove(ref);
         if (instance != null) {
+               m_handler.info("Dispose the instance (departure of the factory) 
" + ((ComponentInstance) instance).getInstanceName());
             ((ComponentInstance) instance).dispose();
         }
     }


Reply via email to