You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/08/31 22:47:22 UTC
logging-log4j2 git commit: "assembler" -> "builder" vernacular:
Rename AssembledConfiguration -> BuiltConfiguration.
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4J2-952 1564bc3ed -> 18d52d603
"assembler" -> "builder" vernacular: Rename AssembledConfiguration ->
BuiltConfiguration.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/18d52d60
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/18d52d60
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/18d52d60
Branch: refs/heads/LOG4J2-952
Commit: 18d52d603243ae17d134e2b6300e8cdc33605538
Parents: 1564bc3
Author: ggregory <gg...@apache.org>
Authored: Mon Aug 31 13:47:19 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Mon Aug 31 13:47:19 2015 -0700
----------------------------------------------------------------------
.../api/ConfigurationBuilderFactory.java | 6 +-
.../builder/impl/AssembledConfiguration.java | 141 -------------------
.../config/builder/impl/BuiltConfiguration.java | 141 +++++++++++++++++++
.../impl/DefaultConfigurationBuilder.java | 10 +-
.../properties/PropertiesConfiguration.java | 4 +-
.../log4j/core/config/TestConfigurator.java | 4 +-
6 files changed, 153 insertions(+), 153 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java
index 3252512..da1b81c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java
@@ -17,7 +17,7 @@
package org.apache.logging.log4j.core.config.builder.api;
-import org.apache.logging.log4j.core.config.builder.impl.AssembledConfiguration;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder;
/**
@@ -29,11 +29,11 @@ public class ConfigurationBuilderFactory {
* Returns a new default ConfigurationBuilder to construct Log4j configurations.
* @return A new ConfigurationBuilder.
*/
- public static ConfigurationBuilder<AssembledConfiguration> newConfigurationBuilder() {
+ public static ConfigurationBuilder<BuiltConfiguration> newConfigurationBuilder() {
return new DefaultConfigurationBuilder<>();
}
- public static <T extends AssembledConfiguration> ConfigurationBuilder<T> newConfigurationBuilder(Class<T> clazz) {
+ public static <T extends BuiltConfiguration> ConfigurationBuilder<T> newConfigurationBuilder(Class<T> clazz) {
return new DefaultConfigurationBuilder<>(clazz);
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/AssembledConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/AssembledConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/AssembledConfiguration.java
deleted file mode 100644
index 8cfbd35..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/AssembledConfiguration.java
+++ /dev/null
@@ -1,141 +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.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.FileConfigurationMonitor;
-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;
-import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
-import org.apache.logging.log4j.core.config.plugins.util.PluginType;
-import org.apache.logging.log4j.core.config.plugins.util.ResolverUtil;
-import org.apache.logging.log4j.core.config.status.StatusConfiguration;
-import org.apache.logging.log4j.core.util.Patterns;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * This is the general version of the Configuration created by the Assembler. It may be extended to
- * enhance its functionality.
- */
-public class AssembledConfiguration extends AbstractConfiguration {
- private static final long serialVersionUID = -3071897330997405132L;
- private static final String[] VERBOSE_CLASSES = new String[] { ResolverUtil.class.getName() };
- private final StatusConfiguration statusConfig;
- protected Component root;
- private Component loggersComponent;
- private Component appendersComponent;
- private Component filtersComponent;
- private Component propertiesComponent;
- private Component customLevelsComponent;
-
- public AssembledConfiguration(ConfigurationSource source, Component rootComponent) {
- super(source);
- statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES).withStatus(getDefaultStatus());
- for (Component component : rootComponent.getComponents()) {
- switch (component.getPluginType()) {
- case "Loggers": {
- loggersComponent = component;
- break;
- }
- case "Appenders": {
- appendersComponent = component;
- break;
- }
- case "Filters": {
- filtersComponent = component;
- break;
- }
- case "Properties": {
- propertiesComponent = component;
- break;
- }
- case "CustomLevels": {
- customLevelsComponent = component;
- break;
- }
- }
- }
- root = rootComponent;
- }
-
- @Override
- public void setup() {
- List<Node> children = rootNode.getChildren();
- if (propertiesComponent.getComponents().size() > 0) {
- children.add(convertToNode(rootNode, propertiesComponent));
- }
- if (customLevelsComponent.getComponents().size() > 0) {
- children.add(convertToNode(rootNode, customLevelsComponent));
- }
- children.add(convertToNode(rootNode, loggersComponent));
- children.add(convertToNode(rootNode, appendersComponent));
- if (filtersComponent.getComponents().size() > 0) {
- if (filtersComponent.getComponents().size() == 1) {
- children.add(convertToNode(rootNode, filtersComponent.getComponents().get(0)));
- } else {
- children.add(convertToNode(rootNode, filtersComponent));
- }
- }
- root = null;
- }
-
- public StatusConfiguration getStatusConfiguration() {
- return statusConfig;
- }
-
- public void setPluginPackages(String packages) {
- pluginPackages.addAll(Arrays.asList(packages.split(Patterns.COMMA_SEPARATOR)));
- }
-
- public void setShutdownHook(String flag) {
- isShutdownHookEnabled = !"disable".equalsIgnoreCase(flag);
- }
-
- public void setMonitorInterval(int intervalSeconds) {
- if (this instanceof Reconfigurable && intervalSeconds > 0) {
- ConfigurationSource configSource = getConfigurationSource();
- if (configSource != null) {
- final File configFile = configSource.getFile();
- if (intervalSeconds > 0 && configFile != null) {
- monitor = new FileConfigurationMonitor((Reconfigurable)this, configFile, listeners, intervalSeconds);
- }
- }
- }
- }
-
- public PluginManager getPluginManager() {
- return pluginManager;
- }
-
- protected Node convertToNode(Node parent, Component component) {
- String name = component.getPluginType();
- PluginType<?> pluginType = pluginManager.getPluginType(name);
- Node node = new Node(parent, name, pluginType);
- node.getAttributes().putAll(component.getAttributes());
- node.setValue(component.getValue());
- List<Node> children = node.getChildren();
- for (Component child : component.getComponents()) {
- children.add(convertToNode(node, child));
- }
- return node;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/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
new file mode 100644
index 0000000..53ef869
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java
@@ -0,0 +1,141 @@
+/*
+ * 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.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.FileConfigurationMonitor;
+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;
+import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
+import org.apache.logging.log4j.core.config.plugins.util.PluginType;
+import org.apache.logging.log4j.core.config.plugins.util.ResolverUtil;
+import org.apache.logging.log4j.core.config.status.StatusConfiguration;
+import org.apache.logging.log4j.core.util.Patterns;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This is the general version of the Configuration created by the Assembler. It may be extended to
+ * enhance its functionality.
+ */
+public class BuiltConfiguration extends AbstractConfiguration {
+ private static final long serialVersionUID = -3071897330997405132L;
+ private static final String[] VERBOSE_CLASSES = new String[] { ResolverUtil.class.getName() };
+ private final StatusConfiguration statusConfig;
+ protected Component root;
+ private Component loggersComponent;
+ private Component appendersComponent;
+ private Component filtersComponent;
+ private Component propertiesComponent;
+ private Component customLevelsComponent;
+
+ public BuiltConfiguration(ConfigurationSource source, Component rootComponent) {
+ super(source);
+ statusConfig = new StatusConfiguration().withVerboseClasses(VERBOSE_CLASSES).withStatus(getDefaultStatus());
+ for (Component component : rootComponent.getComponents()) {
+ switch (component.getPluginType()) {
+ case "Loggers": {
+ loggersComponent = component;
+ break;
+ }
+ case "Appenders": {
+ appendersComponent = component;
+ break;
+ }
+ case "Filters": {
+ filtersComponent = component;
+ break;
+ }
+ case "Properties": {
+ propertiesComponent = component;
+ break;
+ }
+ case "CustomLevels": {
+ customLevelsComponent = component;
+ break;
+ }
+ }
+ }
+ root = rootComponent;
+ }
+
+ @Override
+ public void setup() {
+ List<Node> children = rootNode.getChildren();
+ if (propertiesComponent.getComponents().size() > 0) {
+ children.add(convertToNode(rootNode, propertiesComponent));
+ }
+ if (customLevelsComponent.getComponents().size() > 0) {
+ children.add(convertToNode(rootNode, customLevelsComponent));
+ }
+ children.add(convertToNode(rootNode, loggersComponent));
+ children.add(convertToNode(rootNode, appendersComponent));
+ if (filtersComponent.getComponents().size() > 0) {
+ if (filtersComponent.getComponents().size() == 1) {
+ children.add(convertToNode(rootNode, filtersComponent.getComponents().get(0)));
+ } else {
+ children.add(convertToNode(rootNode, filtersComponent));
+ }
+ }
+ root = null;
+ }
+
+ public StatusConfiguration getStatusConfiguration() {
+ return statusConfig;
+ }
+
+ public void setPluginPackages(String packages) {
+ pluginPackages.addAll(Arrays.asList(packages.split(Patterns.COMMA_SEPARATOR)));
+ }
+
+ public void setShutdownHook(String flag) {
+ isShutdownHookEnabled = !"disable".equalsIgnoreCase(flag);
+ }
+
+ public void setMonitorInterval(int intervalSeconds) {
+ if (this instanceof Reconfigurable && intervalSeconds > 0) {
+ ConfigurationSource configSource = getConfigurationSource();
+ if (configSource != null) {
+ final File configFile = configSource.getFile();
+ if (intervalSeconds > 0 && configFile != null) {
+ monitor = new FileConfigurationMonitor((Reconfigurable)this, configFile, listeners, intervalSeconds);
+ }
+ }
+ }
+ }
+
+ public PluginManager getPluginManager() {
+ return pluginManager;
+ }
+
+ protected Node convertToNode(Node parent, Component component) {
+ String name = component.getPluginType();
+ PluginType<?> pluginType = pluginManager.getPluginType(name);
+ Node node = new Node(parent, name, pluginType);
+ node.getAttributes().putAll(component.getAttributes());
+ node.setValue(component.getValue());
+ List<Node> children = node.getChildren();
+ for (Component child : component.getComponents()) {
+ children.add(convertToNode(node, child));
+ }
+ return node;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
index 495f074..99ae765 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
@@ -38,7 +38,7 @@ import java.util.List;
/**
*
*/
-public class DefaultConfigurationBuilder<T extends AssembledConfiguration> implements ConfigurationBuilder<T> {
+public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implements ConfigurationBuilder<T> {
private final Component root = new Component();
private Component loggers;
@@ -65,11 +65,11 @@ public class DefaultConfigurationBuilder<T extends AssembledConfiguration> imple
private static final String LOG4J_ASYNC_LOGGERS = "Log4jContextSelector";
public DefaultConfigurationBuilder() {
- this(AssembledConfiguration.class);
+ this(BuiltConfiguration.class);
root.addAttribute("name", "Assembled");
}
- public <T extends AssembledConfiguration> DefaultConfigurationBuilder(Class<T> clazz) {
+ public <T extends BuiltConfiguration> DefaultConfigurationBuilder(Class<T> clazz) {
if (clazz == null) {
throw new IllegalArgumentException("A Configuration class must be provided");
}
@@ -283,13 +283,13 @@ public class DefaultConfigurationBuilder<T extends AssembledConfiguration> imple
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public T build() {
- AssembledConfiguration configuration;
+ BuiltConfiguration configuration;
try {
if (source == null) {
source = ConfigurationSource.NULL_SOURCE;
}
Constructor constructor = clazz.getConstructor(ConfigurationSource.class, Component.class);
- configuration = (AssembledConfiguration) constructor.newInstance(source, root);
+ configuration = (BuiltConfiguration) constructor.newInstance(source, root);
configuration.setMonitorInterval(monitorInterval);
if (name != null) {
configuration.setName(name);
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
index 9e3abea..ae0e49c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfiguration.java
@@ -20,14 +20,14 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Reconfigurable;
import org.apache.logging.log4j.core.config.builder.api.Component;
-import org.apache.logging.log4j.core.config.builder.impl.AssembledConfiguration;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import java.io.IOException;
/**
* Configuration created from a properties file.
*/
-public class PropertiesConfiguration extends AssembledConfiguration implements Reconfigurable {
+public class PropertiesConfiguration extends BuiltConfiguration implements Reconfigurable {
private static final long serialVersionUID = 5198216024278070407L;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/18d52d60/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
index 42ac65e..3aa3f89 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/TestConfigurator.java
@@ -34,7 +34,7 @@ import org.apache.logging.log4j.core.appender.ConsoleAppender;
import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
-import org.apache.logging.log4j.core.config.builder.impl.AssembledConfiguration;
+import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.core.filter.CompositeFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.After;
@@ -362,7 +362,7 @@ public class TestConfigurator {
@Test
public void testAssembler() throws Exception {
- ConfigurationBuilder<AssembledConfiguration> assembler = ConfigurationBuilderFactory.newConfigurationBuilder();
+ ConfigurationBuilder<BuiltConfiguration> assembler = ConfigurationBuilderFactory.newConfigurationBuilder();
assembler.setStatusLevel(Level.ERROR);
assembler.setConfigurationName("BuilderTest");
assembler.add(assembler.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)