directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r280040 [2/2] - in /directory/sandbox/trunk/osgi-spec/trunk/configuration: ./ src/main/java/org/apache/configuration/ src/main/java/org/apache/configuration/impl/ src/main/java/org/apache/configuration/store/
Date Sat, 10 Sep 2005 21:05:17 GMT
Copied: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/UpdateQueue.java
(from r279417, directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/UpdateQueue.java)
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/UpdateQueue.java?p2=directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/UpdateQueue.java&p1=directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/UpdateQueue.java&r1=279417&r2=280040&rev=280040&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/UpdateQueue.java
(original)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/UpdateQueue.java
Sat Sep 10 14:05:06 2005
@@ -15,11 +15,13 @@
  *
  */
 
-package org.apache.configuration;
+package org.apache.configuration.impl;
 
 import java.util.Vector;
 
 import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class is responsible for dispatching configurations to ManagedService(Factories).
@@ -27,6 +29,9 @@
  */
 final class UpdateQueue implements Runnable
 {
+    /** the log for this class */
+    private static final Logger log = LoggerFactory.getLogger( UpdateQueue.class );
+
     /**
      * The PluginManager to use.
      */
@@ -50,7 +55,7 @@
     /**
      * Construct an UpdateQueue given a BundleContext.
      * 
-     * @param tracker The BundleContext to use.
+     * @param pm The PluginManager to use.
      */
     UpdateQueue( PluginManager pm )
     {
@@ -64,47 +69,47 @@
     {
         while ( true )
         {
-            if ( doUpdateQueueLogging() )
+            if ( log.isDebugEnabled() )
             {
-                Activator.LOG.info( "[UpdateQueue] Getting next Update from queue" );
+                log.info( "Getting next Update from queue" );
             }
-            
+
             Update update = dequeue();
-            
+
             if ( update == null )
             {
-                if ( doUpdateQueueLogging() )
+                if ( log.isDebugEnabled() )
                 {
-                    Activator.LOG.info( "[UpdateQueue] Got null Update from queue" );
+                    log.info( "Got null Update from queue" );
                 }
                 return;
             }
-            
-            if ( doUpdateQueueLogging() )
+
+            if ( log.isDebugEnabled() )
             {
-                Activator.LOG.info( "[UpdateQueue] Got an Update from queue" );
+                log.info( "Got an Update from queue" );
             }
             try
             {
-                if (doUpdateQueueLogging())
+                if ( log.isDebugEnabled() )
                 {
-                    Activator.LOG.info( "[UpdateQueue] Calling Update.doUpdate" );
+                    log.info( "Calling Update.doUpdate" );
                 }
-                
-                update.doUpdate(pm);
-                
-                if (doUpdateQueueLogging())
+
+                update.doUpdate( pm );
+
+                if ( log.isDebugEnabled() )
                 {
-                    Activator.LOG.info( "[UpdateQueue] Update.doUpdate returned" );
+                    log.info( "Update.doUpdate returned" );
                 }
             }
-            catch (ConfigurationException ce)
+            catch ( ConfigurationException ce )
             {
-                Activator.LOG.error("[CM] Error in configuration for " + update.pid, ce);
+                log.error( "Error in configuration for " + update.pid, ce );
             }
-            catch (Exception e)
+            catch ( Exception e )
             {
-                Activator.LOG.error("[CM] Error while updating " + update.pid, e);
+                log.error( "Error while updating " + update.pid, e );
             }
         }
     }
@@ -113,21 +118,19 @@
      * Add an entry to the end of the queue.
      * 
      * @param update The Update to add to the queue.
-     * @throws java.lang.Exception If given a null argument.
      */
     public synchronized void enqueue( Update update )
     {
         if ( update == null )
         {
-            throw new IllegalArgumentException(
-                    "ConfigurationDispatcher.enqueue(Update) needs a non-null argument."
);
+            throw new IllegalArgumentException( "ConfigurationDispatcher.enqueue(Update)
needs a non-null argument." );
         }
-        
-        if ( doUpdateQueueLogging() )
+
+        if ( log.isDebugEnabled() )
         {
-            Activator.LOG.info( "[UpdateQueue] Adding update for " + update.pid + " to queue"
);
+            log.info( "Adding update for " + update.pid + " to queue" );
         }
-        
+
         queue.addElement( update );
         attachNewThreadIfNeccesary();
         notifyAll();
@@ -145,29 +148,29 @@
         {
             try
             {
-                if ( doUpdateQueueLogging() )
+                if ( log.isDebugEnabled() )
                 {
-                    Activator.LOG.info( "[UpdateQueue] Queue is empty. Waiting 5000 ms" );
+                    log.info( "Queue is empty. Waiting 5000 ms" );
                 }
                 wait( 5000 );
             }
-            catch (InterruptedException ignored)
+            catch ( InterruptedException ignored )
             {
             }
         }
         if ( queue.isEmpty() )
         {
-            if ( doUpdateQueueLogging() )
+            if ( log.isDebugEnabled() )
             {
-                Activator.LOG.info( "[UpdateQueue] Queue is still empty. Detaching thread."
);
+                log.info( "Queue is still empty. Detaching thread." );
             }
-            
+
             detachCurrentThread();
             return null;
         }
-        
-        Update u = (Update) queue.elementAt(0);
-        queue.removeElementAt(0);
+
+        Update u = (Update) queue.elementAt( 0 );
+        queue.removeElementAt( 0 );
         return u;
     }
 
@@ -177,11 +180,11 @@
         {
             if ( thread == null )
             {
-                if ( doUpdateQueueLogging() )
+                if ( log.isDebugEnabled() )
                 {
-                    Activator.LOG.info( "[UpdateQueue] Attaching new thread." );
+                    log.info( "Attaching new thread." );
                 }
-                
+
                 thread = new Thread( this );
                 thread.setDaemon( true );
                 thread.start();
@@ -193,18 +196,12 @@
     {
         synchronized ( threadLock )
         {
-            if ( doUpdateQueueLogging() )
+            if ( log.isDebugEnabled() )
             {
-                Activator.LOG.info( "[UpdateQueue] Detaching thread because queue is empty."
);
+                log.info( "Detaching thread because queue is empty." );
             }
-            
+
             thread = null;
         }
     }
-
-    boolean doUpdateQueueLogging()
-    {
-        return true;
-    }
 }
-



Mime
View raw message