Author: clement
Date: Thu Aug 27 11:45:53 2009
New Revision: 808377

URL: http://svn.apache.org/viewvc?rev=808377&view=rev
Log:
Fix issue Felix-1533:
avoid the potential deadlock when the OSGi frameowrk is stopping

Fix issue Felix-1532:
Add a new property to set the log level (beginning by an upper case)

Modified:
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
    
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
    felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java
    felix/trunk/ipojo/tests/integration-tests/pom.xml
    felix/trunk/ipojo/tests/pom.xml

Modified: 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java?rev=808377&r1=808376&r2=808377&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java 
(original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/Extender.java 
Thu Aug 27 11:45:53 2009
@@ -116,7 +116,7 @@
      * @param event the bundle event.
      * @see 
org.osgi.framework.BundleListener#bundleChanged(org.osgi.framework.BundleEvent)
      */
-    public synchronized void bundleChanged(final BundleEvent event) {
+    public void bundleChanged(final BundleEvent event) {
         if (event.getBundle() == m_bundle) { return; }
 
         switch (event.getType()) {
@@ -304,6 +304,8 @@
                 }
             }
         }
+        
+        m_logger.log(Logger.INFO, "iPOJO Runtime started");
     }
 
     /**
@@ -338,6 +340,8 @@
 
         m_factoryTypes = null;
         m_creator = null;
+        
+        m_logger.log(Logger.INFO, "iPOJO Runtime stopped");
     }
     
     /**

Modified: 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java?rev=808377&r1=808376&r2=808377&view=diff
==============================================================================
--- 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java 
(original)
+++ 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/IPojoFactory.java 
Thu Aug 27 11:45:53 2009
@@ -165,6 +165,8 @@
         }
 
         m_requiredHandlers = getRequiredHandlerList(); // Call sub-class to 
get the list of required handlers.
+        
+        m_logger.log(Logger.INFO, "New factory created : " + m_factoryName);
     }
 
     /**
@@ -298,11 +300,14 @@
             ComponentInstance instance = createInstance(configuration, 
context, handlers); // This method is called with the lock.
             INSTANCE_NAME.add(name);
             m_componentInstances.put(name, instance);
+            m_logger.log(Logger.INFO, "Instance " + name + " from factory " + 
m_factoryName + " created");
             return instance;
         } catch (ConfigurationException e) {
             m_logger.log(Logger.ERROR, e.getMessage());
             throw new ConfigurationException(e.getMessage(), m_factoryName);
         }
+        
+
     }
 
     /**
@@ -539,6 +544,9 @@
         m_described = false;
         m_componentDesc = null;
         m_componentInstances.clear();
+        
+        m_logger.log(Logger.INFO, "Factory " + m_factoryName + " stopped");
+
     }
 
     /**
@@ -581,6 +589,9 @@
                     
m_context.registerService(m_componentDesc.getFactoryInterfacesToPublish(), 
this, m_componentDesc
                             .getPropertiesToPublish());
         }
+        
+        m_logger.log(Logger.INFO, "Factory " + m_factoryName + " started");
+
     }
 
     /**

Modified: 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java?rev=808377&r1=808376&r2=808377&view=diff
==============================================================================
--- 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java 
(original)
+++ 
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Logger.java 
Thu Aug 27 11:45:53 2009
@@ -34,7 +34,13 @@
     /**
      * The iPOJO default log level property.
      */
-    public static final String IPOJO_LOG_LEVEL = "ipojo.log.level";
+    public static final String IPOJO_LOG_LEVEL_PROP = "ipojo.log.level";
+    
+    /**
+     * iPOJO log level manifest header.
+     * Use an upper case to support bnd.
+     */
+    public static final String IPOJO_LOG_LEVEL_HEADER = "IPOJO-log-level";
 
     /**
      * The Log Level ERROR.
@@ -257,14 +263,19 @@
      */
     private static int getDefaultLevel(BundleContext context) {
         // First check in the framework and in the system properties
-        String level = context.getProperty(IPOJO_LOG_LEVEL);
+        String level = context.getProperty(IPOJO_LOG_LEVEL_PROP);
         
-        // If null, look in bundle manifest
+        // If null, look in the bundle manifest
         if (level == null) {
-            String key = IPOJO_LOG_LEVEL.replace('.', '-');
+            String key = IPOJO_LOG_LEVEL_PROP.replace('.', '-');
             level = (String) context.getBundle().getHeaders().get(key);
         }
         
+        // if still null try the second header
+        if (level == null) {
+            level = (String) 
context.getBundle().getHeaders().get(IPOJO_LOG_LEVEL_HEADER);
+        }
+                
         if (level != null) {
             if (level.equalsIgnoreCase("info")) {
                 return INFO;

Modified: felix/trunk/ipojo/tests/integration-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/integration-tests/pom.xml?rev=808377&r1=808376&r2=808377&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/integration-tests/pom.xml (original)
+++ felix/trunk/ipojo/tests/integration-tests/pom.xml Thu Aug 27 11:45:53 2009
@@ -242,7 +242,7 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.configadmin</artifactId>
-      <version>1.0.10</version>
+      <version>1.2.0</version>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: felix/trunk/ipojo/tests/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/pom.xml?rev=808377&r1=808376&r2=808377&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/pom.xml (original)
+++ felix/trunk/ipojo/tests/pom.xml Thu Aug 27 11:45:53 2009
@@ -42,6 +42,7 @@
   <module>core/handler</module>
   <module>core/external-handlers</module>
   <module>core/bad-configurations</module>
+  <module>core/logger</module>
   <module>composite/composite-runtime</module>
   <module>composite/import-export</module>
   <module>composite/service-instance</module>


Reply via email to