User: user57  
  Date: 01/07/06 21:29:59

  Modified:    src/main/org/jboss/util Info.java
  Log:
   o Only logging system properties if debug is enabled.
  
  Revision  Changes    Path
  1.10      +150 -118  jboss/src/main/org/jboss/util/Info.java
  
  Index: Info.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/Info.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Info.java 2001/06/27 03:08:21     1.9
  +++ Info.java 2001/07/07 04:29:59     1.10
  @@ -14,124 +14,156 @@
   
   import org.apache.log4j.Category;
   
  -/** A simple mbean that dumps out info like the system properties, etc.
  +/**
  + * A simple mbean that dumps out info like the system properties, etc.
    *      
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>.
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>.
  - *   @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>.
  - *   @version $Revision: 1.9 $
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>.
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>.
  + * @author <a href="mailto:[EMAIL PROTECTED]";>Hiram Chirino</a>.
  + * @version $Revision: 1.10 $
    */
  -public class Info implements InfoMBean, MBeanRegistration {
  -     // Constants -----------------------------------------------------
  -     public static final String OBJECT_NAME= ":service=Info";
  -
  -     // Attributes ----------------------------------------------------
  -     Category log= Category.getInstance(Info.class);
  -
  -     // Static --------------------------------------------------------
  -
  -     // Constructors --------------------------------------------------
  -
  -     // Public --------------------------------------------------------
  -     public ObjectName preRegister(MBeanServer server, ObjectName name) throws 
java.lang.Exception {
  -             // Dump out basic info as INFO priority msgs
  -             log.info("Java version: " + System.getProperty("java.version") + "," + 
System.getProperty("java.vendor"));
  -             log.info("Java VM: " + System.getProperty("java.vm.name") + " " + 
System.getProperty("java.vm.version") + "," + System.getProperty("java.vm.vendor"));
  -             log.info("System: " + System.getProperty("os.name") + " " + 
System.getProperty("os.version") + "," + System.getProperty("os.arch"));
  -             // Now dump out the entire System properties as DEBUG priority msgs
  -             log.debug("+++ Full System Properties Dump");
  -             Enumeration names= System.getProperties().propertyNames();
  -             while (names.hasMoreElements()) {
  -                     String pname= (String) names.nextElement();
  -                     log.debug(pname + ": " + System.getProperty(pname));
  -             }
  -
  -             // MF TODO: say everything that needs to be said here: copyright, 
included libs and TM, contributor and (C) jboss org 2000
  -             return new ObjectName(OBJECT_NAME);
  -     }
  -
  -     public void postRegister(java.lang.Boolean registrationDone) {
  -     }
  -
  -     public void preDeregister() throws java.lang.Exception {
  -     }
  -
  -     public void postDeregister() {
  -     }
  -
  -     public String getThreadGroupInfo(ThreadGroup group) {
  -
  -             StringBuffer rc= new StringBuffer();
  -
  -             rc.append("<BR><B>");
  -             rc.append("Thread Group: " + group.getName());
  -             rc.append("</B> : ");
  -             rc.append("max priority:" + group.getMaxPriority() + ", demon:" + 
group.isDaemon());
  -
  -             rc.append("<blockquote>");
  -             Thread threads[]= new Thread[group.activeCount()];
  -             group.enumerate(threads, false);
  -             for (int i= 0; i < threads.length && threads[i] != null; i++) {
  -                     rc.append("<B>");
  -                     rc.append("Thread: " + threads[i].getName());
  -                     rc.append("</B> : ");
  -                     rc.append("priority:" + threads[i].getPriority() + ", demon:" 
+ threads[i].isDaemon());
  -                     rc.append("<BR>");
  -             }
  -
  -             ThreadGroup groups[]= new ThreadGroup[group.activeGroupCount()];
  -             group.enumerate(groups, false);
  -             for (int i= 0; i < groups.length && groups[i] != null; i++) {
  -                     rc.append(getThreadGroupInfo(groups[i]));
  -             }
  -             rc.append("</blockquote>");
  -             return rc.toString();
  -     }
  -
  -     public String listMemoryUsage() {
  -
  -             String rc= "<P><B>Total Memory: </B>" + 
(Runtime.getRuntime().totalMemory()) + " </P>" + "<P><B>Free Memory: </B>" + 
(Runtime.getRuntime().freeMemory()) + " </P>";
  -
  -             return rc;
  -     }
  -
  -     public String listSystemInfo() {
  -
  -             // Dump out basic info as INFO priority msgs
  -             StringBuffer rc= new StringBuffer();
  -             rc.append("<pre>");
  -             rc.append("Java version: " + System.getProperty("java.version") + "," 
+ System.getProperty("java.vendor"));
  -             rc.append("\n");
  -             rc.append("Java VM: " + System.getProperty("java.vm.name") + " " + 
System.getProperty("java.vm.version") + "," + System.getProperty("java.vm.vendor"));
  -             rc.append("\n");
  -             rc.append("System: " + System.getProperty("os.name") + " " + 
System.getProperty("os.version") + "," + System.getProperty("os.arch"));
  -             rc.append("\n");
  -             rc.append("</pre>");
  -
  -             // HRC: Should we also do a full system properties dump??
  -
  -             return rc.toString();
  -     }
  -
  -     public String listThreadDump() {
  -
  -             // Get the root thread group
  -             ThreadGroup root= Thread.currentThread().getThreadGroup();
  -             while (root.getParent() != null) {
  -                     root= root.getParent();
  -             }
  -
  -             // I'm not sure why what gets reported is off by +1, 
  -             // but I'm adjusting so that it is consistent with the display
  -             int activeThreads = root.activeCount()-1;
  -             // I'm not sure why what gets reported is off by -1
  -             // but I'm adjusting so that it is consistent with the display
  -             int activeGroups = root.activeGroupCount()+1;
  +public class Info
  +   implements InfoMBean, MBeanRegistration
  +{
  +   // Constants -----------------------------------------------------
  +
  +   public static final String OBJECT_NAME= ":service=Info";
  +
  +   // Attributes ----------------------------------------------------
  +
  +   /** Instance logger. */
  +   private Category log = Category.getInstance(this.getClass());
  +
  +   // Static --------------------------------------------------------
  +
  +   // Constructors --------------------------------------------------
  +
  +   // Public --------------------------------------------------------
  +
  +   public ObjectName preRegister(MBeanServer server, ObjectName name)
  +      throws Exception
  +   {
  +      // Dump out basic info as INFO priority msgs
  +      log.info("Java version: " +
  +               System.getProperty("java.version") + "," +
  +               System.getProperty("java.vendor"));
  +      log.info("Java VM: " +
  +               System.getProperty("java.vm.name") + " " +
  +               System.getProperty("java.vm.version") + "," +
  +               System.getProperty("java.vm.vendor"));
  +      log.info("System: " +
  +               System.getProperty("os.name") + " " +
  +               System.getProperty("os.version") + "," +
  +               System.getProperty("os.arch"));
  +
  +      // dump out the entire system properties if debug is enabled
  +      if (log.isDebugEnabled()) {
  +         log.debug("+++ Full System Properties Dump");
  +         Enumeration names= System.getProperties().propertyNames();
  +         while (names.hasMoreElements()) {
  +            String pname= (String) names.nextElement();
  +            log.debug(pname + ": " + System.getProperty(pname));
  +         }
  +      }
  +                
  +      // MF TODO: say everything that needs to be said here:
  +      // copyright, included libs and TM, contributor and (C) jboss org 2000
  +      return new ObjectName(OBJECT_NAME);
  +   }
  +
  +   public void postRegister(Boolean registrationDone) {
  +      // empty
  +   }
  +
  +   public void preDeregister() throws Exception {
  +      // empty
  +   }
  +
  +   public void postDeregister() {
  +      // empty
  +   }
  +
  +   public String getThreadGroupInfo(ThreadGroup group) {
  +      StringBuffer rc= new StringBuffer();
  +
  +      rc.append("<BR><B>");
  +      rc.append("Thread Group: " + group.getName());
  +      rc.append("</B> : ");
  +      rc.append("max priority:" + group.getMaxPriority() +
  +                ", demon:" + group.isDaemon());
  +
  +      rc.append("<blockquote>");
  +      Thread threads[]= new Thread[group.activeCount()];
  +      group.enumerate(threads, false);
  +      for (int i= 0; i < threads.length && threads[i] != null; i++) {
  +         rc.append("<B>");
  +         rc.append("Thread: " + threads[i].getName());
  +         rc.append("</B> : ");
  +         rc.append("priority:" + threads[i].getPriority() +
  +                   ", demon:" + threads[i].isDaemon());
  +         rc.append("<BR>");
  +      }
  +
  +      ThreadGroup groups[]= new ThreadGroup[group.activeGroupCount()];
  +      group.enumerate(groups, false);
  +      for (int i= 0; i < groups.length && groups[i] != null; i++) {
  +         rc.append(getThreadGroupInfo(groups[i]));
  +      }
  +      rc.append("</blockquote>");
  +      return rc.toString();
  +   }
  +
  +   public String listMemoryUsage() {
  +      String rc= "<P><B>Total Memory: </B>" +
  +         (Runtime.getRuntime().totalMemory()) +
  +         " </P>" + "<P><B>Free Memory: </B>" +
  +         (Runtime.getRuntime().freeMemory()) + " </P>";
  +      return rc;
  +   }
  +
  +   public String listSystemInfo() {
  +      // Dump out basic info as INFO priority msgs
  +      StringBuffer rc= new StringBuffer();
  +      rc.append("<pre>");
  +      rc.append("Java version: " +
  +                System.getProperty("java.version") + "," +
  +                System.getProperty("java.vendor"));
  +      rc.append("\n");
  +      rc.append("Java VM: " +
  +                System.getProperty("java.vm.name") + " " +
  +                System.getProperty("java.vm.version") + "," +
  +                System.getProperty("java.vm.vendor"));
  +      rc.append("\n");
  +      rc.append("System: " +
  +                System.getProperty("os.name") + " " +
  +                System.getProperty("os.version") + "," +
  +                System.getProperty("os.arch"));
  +      rc.append("\n");
  +      rc.append("</pre>");
  +
  +      // HRC: Should we also do a full system properties dump??
  +
  +      return rc.toString();
  +   }
  +
  +   public String listThreadDump() {
  +      // Get the root thread group
  +      ThreadGroup root= Thread.currentThread().getThreadGroup();
  +      while (root.getParent() != null) {
  +         root = root.getParent();
  +      }
  +
  +      // I'm not sure why what gets reported is off by +1, 
  +      // but I'm adjusting so that it is consistent with the display
  +      int activeThreads = root.activeCount()-1;
  +      // I'm not sure why what gets reported is off by -1
  +      // but I'm adjusting so that it is consistent with the display
  +      int activeGroups = root.activeGroupCount()+1;
                
  -             String rc=
  -                 "<b>Total Threads:</b> "+activeThreads+"<br>"+
  -                 "<b>Total Thread Groups:</b> "+activeGroups+"<br>"+
  -                     getThreadGroupInfo(root) ;
  -             return rc;
  -     }
  -}
  \ No newline at end of file
  +      String rc=
  +         "<b>Total Threads:</b> "+activeThreads+"<br>"+
  +         "<b>Total Thread Groups:</b> "+activeGroups+"<br>"+
  +         getThreadGroupInfo(root) ;
  +      return rc;
  +   }
  +}
  
  
  

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

Reply via email to