geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r767088 - in /geronimo/sandbox/blueprint/blueprint-core: pom.xml src/main/java/org/apache/geronimo/blueprint/Activator.java
Date Tue, 21 Apr 2009 09:41:10 GMT
Author: gnodet
Date: Tue Apr 21 09:41:10 2009
New Revision: 767088

URL: http://svn.apache.org/viewvc?rev=767088&view=rev
Log:
Use slf4j for logging

Modified:
    geronimo/sandbox/blueprint/blueprint-core/pom.xml
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java

Modified: geronimo/sandbox/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/pom.xml?rev=767088&r1=767087&r2=767088&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/pom.xml (original)
+++ geronimo/sandbox/blueprint/blueprint-core/pom.xml Tue Apr 21 09:41:10 2009
@@ -57,6 +57,11 @@
           <artifactId>asm-all</artifactId>
           <version>3.1</version>
       </dependency>
+      <dependency>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-api</artifactId>
+          <version>1.5.6</version>
+      </dependency>
   </dependencies>
 
     <build>

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java?rev=767088&r1=767087&r2=767088&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/Activator.java
Tue Apr 21 09:41:10 2009
@@ -38,6 +38,8 @@
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.SynchronousBundleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * TODO: javadoc
@@ -49,13 +51,15 @@
  */
 public class Activator implements BundleActivator, SynchronousBundleListener {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
     private final ExecutorService executors = Executors.newSingleThreadExecutor();
     private final Map<Bundle, ModuleContextImpl> contextMap = new HashMap<Bundle,
ModuleContextImpl>();
     private ModuleContextEventSender sender;
     private NamespaceHandlerRegistry handlers;
 
     public void start(BundleContext context) {
-        System.out.println("Starting to listen for bundle events.");
+        LOGGER.debug("Starting blueprint extender...");
         context.addBundleListener(this);
 
         sender = new DefaultModuleContextEventSender(context);
@@ -67,19 +71,24 @@
                 checkBundle(b);
             }
         }
+        LOGGER.debug("Blueprint extender started");
     }
 
 
     public void stop(BundleContext context) {
+        LOGGER.debug("Stopping blueprint extender...");
+        List<Bundle> bundles = new ArrayList<Bundle>(contextMap.keySet());
+        for (Bundle bundle : bundles) {
+            destroyContext(bundle);
+        }
         // TODO: destroy all contexts
         context.removeBundleListener(this);
         this.sender.destroy();
         this.handlers.destroy();
-        System.out.println("Stopped listening for bundle events.");
+        LOGGER.debug("Blueprint extender stopped");
     }
 
     public void bundleChanged(BundleEvent event) {
-        System.out.println("bundle changed:" + event.getBundle().getSymbolicName() + "  "+
event.getType());
         if (event.getType() == BundleEvent.STARTED) {
             checkBundle(event.getBundle());
         } else if (event.getType() == BundleEvent.STOPPING) {
@@ -90,12 +99,13 @@
     private void destroyContext(Bundle bundle) {
         ModuleContextImpl moduleContext = contextMap.remove(bundle);
         if (moduleContext != null) {
+            LOGGER.debug("Destroying ModuleContext for bundle " + bundle.getSymbolicName());
             moduleContext.destroy();
         }
     }
     
     private void checkBundle(Bundle bundle) {
-        System.out.println("Checking: " + bundle.getSymbolicName());
+        LOGGER.debug("Scanning bundle " + bundle.getSymbolicName() + " for blueprint application");
 
         List<URL> urls = new ArrayList<URL>();
         Dictionary headers = bundle.getHeaders();
@@ -119,6 +129,7 @@
             }
         }
         if (!urls.isEmpty()) {
+            LOGGER.debug("Found blueprint application in bundle " + bundle.getSymbolicName()
+ " with urls: " + urls);
             final ModuleContextImpl moduleContext = new ModuleContextImpl(bundle.getBundleContext(),
sender, handlers, urls);
             contextMap.put(bundle, moduleContext);
             executors.submit(new Runnable() {
@@ -126,6 +137,8 @@
                     moduleContext.create();
                 }
             });
+        } else {
+            LOGGER.debug("No blueprint application found in bundle " + bundle.getSymbolicName());
         }
     }
 



Mime
View raw message