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

  Modified:    src/main/org/jboss/util CounterInterceptor.java
                        CounterService.java Executor.java Scheduler.java
                        XmlHelper.java
  Log:
  Convert all logging to org.jboss.logging.Logger which is a subclass of
  org.apache.log4j.Category.
  
  Revision  Changes    Path
  1.5       +6 -6      jboss/src/main/org/jboss/util/CounterInterceptor.java
  
  Index: CounterInterceptor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/CounterInterceptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CounterInterceptor.java   2001/09/01 19:50:33     1.4
  +++ CounterInterceptor.java   2001/09/11 18:35:04     1.5
  @@ -8,9 +8,8 @@
   import org.jboss.ejb.Container;
   import org.jboss.ejb.plugins.*;
   
  -// TODO this needs to be replaced with the log4j logging
  -import org.jboss.logging.Logger;
   
  +import org.jboss.logging.Logger;
   import org.jboss.util.CounterService;
   
   /**
  @@ -38,8 +37,9 @@
    * statistics.
    * @author <a href="mailto:[EMAIL PROTECTED]";>Dan Christopherson</href>
    */
  -public class CounterInterceptor extends AbstractInterceptor {
  -
  +public class CounterInterceptor extends AbstractInterceptor
  +{
  +   static protected Logger log = Logger.create(CounterInterceptor.class);
      Container container = null;
      CounterService counter = null;
      boolean loggedNoCounter = false;
  @@ -89,7 +89,7 @@
   
      public void init() throws java.lang.Exception {
         //get a reference to the CounterService from JNDI
  -      Logger.debug("CounterInterceptor initializing");
  +      log.debug("CounterInterceptor initializing");
      }
   
      private CounterService getCounter() {
  @@ -99,7 +99,7 @@
               counter = (CounterService)ctx.lookup("java:/CounterService");
            } catch (NamingException ne) {
               if (!loggedNoCounter) {
  -               Logger.warning("CounterInterceptor can't get counter service "+ne);
  +               log.warn("CounterInterceptor can't get counter service ", ne);
                  loggedNoCounter = true;
               }
            }
  
  
  
  1.3       +45 -29    jboss/src/main/org/jboss/util/CounterService.java
  
  Index: CounterService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/CounterService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CounterService.java       2001/08/30 03:50:12     1.2
  +++ CounterService.java       2001/09/11 18:35:04     1.3
  @@ -9,28 +9,29 @@
   import javax.naming.Reference;
   import javax.naming.StringRefAddr;
   import org.jboss.system.ServiceMBeanSupport;
  -import org.jboss.logging.Log;
   import org.jboss.naming.NonSerializableFactory;
   
   /** A service offering accumulator style counters to help in diagnosing
  - *  performance issues. 
  - *  @author <a href="mailto:[EMAIL PROTECTED]";>Dan Christopherson</href> 
  + *  performance issues.
  + *  @author <a href="mailto:[EMAIL PROTECTED]";>Dan Christopherson</href>
    *  */
  -public class CounterService 
  +public class CounterService
      extends ServiceMBeanSupport
      implements CounterServiceMBean
   {
      private HashMap counterMap = new HashMap();
      
  -
      
      /** accumulate a count into a named counter. will initialize the named
       *  counter if neccessary. */
  -   public void accumulate(String counterName, long add) {
  +   public void accumulate(String counterName, long add)
  +   {
         Counter counter = null;
  -      synchronized (counterMap) {
  +      synchronized (counterMap)
  +      {
            counter = (Counter)counterMap.get(counterName);
  -         if (counter == null) {
  +         if (counter == null)
  +         {
               counter = new Counter(counterName);
               counterMap.put(counterName, counter);
            }
  @@ -38,75 +39,90 @@
         counter.addToCount(add);
      }
      
  -   protected void startService() throws java.lang.Exception {
  +   protected void startService() throws java.lang.Exception
  +   {
         super.startService();
         
         InitialContext ctx = new InitialContext();
         
         //bind myself into JNDI, at java:/CounterService
  -             NonSerializableFactory.bind("java:/CounterService", this);
  -             StringRefAddr addr = new StringRefAddr("nns", "java:/CounterService");
  -             Reference ref = new Reference(this.getClass().getName(), addr, 
NonSerializableFactory.class.getName(), null);
  -             ctx.bind("java:/CounterService", ref);
  +      NonSerializableFactory.bind("java:/CounterService", this);
  +      StringRefAddr addr = new StringRefAddr("nns", "java:/CounterService");
  +      Reference ref = new Reference(this.getClass().getName(), addr, 
NonSerializableFactory.class.getName(), null);
  +      ctx.bind("java:/CounterService", ref);
      }
  -   protected void stopService() {
  +   protected void stopService()
  +   {
         super.stopService();
  -      try {
  +      try
  +      {
            InitialContext ctx = new InitialContext();
            ctx.unbind("java:/CounterService");
  -                     NonSerializableFactory.unbind("java:/CounterService");
  -      } catch (NamingException ne) {
  -         log.error("Coulnd't unbind CounterService: "+ne.getMessage());
  +         NonSerializableFactory.unbind("java:/CounterService");
  +      }
  +      catch (NamingException ne)
  +      {
  +         log.error("Coulnd't unbind CounterService", ne);
         }
      }
      
  -   public String getName() {
  +   public String getName()
  +   {
         return "Counter Service";
      }
      
  -   public String list() {
  +   public String list()
  +   {
         DecimalFormat format = new DecimalFormat("####0.0000");
         String retVal = "";
         Iterator keys = counterMap.keySet().iterator();
  -      while (keys.hasNext()) {
  +      while (keys.hasNext())
  +      {
            String key = (String)keys.next();
            Counter counter = (Counter)counterMap.get(key);
            long total = 0;
            int entries = 0;
  -         synchronized (counter) {//so we dont catch half of it.
  +         synchronized (counter)
  +         {//so we dont catch half of it.
               total = counter.getCount();
               entries = counter.getEntries();
            }
            double avg = ((double)total)/((double)entries);
            String descrip = key+": total="+total+" on "+entries+"entries for "+
  -                          "an average of "+format.format(avg)+"<br>\n";
  +         "an average of "+format.format(avg)+"<br>\n";
            retVal += descrip;
         }
         return retVal;
      }
      
  -   private static class Counter {
  +   private static class Counter
  +   {
         private String name;
         private long count=0;
         private int entries=0;
         
  -      public Counter(String n) {
  +      public Counter(String n)
  +      {
            name = n;
         }
         
  -      public String getName() {
  +      public String getName()
  +      {
            return name;
         }
         
  -      public synchronized long getCount() {
  +      public synchronized long getCount()
  +      {
            return count;
         }
         
  -      public synchronized int getEntries() {
  +      public synchronized int getEntries()
  +      {
            return entries;
         }
         
  -      public synchronized void addToCount(long add) {
  +      public synchronized void addToCount(long add)
  +      {
            count += add;
            entries++;
         }
  
  
  
  1.6       +6 -8      jboss/src/main/org/jboss/util/Executor.java
  
  Index: Executor.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/Executor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Executor.java     2001/08/03 17:15:57     1.5
  +++ Executor.java     2001/09/11 18:35:04     1.6
  @@ -12,27 +12,25 @@
   import javax.management.*;
   import javax.management.loading.MLet;
   
  -import org.jboss.logging.Log;
  -import org.jboss.logging.DefaultLog;
  +import org.jboss.logging.Logger;
   
   /**
    *   <description> 
    *      
    *   @see <related>
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>.
  - *   @version $Revision: 1.5 $
  + *   @version $Revision: 1.6 $
    */
   public class Executor
      implements ExecutorMBean, MBeanRegistration
   {
      // Constants -----------------------------------------------------
      public static final String OBJECT_NAME = ":service=Executor";
  +   private static Logger log = Logger.create("Executor");
       
      // Attributes ----------------------------------------------------
      String exec;
      
  -    Log log = Log.createLog("Executor");
  -   
      // Static --------------------------------------------------------
   
      // Constructors --------------------------------------------------
  @@ -45,17 +43,17 @@
      public ObjectName preRegister(MBeanServer server, ObjectName name)
         throws java.lang.Exception
      {
  -      log.log("Execute:"+exec);
  +      log.info("Execute:"+exec);
         Process p = Runtime.getRuntime().exec(exec);
         
         p.getErrorStream().close();
         DataInputStream in = new DataInputStream(p.getInputStream());
         String line;
         while ((line = in.readLine()) != null)
  -         log.log(line);
  +         log.info(line);
         
         p.waitFor();
  -      log.log("Done");
  +      log.info("Done");
            
         return new ObjectName(OBJECT_NAME);
      }
  
  
  
  1.10      +3 -3      jboss/src/main/org/jboss/util/Scheduler.java
  
  Index: Scheduler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/Scheduler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Scheduler.java    2001/09/01 19:50:33     1.9
  +++ Scheduler.java    2001/09/11 18:35:04     1.10
  @@ -556,7 +556,7 @@
            unbind();
         }
         catch( Exception e ) {
  -         log.exception( e );
  +         log.error("Failed to unbind", e );
         }
      }
   
  @@ -598,7 +598,7 @@
         );
           lContext.bind( lName.get( 0 ), lReference );
   
  -        log.log( "JBoss Scheduler Service '" + getJNDIName() + "' bound to " + 
lJNDIName );
  +        log.info( "JBoss Scheduler Service '" + getJNDIName() + "' bound to " + 
lJNDIName );
       }
   
       private void unbind() throws NamingException {
  @@ -606,7 +606,7 @@
   
         new InitialContext().unbind( lJNDIName );
         NonSerializableFactory.unbind( lJNDIName );
  -      log.log("JBoss Scheduler service '" + lJNDIName + "' removed from JNDI" );
  +      log.info("JBoss Scheduler service '" + lJNDIName + "' removed from JNDI" );
       }
   
      // -------------------------------------------------------------------------
  
  
  
  1.4       +1 -2      jboss/src/main/org/jboss/util/XmlHelper.java
  
  Index: XmlHelper.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/XmlHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XmlHelper.java    2001/08/03 17:15:58     1.3
  +++ XmlHelper.java    2001/09/11 18:35:04     1.4
  @@ -11,13 +11,12 @@
   
   import org.w3c.dom.*;
   
  -import org.jboss.logging.Log;
   
   /**
    *   A utility class to cover up the rough bits of xml parsing
    *      
    *   @author <a href="mailto:[EMAIL PROTECTED]";>Chris Kimpton</a>
  - *   @version $Revision: 1.3 $
  + *   @version $Revision: 1.4 $
    */
   public class XmlHelper
   {
  
  
  

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

Reply via email to