[logback-dev] svn commit: r2341 - in logback/trunk/logback-core/src/main/java/ch/qos/logback/core: . joran

noreply.ceki at qos.ch noreply.ceki at qos.ch
Sun Jul 12 22:46:59 CEST 2009


Author: ceki
Date: Sun Jul 12 22:46:59 2009
New Revision: 2341

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java

Log:
- initial very rough implementation of automatic reconfiguration on configuration 
  file change, related to LBCORE-59

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java	Sun Jul 12 22:46:59 2009
@@ -83,4 +83,9 @@
   static public final char TAB = '\t';
   
   static public final String SEE_FNP_NOT_SET = "See also http://logback.qos.ch/codes.html#tbr_fnp_not_set";
+  
+  // The url used for the last configuration via Joran. If a file is used for the
+  // configuration, then file.getURL() is registered
+  public static String URL_OF_LAST_CONFIGURATION_VIA_JORAN = "URL_OF_LAST_CONFIGURATION_VIA_JORAN";
+  
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/GenericConfigurator.java	Sun Jul 12 22:46:59 2009
@@ -19,6 +19,7 @@
 
 import org.xml.sax.InputSource;
 
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.joran.event.SaxEvent;
 import ch.qos.logback.core.joran.event.SaxEventRecorder;
 import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
@@ -37,6 +38,7 @@
 
   final public void doConfigure(URL url) throws JoranException {
     try {
+      informContextOfURLUsedForConfiguration(url);
       URLConnection urlConnection = url.openConnection();
       // per http://jira.qos.ch/browse/LBCORE-105
       urlConnection.setDefaultUseCaches(false);
@@ -57,6 +59,7 @@
   final public void doConfigure(File file) throws JoranException {
     FileInputStream fis = null;
     try {
+      informContextOfURLUsedForConfiguration(file.toURL());
       fis = new FileInputStream(file);
       doConfigure(fis);
     } catch (IOException ioe) {
@@ -76,6 +79,10 @@
     }
   }
 
+  protected void informContextOfURLUsedForConfiguration(URL url) {
+    getContext().putObject(CoreConstants.URL_OF_LAST_CONFIGURATION_VIA_JORAN, url);
+  }
+  
   final public void doConfigure(InputStream inputStream) throws JoranException {
     doConfigure(new InputSource(inputStream));
   }


More information about the logback-dev mailing list