Repository: logging-log4j2 Updated Branches: refs/heads/master 609267e2a -> b86a3a820
Rename FileWatcherConfigurationMonitor Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b86a3a82 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b86a3a82 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b86a3a82 Branch: refs/heads/master Commit: b86a3a820bb0e010bd0765b83f087a1a6c079184 Parents: 609267e Author: Ralph Goers <[email protected]> Authored: Sat Nov 21 23:05:42 2015 -0700 Committer: Ralph Goers <[email protected]> Committed: Sat Nov 21 23:05:42 2015 -0700 ---------------------------------------------------------------------- .../core/config/ConfiguratonFileWatcher.java | 67 ++++++++++++++++++++ .../config/FileWatcherConfigurationMonitor.java | 67 -------------------- .../config/builder/impl/BuiltConfiguration.java | 4 +- .../core/config/json/JsonConfiguration.java | 4 +- .../log4j/core/config/xml/XmlConfiguration.java | 4 +- 5 files changed, 73 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b86a3a82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java new file mode 100644 index 0000000..501280d --- /dev/null +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfiguratonFileWatcher.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.core.config; + +import org.apache.logging.log4j.core.util.FileWatcher; +import org.apache.logging.log4j.core.util.Log4jThread; + +import java.io.File; +import java.util.List; + +/** + * Class Description goes here. + * Created by rgoers on 11/21/15 + */ +public class ConfiguratonFileWatcher implements FileWatcher { + + private Reconfigurable reconfigurable; + private List<ConfigurationListener> listeners; + + public ConfiguratonFileWatcher(Reconfigurable reconfigurable, final List<ConfigurationListener> listeners) { + this.reconfigurable = reconfigurable; + this.listeners = listeners; + } + + + @Override + public void fileModified(File file) { + for (final ConfigurationListener listener : listeners) { + final Thread thread = new Log4jThread(new ReconfigurationWorker(listener, reconfigurable)); + thread.setDaemon(true); + thread.start(); + } + } + + /** + * Helper class for triggering a reconfiguration in a background thread. + */ + private static class ReconfigurationWorker implements Runnable { + + private final ConfigurationListener listener; + private final Reconfigurable reconfigurable; + + public ReconfigurationWorker(final ConfigurationListener listener, final Reconfigurable reconfigurable) { + this.listener = listener; + this.reconfigurable = reconfigurable; + } + + @Override + public void run() { + listener.onChange(reconfigurable); + } + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b86a3a82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/FileWatcherConfigurationMonitor.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/FileWatcherConfigurationMonitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/FileWatcherConfigurationMonitor.java deleted file mode 100644 index 9a8c932..0000000 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/FileWatcherConfigurationMonitor.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ -package org.apache.logging.log4j.core.config; - -import org.apache.logging.log4j.core.util.FileWatcher; -import org.apache.logging.log4j.core.util.Log4jThread; - -import java.io.File; -import java.util.List; - -/** - * Class Description goes here. - * Created by rgoers on 11/21/15 - */ -public class FileWatcherConfigurationMonitor implements FileWatcher { - - private Reconfigurable reconfigurable; - private List<ConfigurationListener> listeners; - - public FileWatcherConfigurationMonitor(Reconfigurable reconfigurable, final List<ConfigurationListener> listeners) { - this.reconfigurable = reconfigurable; - this.listeners = listeners; - } - - - @Override - public void fileModified(File file) { - for (final ConfigurationListener listener : listeners) { - final Thread thread = new Log4jThread(new ReconfigurationWorker(listener, reconfigurable)); - thread.setDaemon(true); - thread.start(); - } - } - - /** - * Helper class for triggering a reconfiguration in a background thread. - */ - private static class ReconfigurationWorker implements Runnable { - - private final ConfigurationListener listener; - private final Reconfigurable reconfigurable; - - public ReconfigurationWorker(final ConfigurationListener listener, final Reconfigurable reconfigurable) { - this.listener = listener; - this.reconfigurable = reconfigurable; - } - - @Override - public void run() { - listener.onChange(reconfigurable); - } - } -} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b86a3a82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java index f096617..4b1682c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java @@ -18,7 +18,7 @@ package org.apache.logging.log4j.core.config.builder.impl; import org.apache.logging.log4j.core.config.AbstractConfiguration; import org.apache.logging.log4j.core.config.ConfigurationSource; -import org.apache.logging.log4j.core.config.FileWatcherConfigurationMonitor; +import org.apache.logging.log4j.core.config.ConfiguratonFileWatcher; import org.apache.logging.log4j.core.config.Node; import org.apache.logging.log4j.core.config.Reconfigurable; import org.apache.logging.log4j.core.config.builder.api.Component; @@ -153,7 +153,7 @@ public class BuiltConfiguration extends AbstractConfiguration { if (intervalSeconds > 0) { getWatchManager().setIntervalSeconds(intervalSeconds); if (configFile != null) { - FileWatcher watcher = new FileWatcherConfigurationMonitor((Reconfigurable) this, listeners); + FileWatcher watcher = new ConfiguratonFileWatcher((Reconfigurable) this, listeners); getWatchManager().watchFile(configFile, watcher); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b86a3a82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java index ab5818c..e4bf0f0 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.logging.log4j.core.config.AbstractConfiguration; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.ConfigurationSource; -import org.apache.logging.log4j.core.config.FileWatcherConfigurationMonitor; +import org.apache.logging.log4j.core.config.ConfiguratonFileWatcher; import org.apache.logging.log4j.core.config.LoggerConfig; import org.apache.logging.log4j.core.config.Node; import org.apache.logging.log4j.core.config.Reconfigurable; @@ -91,7 +91,7 @@ public class JsonConfiguration extends AbstractConfiguration implements Reconfig if (intervalSeconds > 0) { getWatchManager().setIntervalSeconds(intervalSeconds); if (configFile != null) { - FileWatcher watcher = new FileWatcherConfigurationMonitor(this, listeners); + FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners); getWatchManager().watchFile(configFile, watcher); } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b86a3a82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java index dabd531..1db5392 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java @@ -38,7 +38,7 @@ import javax.xml.validation.Validator; import org.apache.logging.log4j.core.config.AbstractConfiguration; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.ConfigurationSource; -import org.apache.logging.log4j.core.config.FileWatcherConfigurationMonitor; +import org.apache.logging.log4j.core.config.ConfiguratonFileWatcher; import org.apache.logging.log4j.core.config.Node; import org.apache.logging.log4j.core.config.Reconfigurable; import org.apache.logging.log4j.core.config.plugins.util.PluginType; @@ -136,7 +136,7 @@ public class XmlConfiguration extends AbstractConfiguration implements Reconfigu if (intervalSeconds > 0) { getWatchManager().setIntervalSeconds(intervalSeconds); if (configFile != null) { - FileWatcher watcher = new FileWatcherConfigurationMonitor(this, listeners); + FileWatcher watcher = new ConfiguratonFileWatcher(this, listeners); getWatchManager().watchFile(configFile, watcher); } }
