You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2006/01/24 05:18:46 UTC
svn commit: r371802 - in /logging/log4j/trunk/src/java/org/apache/log4j:
spi/Configurator.java watchdog/FileWatchdog.java
watchdog/WatchdogSkeleton.java
Author: carnold
Date: Mon Jan 23 20:18:43 2006
New Revision: 371802
URL: http://svn.apache.org/viewcvs?rev=371802&view=rev
Log:
Bug 35452: Remove Configurator.doConfigure(InputStream)
Modified:
logging/log4j/trunk/src/java/org/apache/log4j/spi/Configurator.java
logging/log4j/trunk/src/java/org/apache/log4j/watchdog/FileWatchdog.java
logging/log4j/trunk/src/java/org/apache/log4j/watchdog/WatchdogSkeleton.java
Modified: logging/log4j/trunk/src/java/org/apache/log4j/spi/Configurator.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/src/java/org/apache/log4j/spi/Configurator.java?rev=371802&r1=371801&r2=371802&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/spi/Configurator.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/spi/Configurator.java Mon Jan 23 20:18:43 2006
@@ -51,19 +51,4 @@
@param repository The repository to operate upon.
*/
void doConfigure(URL url, LoggerRepository repository);
-
- /**
- Use an InputStream as a source for configuration and set up log4j
- accordingly.
-
- The configuration is done relative to the <code>hierarchy</code>
- parameter.
-
- @since 1.3
-
- @param stream The input stream to use for configuration data.
- @param repository The repository to operate upon.
- */
- void doConfigure(InputStream stream, LoggerRepository repository);
-
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/watchdog/FileWatchdog.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/src/java/org/apache/log4j/watchdog/FileWatchdog.java?rev=371802&r1=371801&r2=371802&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/watchdog/FileWatchdog.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/watchdog/FileWatchdog.java Mon Jan 23 20:18:43 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 1999,2004 The Apache Software Foundation.
+ * Copyright 1999,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
package org.apache.log4j.watchdog;
import java.io.File;
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
+import java.net.URL;
/**
* Implements a watchdog to watch a file. When the file changes, determined by
@@ -32,6 +30,7 @@
/** The file being watched. */
private File watchedFile;
+ private URL watchedURL;
/**
* Sets the path of the file to use and watch for configuration changes.
@@ -63,6 +62,20 @@
}
watchedFile = new File(filePath);
+ try {
+ //
+ // attempt to invoke JDK 1.4's File.toURI and URI.toURL methods
+ // which do a better job of escaping file names than File.toURL.
+ Object uri = File.class.getMethod("toURI", null).invoke(watchedFile, null);
+ watchedURL = (URL) uri.getClass().getMethod("toURL", null).invoke(uri, null);
+ } catch(Exception ex) {
+ try {
+ watchedURL = watchedFile.toURL();
+ } catch(java.net.MalformedURLException ex2) {
+ this.getLogger().error("Watchdog {} unable to express filename {} as a URL",
+ this.getName(), watchedFile.getName());
+ }
+ }
super.activateOptions();
}
@@ -80,10 +93,9 @@
* configuration data.
*/
public void reconfigure() {
- try {
- reconfigureByInputStream(new BufferedInputStream(
- new FileInputStream(watchedFile)));
- } catch (FileNotFoundException e) {
+ if (watchedFile.exists() && watchedURL != null) {
+ reconfigureByURL(watchedURL);
+ } else {
this.getLogger().error("{} watchdog cannot find file {}",
this.getName(), watchedFile.getName());
}
Modified: logging/log4j/trunk/src/java/org/apache/log4j/watchdog/WatchdogSkeleton.java
URL: http://svn.apache.org/viewcvs/logging/log4j/trunk/src/java/org/apache/log4j/watchdog/WatchdogSkeleton.java?rev=371802&r1=371801&r2=371802&view=diff
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/watchdog/WatchdogSkeleton.java (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/watchdog/WatchdogSkeleton.java Mon Jan 23 20:18:43 2006
@@ -129,37 +129,4 @@
this.getName());
}
}
-
- /**
- * Helper method to reconfigure using an InputStream.
- * The input parameter, configurationStream, should be a stream
- * of configuration data in a format expected by the configurator.
- *
- * @param srcStream The input stream that contains the data to be used
- * reconfiguration.
- */
- protected void reconfigureByInputStream(InputStream srcStream) {
- if (this.getLogger().isDebugEnabled()) {
- this.getLogger().debug("watchdog \"{}\" reconfiguring from InputStream");
- }
-
- // create an instance of the configurator class
- Configurator configurator = getConfiguratorInstance();
-
- // if able to create configurator, then reconfigure using input stream
- if (configurator != null) {
- try {
- configurator.doConfigure(srcStream, this.getLoggerRepository());
- } catch (Exception e) {
- getLogger().error(
- "watchdog " + this.getName() + " error working with configurator," +
- " ignoring new configuration settings", e);
- }
- }
- else {
- getLogger().error(
- "watchdog \"{}\" could not create configurator, ignoring new configuration settings",
- this.getName());
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org