User: starksm 
  Date: 01/09/11 11:35:04

  Modified:    src/main/org/jboss/system Info.java ServiceConfigurator.java
                        ServiceController.java ServiceMBeanSupport.java
  Log:
  Convert all logging to org.jboss.logging.Logger which is a subclass of
  org.apache.log4j.Category.
  
  Revision  Changes    Path
  1.3       +18 -20    jboss/src/main/org/jboss/system/Info.java
  
  Index: Info.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/Info.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Info.java 2001/09/08 00:53:56     1.2
  +++ Info.java 2001/09/11 18:35:03     1.3
  @@ -12,8 +12,7 @@
   import javax.management.MBeanServer;
   import javax.management.MBeanRegistration;
   
  -// Part of the boot, don't use log4j
  -import org.jboss.logging.Log;
  +import org.jboss.logging.Logger;
   
   /**
    * A simple mbean that dumps out info like the system properties, etc.
  @@ -23,14 +22,16 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>.
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason Dillon</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class Info
      implements InfoMBean, MBeanRegistration
   {
      // Constants -----------------------------------------------------
  -     
  +
      // Attributes ----------------------------------------------------
  +   /** Instance logger. */
  +   private static Logger log = Logger.create("GPA");
   
      //
      // System information
  @@ -50,12 +51,8 @@
      protected String configurationDirectory;
      protected String patchDirectory;
      protected String jbossVersion;
  -     
  -   /** Instance logger. */
  -   private Log log = Log.createLog("GPA");
  -     
      // Static --------------------------------------------------------
  -     
  +
      // Constructors --------------------------------------------------
        
      // Public --------------------------------------------------------
  @@ -83,32 +80,33 @@
         libraryDirectory = System.getProperty("jboss.system.libraryDirectory");
         patchDirectory = System.getProperty("jboss.system.patchDirectory");
                
  -      log.log("General Purpose Architecture [GPA]");
  +      log.info("General Purpose Architecture [GPA]");
                
         // Dump out basic info as INFO priority msgs
  -      log.log("Java version: " +
  +      log.info("Java version: " +
                 javaVersion + "," +
                 javaVendor);
  -      log.log("Java VM: " +
  +      log.info("Java VM: " +
                 javaVMName + " " +
                 javaVMVersion + "," +
                 javaVMVendor);
  -      log.log("OS-System: " +
  +      log.info("OS-System: " +
                 osName + " " +
                 osVersion + "," +
                 osArch);
  -      log.log("JBoss Version : " + jbossVersion);
  -      log.log("localDir : " + jbossLocalHomeDirectory);
  -      log.log("installationURL : "+ installationURL);
  -      log.log("configuration : " + configurationDirectory);
  -      log.log("libraries : "+libraryDirectory);
  +      log.info("JBoss Version : " + jbossVersion);
  +      log.info("localDir : " + jbossLocalHomeDirectory);
  +      log.info("installationURL : "+ installationURL);
  +      log.info("configuration : " + configurationDirectory);
  +      log.info("libraries : "+libraryDirectory);
         //        log.info("local patch directory " + patchDirectory);
  -      log.log("Oh, and remember we love you");
  +      log.info("Oh, and remember we love you");
                
         // dump out the entire system properties if debug is enabled
         log.debug("+++ Full System Properties Dump");
         Enumeration names= System.getProperties().propertyNames();
  -      while (names.hasMoreElements()) {
  +      while (names.hasMoreElements())
  +      {
            String pname= (String) names.nextElement();
            log.debug(pname + ": " + System.getProperty(pname));
         }
  
  
  
  1.4       +3 -3      jboss/src/main/org/jboss/system/ServiceConfigurator.java
  
  Index: ServiceConfigurator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceConfigurator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServiceConfigurator.java  2001/09/08 00:53:57     1.3
  +++ ServiceConfigurator.java  2001/09/11 18:35:03     1.4
  @@ -32,7 +32,7 @@
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Document;
   
  -import org.jboss.logging.Log;
  +import org.jboss.logging.Logger;
   import org.jboss.util.DOMWriter;
   
   /**
  @@ -40,7 +40,7 @@
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    *
    * <p><b>20010830 marc fleury:</b>
    * <ul>
  @@ -71,7 +71,7 @@
      private MBeanServer server;
   
      /** The instance logger. */
  -   private Log log = Log.createLog("Configurator");
  +   private static Logger log = Logger.create("Configurator");
        
      // Constructors --------------------------------------------------
        
  
  
  
  1.6       +22 -27    jboss/src/main/org/jboss/system/ServiceController.java
  
  Index: ServiceController.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceController.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ServiceController.java    2001/09/11 05:23:40     1.5
  +++ ServiceController.java    2001/09/11 18:35:03     1.6
  @@ -31,8 +31,6 @@
   import javax.management.RuntimeMBeanException;
   import javax.management.RuntimeOperationsException;
   
  -import org.jboss.logging.log4j.JBossCategory;
  -
   import org.w3c.dom.Element;
   
   /**
  @@ -42,7 +40,7 @@
    * @see org.jboss.system.Service
    * @author <a href="mailto:[EMAIL PROTECTED]";>Marc Fleury</a>
    * @author <a href="[EMAIL PROTECTED]">David Jencks</a>
  - * @version $Revision: 1.5 $ <p>
  + * @version $Revision: 1.6 $ <p>
    *
    * <b>Revisions:</b> <p>
    *
  @@ -87,9 +85,6 @@
      /** The map keeps the list of objectNames to services. */
      Map nameToServiceMap = new HashMap();
   
  -   JBossCategory category = (JBossCategory)
  -      JBossCategory.getInstance(getClass().getName());
  -
      // Static --------------------------------------------------------
   
      // Constructors --------------------------------------------------
  @@ -175,7 +170,7 @@
         //
         catch (Throwable e)
         {
  -         category.error("Could not create MBean: " + objectName, e);
  +         log.error("Could not create MBean: " + objectName, e);
            if (e instanceof Exception)
               throw (Exception)e;
            if (e instanceof Error)
  @@ -190,7 +185,7 @@
         }
         catch (ConfigurationException e)
         {
  -         category.error("Could not configure MBean: " + objectName, e);
  +         log.error("Could not configure MBean: " + objectName, e);
            throw e;
         }
   
  @@ -234,15 +229,15 @@
       */
      public void undeploy(ObjectName objectName) throws Exception
      {
  -      if (category.isDebugEnabled()) {
  -         category.debug("undeploying " + objectName + "from server");
  +      if (log.isDebugEnabled()) {
  +         log.debug("undeploying " + objectName + "from server");
         }
         
         // Do we have a deployed MBean?
         if (server.isRegistered(objectName))
         {
  -         if (category.isDebugEnabled()) {
  -            category.debug("undeploying " + objectName + "from server");
  +         if (log.isDebugEnabled()) {
  +            log.debug("undeploying " + objectName + "from server");
            }
            
            //Remove from local maps
  @@ -277,7 +272,7 @@
         creator = new ServiceCreator(server);
         configurator = new ServiceConfigurator(server);
   
  -      category.info("Controller MBean online");
  +      log.info("Controller MBean online");
         return name == null ? new ObjectName(OBJECT_NAME) : name;
      }
   
  @@ -292,7 +287,7 @@
             throws Exception
      {
   
  -      category.info("Initializing " + services.size() + " services");
  +      log.info("Initializing " + services.size() + " services");
   
         List servicesCopy = new ArrayList(services);
         Iterator enum = servicesCopy.iterator();
  @@ -309,11 +304,11 @@
            }
            catch (Throwable e)
            {
  -            category.error("Could not initialize " + name, e);
  +            log.error("Could not initialize " + name, e);
            }
         }
         
  -      category.info("Initialized " + serviceCounter + " services");
  +      log.info("Initialized " + serviceCounter + " services");
      }
   
      /**
  @@ -324,7 +319,7 @@
      public void start()
             throws Exception
      {
  -      category.info("Starting " + services.size() + " services");
  +      log.info("Starting " + services.size() + " services");
   
         List servicesCopy = new ArrayList(services);
         Iterator enum = servicesCopy.iterator();
  @@ -342,10 +337,10 @@
            }
            catch (Throwable e)
            {
  -            category.error("Could not start " + name, e);
  +            log.error("Could not start " + name, e);
            }
         }
  -      category.info("Started " + serviceCounter + " services");
  +      log.info("Started " + serviceCounter + " services");
      }
   
      /**
  @@ -353,7 +348,7 @@
       */
      public void stop()
      {
  -      category.info("Stopping " + services.size() + " services");
  +      log.info("Stopping " + services.size() + " services");
   
         List servicesCopy = new ArrayList(services);
         ListIterator enum = servicesCopy.listIterator();
  @@ -376,10 +371,10 @@
            }
            catch (Throwable e)
            {
  -            category.error("Could not stop " + name, e);
  +            log.error("Could not stop " + name, e);
            }
         }
  -      category.info("Stopped " + serviceCounter + " services");
  +      log.info("Stopped " + serviceCounter + " services");
      }
   
      /**
  @@ -387,7 +382,7 @@
       */
      public void destroy()
      {
  -      category.info("Destroying " + services.size() + " services");
  +      log.info("Destroying " + services.size() + " services");
   
         List servicesCopy = new ArrayList(services);
         ListIterator enum = servicesCopy.listIterator();
  @@ -410,11 +405,11 @@
            }
            catch (Throwable e)
            {
  -            category.error("Could not destroy" + name, e);
  +            log.error("Could not destroy" + name, e);
            }
         }
         
  -      category.info("Destroyed " + serviceCounter + " services");
  +      log.info("Destroyed " + serviceCounter + " services");
      }
   
      /**
  @@ -587,7 +582,7 @@
            e = ((ReflectionException)e).getTargetException();
         }
   
  -      category.error(e);
  +      log.error(e);
      }
   
      // Inner classes -------------------------------------------------
  @@ -648,7 +643,7 @@
            // any Service methods
            if (opCount == 0)
            {
  -            category.warn(objectName +
  +            log.warn(objectName +
                     " does not implement any Service methods");
            }
         }
  
  
  
  1.3       +39 -39    jboss/src/main/org/jboss/system/ServiceMBeanSupport.java
  
  Index: ServiceMBeanSupport.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/system/ServiceMBeanSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceMBeanSupport.java  2001/09/08 00:53:57     1.2
  +++ ServiceMBeanSupport.java  2001/09/11 18:35:03     1.3
  @@ -15,11 +15,8 @@
   import javax.management.ObjectName;
   import javax.management.MalformedObjectNameException;
   
  -import org.apache.log4j.Category;
  -   
  -import org.jboss.logging.Log;
  -import org.jboss.logging.LogToCategory;
  -import org.jboss.logging.log4j.JBossCategory;
  +import org.jboss.logging.Logger;
  +import org.apache.log4j.NDC;
   
   /**
    * An abstract base class JBoss services can subclass to implement a
  @@ -33,11 +30,11 @@
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    * 
    * Revisions:
    * 20010619 scott.stark: use the full service class name as the log4j
  - *                       category name
  + *                       log name
    */
   public abstract class ServiceMBeanSupport
      extends NotificationBroadcasterSupport
  @@ -49,8 +46,7 @@
      private MBeanServer server;
      private int id = 0;
   
  -   protected Log log;
  -   protected JBossCategory category;
  +   protected Logger log;
   
      // Static --------------------------------------------------------
   
  @@ -58,8 +54,7 @@
   
      public ServiceMBeanSupport()
      {
  -      category = (JBossCategory)JBossCategory.getInstance(getClass());
  -      log = new LogToCategory(category);
  +      log = Logger.create(getClass());
      }
   
      // Public --------------------------------------------------------
  @@ -84,20 +79,22 @@
      public void init()
         throws Exception
      {
  -      log.setLog(log);
  -      category.info("Initializing");
  +      NDC.push(getName());
  +      log.info("Initializing");
         try
         {
            initService();
  -      } catch (Exception e)
  +      }
  +      catch (Exception e)
         {
  -         category.error("Initialization failed", e);
  +         log.error("Initialization failed", e);
            throw e;
  -      } finally
  +      }
  +      finally
         {
  -         log.unsetLog();
  +         NDC.pop();
         }
  -      category.info("Initialized");
  +      log.info("Initialized");
      }
        
      public void start()
  @@ -109,26 +106,28 @@
         state = STARTING;
         //AS It seems that the first attribute is not needed anymore and use a long 
instead of a Date
         sendNotification(new AttributeChangeNotification(this, id++, new 
Date().getTime(), getName()+" starting", "State", "java.lang.Integer", new 
Integer(STOPPED), new Integer(STARTING)));
  -      category.info("Starting");
  -      log.setLog(log);
  +      log.info("Starting");
  +      NDC.push(getName());
         try
         {
            startService();
  -      } catch (Exception e)
  +      }
  +      catch (Exception e)
         {
            state = STOPPED;
            //AS It seems that the first attribute is not needed anymore and use a 
long instead of a Date
            sendNotification(new AttributeChangeNotification(this, id++, new 
Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new 
Integer(STARTING), new Integer(STOPPED)));
  -         category.error("Stopped", e);
  +         log.error("Stopped", e);
            throw e;
  -      } finally
  +      }
  +      finally
         {
  -         log.unsetLog();
  +         NDC.pop();
         }
         state = STARTED;
         //AS It seems that the first attribute is not needed anymore and use a long 
instead of a Date
         sendNotification(new AttributeChangeNotification(this, id++, new 
Date().getTime(), getName()+" started", "State", "java.lang.Integer", new 
Integer(STARTING), new Integer(STARTED)));
  -      category.info("Started");
  +      log.info("Started");
      }
      
      public void stop()
  @@ -139,43 +138,44 @@
         state = STOPPING;
         //AS It seems that the first attribute is not needed anymore and use a long 
instead of a Date
         sendNotification(new AttributeChangeNotification(this, id++, new 
Date().getTime(), getName()+" stopping", "State", "java.lang.Integer", new 
Integer(STARTED), new Integer(STOPPING)));
  -      category.info("Stopping");
  -      log.setLog(log);
  +      log.info("Stopping");
  +      NDC.push(getName());
         
         try
         {
            stopService();
  -      } catch (Throwable e)
  +      }
  +      catch (Throwable e)
         {
  -         category.error(e);
  +         log.error(e);
         }
         
         state = STOPPED;
         //AS It seems that the first attribute is not needed anymore and use a long 
instead of a Date
         sendNotification(new AttributeChangeNotification(this, id++, new 
Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new 
Integer(STOPPING), new Integer(STOPPED)));
  -      category.info("Stopped");
  -      log.unsetLog();
  +      log.info("Stopped");
  +      NDC.pop();
      }
  -   
  +
      public void destroy()
      {
         if (getState() != STOPPED)
            stop();
        
  -      category.info("Destroying");
  -      log.setLog(log);
  +      log.info("Destroying");
  +      NDC.push(getName());
         try
         {
            destroyService();
         } catch (Exception e)
         {
  -         category.error(e);
  +         log.error(e);
         }
        
  -      log.unsetLog();
  -      category.info("Destroyed");
  +      log.info("Destroyed");
  +      NDC.pop();
      }
  -     
  +
      public ObjectName preRegister(MBeanServer server, ObjectName name)
         throws Exception
      {
  @@ -188,7 +188,7 @@
      {
         if (!registrationDone.booleanValue())
         {
  -         category.info( "Registration is not done -> destroy" );
  +         log.info( "Registration is not done -> destroy" );
            destroy();
         }
      }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to