User: starksm 
  Date: 01/04/13 12:06:59

  Modified:    src/main/org/jboss/logging Log4jService.java
  Log:
  Change the ServiceControl to be a passive service with which services
  requiring lifecycle events must register.
  Change ConfigurationService to register all mbean found in the jboss.jcml
  file with the ServiceControl service and make jboss-auto.jcml write only.
  
  Revision  Changes    Path
  1.3       +14 -10    jboss/src/main/org/jboss/logging/Log4jService.java
  
  Index: Log4jService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/logging/Log4jService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Log4jService.java 2001/04/03 03:43:44     1.2
  +++ Log4jService.java 2001/04/13 19:06:59     1.3
  @@ -33,14 +33,14 @@
   
   @author <a href="mailto:[EMAIL PROTECTED]">Fulco Muriglio</a>
   @author [EMAIL PROTECTED]
  -@version $Revision: 1.2 $
  +@version $Revision: 1.3 $
   */
   public class Log4jService implements Log4jServiceMBean, NotificationListener,
       MBeanRegistration
   {
   
   // Attributes ----------------------------------------------------
  -    private Category cat;
  +    private Category category;
       private String configurationPath;
       private int refreshPeriod;
       private boolean refreshFlag;
  @@ -104,6 +104,7 @@
           URL url = loader.getResource(configurationPath);
           if( url == null )
               throw new FileNotFoundException("Failed to find logj4 props: 
"+configurationPath);
  +        this.category = Category.getRoot();
           if( refreshFlag )
           {
               // configurationPath is a file path
  @@ -114,8 +115,7 @@
           {
               PropertyConfigurator.configure(url);
           }
  -        cat = Category.getRoot();
  -        cat.info("Started Log4jService, config="+url);
  +        category.info("Started Log4jService, config="+url);
       }
       /** Stops the log4j framework by calling the Category.shutdown() method.
       @see org.apache.log4j.Category#shutdown()
  @@ -123,8 +123,8 @@
       public void stop()
       {
           Category.shutdown();
  -        if( cat != null )
  -            cat.info("Stopped Log4jService");
  +        if( category != null )
  +            category.info("Stopped Log4jService");
       }
   
   // Public --------------------------------------------------------
  @@ -138,25 +138,29 @@
       */
       public void handleNotification(Notification n, Object handback)
       {
  +        if( category == null )
  +            return;
  +
           String msg = n.getMessage();
           char type = n.getType().charAt(0);
           String source = (String) n.getUserData();
           if( source == null || source.length() == 0 )
               source = "Default";
  +
           NDC.push(source);
           switch( type )
           {
               case 'W':
  -                cat.warn(msg);
  +                category.warn(msg);
               break;
               case 'D':
  -                cat.debug(msg);
  +                category.debug(msg);
               break;
               case 'E':
  -                cat.error(msg);
  +                category.error(msg);
               break;
               default:
  -                cat.info(msg);
  +                category.info(msg);
               break;
           }
           NDC.pop();
  
  
  

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

Reply via email to