User: user57  
  Date: 02/03/04 19:45:46

  Modified:    src/main/org/jboss/logging Log4jService.java
  Log:
   o special handling of file urls, which don't return content type = text/xml
   o more trace debugging
  
  Revision  Changes    Path
  1.4       +28 -8     jboss-system/src/main/org/jboss/logging/Log4jService.java
  
  Index: Log4jService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-system/src/main/org/jboss/logging/Log4jService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Log4jService.java 5 Mar 2002 00:46:05 -0000       1.3
  +++ Log4jService.java 5 Mar 2002 03:45:46 -0000       1.4
  @@ -43,7 +43,7 @@
    * <p>Installs CategoryStream adapters for System.out and System.err
    *    to catch and redirect calls to Log4j.
    *
  - * @version <tt>$Revision: 1.3 $</tt>
  + * @version <tt>$Revision: 1.4 $</tt>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Fulco Muriglio</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Scott Stark</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
  @@ -123,9 +123,6 @@
      {
         this.configurationPath = path;
         this.refreshPeriod = refreshPeriod;
  -
  -      out = System.out;
  -      err = System.err;
      }
   
      public int getRefreshPeriod()
  @@ -194,12 +191,14 @@
         if (CATCH_SYSTEM_OUT)
         {
            category = Category.getInstance("STDOUT");
  +         out = System.out;
            System.setOut(new CategoryStream(category, Priority.INFO, out));
            log.debug("Installed System.out adapter");
         }
         if (CATCH_SYSTEM_ERR)
         {
            category = Category.getInstance("STDERR");
  +         err = System.err;
            System.setErr(new CategoryStream(category, Priority.ERROR, err));
            log.debug("Installed System.err adapter");
         }
  @@ -211,10 +210,14 @@
         if (out != null) {
            System.out.flush();
            System.setOut(out);
  +         log.debug("Removed System.out adapter");
  +         out = null;
         }
         if (err != null) {
            System.err.flush();
            System.setErr(err);
  +         log.debug("Removed System.err adapter");
  +         err = null;
         }
      }
   
  @@ -306,9 +309,9 @@
      private class URLWatchTimerTask
         extends TimerTask
      {
  -      private Category log = Category.getInstance(URLWatchTimerTask.class);
  +      private Logger log = Logger.getLogger(URLWatchTimerTask.class);
   
  -      private long lastConfigured;
  +      private long lastConfigured = -1;
         private URL url;
   
         public URLWatchTimerTask(final URL url)
  @@ -321,11 +324,19 @@
   
         public void run()
         {
  +         log.trace("Checking if configuration changed");
  +
  +         boolean trace = log.isTraceEnabled();
  +         
            try {
               URLConnection conn = url.openConnection();
  +            if (trace) log.trace("connection: " + conn);
  +
               long lastModified = conn.getLastModified();
  -            
  +            if (trace) log.trace("last modified: " + lastModified);
  +
               if (lastConfigured < lastModified) {
  +               log.debug("URL changed, configuring");
                  reconfigure(conn);
               }
            }
  @@ -336,7 +347,16 @@
   
         private void reconfigure(URLConnection conn) 
         {
  -         boolean xml = conn.getContentType().equals("text/xml");
  +         boolean xml = false;
  +         
  +         // check if the url is xml
  +         if (url.getProtocol().equals("file")) {
  +            xml = url.getFile().toLowerCase().endsWith(".xml");
  +         }
  +         else {
  +            xml = conn.getContentType().equals("text/xml");
  +         }
  +
            log.debug("reconfiguring; xml=" + xml);
   
            uninstallSystemAdapters();
  
  
  

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

Reply via email to