You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2015/08/31 01:32:18 UTC
[1/3] logging-log4j2 git commit: LOG4J2-952 - rename assembler
package to builder
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4J2-952 0280c886f -> 7e73c9614
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/CustomConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/CustomConfigurationFactory.java
deleted file mode 100644
index 96c7bcf..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/CustomConfigurationFactory.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.assembler;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilder;
-import org.apache.logging.log4j.core.config.assembler.impl.AssembledConfiguration;
-
-import java.net.URI;
-
-/**
- * Normally this would be a plugin. However, we don't want it used for everything so it will be defined
- * via a system property.
- */
-//@Plugin(name = "CustomConfigurationFactory", category = ConfigurationFactory.CATEGORY)
-//@Order(50)
-public class CustomConfigurationFactory extends ConfigurationFactory {
-
- @Override
- protected String[] getSupportedTypes() {
- return new String[] {"*"};
- }
-
- @Override
- public Configuration getConfiguration(ConfigurationSource source) {
- return getConfiguration(source.toString(), null);
- }
-
- @Override
- public Configuration getConfiguration(final String name, final URI configLocation) {
- ConfigurationBuilder<AssembledConfiguration> assembler = newConfigurationBuilder();
- assembler.setStatusLevel(Level.ERROR);
- assembler.add(assembler.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
- .addAttribute("level", Level.DEBUG));
- AppenderComponentBuilder appenderAssembler = assembler.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
- appenderAssembler.add(assembler.newLayout("PatternLayout").
- addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
- appenderAssembler.add(assembler.newFilter("MarkerFilter", Filter.Result.DENY,
- Filter.Result.NEUTRAL).addAttribute("marker", "FLOW"));
- assembler.add(appenderAssembler);
- assembler.add(assembler.newLogger("org.apache.logging.log4j", Level.DEBUG).
- add(assembler.newAppenderRef("Stdout")).
- addAttribute("additivity", false));
- assembler.add(assembler.newRootLogger(Level.ERROR).add(assembler.newAppenderRef("Stdout")));
- return assembler.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
new file mode 100644
index 0000000..332e86a
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/ConfigurationAssemblerTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.LifeCycle;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.filter.ThresholdFilter;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class ConfigurationAssemblerTest {
+
+ @Test
+ public void doConfigure() throws Exception {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY, "org.apache.logging.log4j.core.config.builder.CustomConfigurationFactory");
+ Configuration config = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
+ assertNotNull("No configuration created", config);
+ assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
+ Map<String, Appender> appenders = config.getAppenders();
+ assertNotNull(appenders);
+ assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
+ Map<String, LoggerConfig> loggers = config.getLoggers();
+ assertNotNull(loggers);
+ assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
+ Filter filter = config.getFilter();
+ assertNotNull("No Filter", filter);
+ assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
+ Logger logger = LogManager.getLogger(getClass());
+ logger.info("Welcome to Log4j!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.java
new file mode 100644
index 0000000..12b2ab7
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/builder/CustomConfigurationFactory.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.builder;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.appender.ConsoleAppender;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+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.impl.AssembledConfiguration;
+
+import java.net.URI;
+
+/**
+ * Normally this would be a plugin. However, we don't want it used for everything so it will be defined
+ * via a system property.
+ */
+//@Plugin(name = "CustomConfigurationFactory", category = ConfigurationFactory.CATEGORY)
+//@Order(50)
+public class CustomConfigurationFactory extends ConfigurationFactory {
+
+ @Override
+ protected String[] getSupportedTypes() {
+ return new String[] {"*"};
+ }
+
+ @Override
+ public Configuration getConfiguration(ConfigurationSource source) {
+ return getConfiguration(source.toString(), null);
+ }
+
+ @Override
+ public Configuration getConfiguration(final String name, final URI configLocation) {
+ ConfigurationBuilder<AssembledConfiguration> assembler = newConfigurationBuilder();
+ assembler.setStatusLevel(Level.ERROR);
+ assembler.add(assembler.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
+ .addAttribute("level", Level.DEBUG));
+ AppenderComponentBuilder appenderAssembler = assembler.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
+ appenderAssembler.add(assembler.newLayout("PatternLayout").
+ addAttribute("pattern", "%d [%t] %-5level: %msg%n%throwable"));
+ appenderAssembler.add(assembler.newFilter("MarkerFilter", Filter.Result.DENY,
+ Filter.Result.NEUTRAL).addAttribute("marker", "FLOW"));
+ assembler.add(appenderAssembler);
+ assembler.add(assembler.newLogger("org.apache.logging.log4j", Level.DEBUG).
+ add(assembler.newAppenderRef("Stdout")).
+ addAttribute("additivity", false));
+ assembler.add(assembler.newRootLogger(Level.ERROR).add(assembler.newAppenderRef("Stdout")));
+ return assembler.build();
+ }
+}
[2/3] logging-log4j2 git commit: LOG4J2-952 - rename assembler
package to builder
Posted by rg...@apache.org.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderRefComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderRefComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderRefComponentBuilder.java
new file mode 100644
index 0000000..840b386
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderRefComponentBuilder.java
@@ -0,0 +1,30 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing AppenderRefs.
+ */
+public interface AppenderRefComponentBuilder extends ComponentBuilder<AppenderRefComponentBuilder> {
+
+ /**
+ * Add a Filter to the Appender component.
+ * @param assembler The FilterComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler.
+ */
+ AppenderRefComponentBuilder add(FilterComponentBuilder assembler);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Assembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Assembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Assembler.java
new file mode 100644
index 0000000..74a4152
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Assembler.java
@@ -0,0 +1,37 @@
+/*
+ * 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.api;
+
+/**
+ * Gathers information in preparation for creating components. These assemblers are primarily useful for
+ * aggregating the information that will be used to create a Configuration.
+ *
+ * @param <T> the Component class this is a builder for.
+ */
+public interface Assembler<T> {
+
+ /**
+ * Builds the plugin object after all configuration has been set. This will use default values for any
+ * unspecified attributes for the plugin.
+ *
+ * @return the configured plugin instance.
+ * @throws org.apache.logging.log4j.core.config.ConfigurationException if there was an error building the plugin
+ * object.
+ */
+ T assemble();
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Component.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Component.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Component.java
new file mode 100644
index 0000000..7f21603
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/Component.java
@@ -0,0 +1,80 @@
+/*
+ * 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.api;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Container for assembling Configurations. This class is not normally directly manipulated by users
+ * of the Assembler API.
+ */
+public class Component {
+
+ private final Map<String, String> attributes = new HashMap<>();
+ private final List<Component> components = new ArrayList<>();
+ private final String pluginType;
+ private final String value;
+
+ public Component(String pluginType) {
+ this(pluginType, null, null);
+ }
+
+ public Component(String pluginType, String name) {
+ this(pluginType, name, null);
+ }
+
+ public Component(String pluginType, String name, String value) {
+ this.pluginType = pluginType;
+ this.value = value;
+ if (name != null && name.length() > 0) {
+ attributes.put("name", name);
+ }
+ }
+
+ public Component() {
+ this.pluginType = null;
+ this.value = null;
+ }
+
+
+ public String addAttribute(String key, String value) {
+ return attributes.put(key, value);
+ }
+
+ public void addComponent(Component component) {
+ components.add(component);
+ }
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+ public List<Component> getComponents() {
+ return components;
+ }
+
+ public String getPluginType() {
+ return pluginType;
+ }
+
+ public String getValue() {
+ return value;
+ }
+ }
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ComponentBuilder.java
new file mode 100644
index 0000000..8d9f496
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ComponentBuilder.java
@@ -0,0 +1,95 @@
+/*
+ * 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.api;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.util.Builder;
+
+/**
+ * Assembler for arbitrary components and the base class for the provided components.
+ */
+@SuppressWarnings("rawtypes")
+public interface ComponentBuilder<T extends ComponentBuilder> extends Builder<Component> {
+
+ /**
+ * Add an attribute to the component.
+ * @param key The attribute key.
+ * @param value The value of the attribute.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, String value);
+
+ /**
+ * Add a logging Level attribute to the component.
+ * @param key The attribute key.
+ * @param level The logging Level.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, Level level);
+
+ /**
+ * Add an enumeration.
+ * @param key The attribute key.
+ * @param value The enumeration.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, Enum<?> value);
+
+ /**
+ * Add an integer attribute.
+ * @param key The attribute key.
+ * @param value The integer value.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, int value);
+
+ /**
+ * Add a boolean attribute.
+ * @param key The attribute key.
+ * @param value The integer value.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, boolean value);
+
+ /**
+ * Add an Object attribute.
+ * @param key The attribute key.
+ * @param value The integer value.
+ * @return The ComponentBuilder.
+ */
+ T addAttribute(String key, Object value);
+
+ /**
+ * Add a sub component.
+ * @param assembler The Assembler for the subcomponent with all of its attributes and sub-components set.
+ * @return The ComponentBuilder.
+ */
+ T addComponent(ComponentBuilder<?> assembler);
+
+ /**
+ * Return the name of the component, if any.
+ * @return The components name or null if it doesn't have one.
+ */
+ String getName();
+
+ /**
+ * Retrieve the ConfigurationBuilder.
+ * @return The ConfiguratonAssembler.
+ */
+ ConfigurationBuilder<? extends Configuration> getBuilder();
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CompositeFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CompositeFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CompositeFilterComponentBuilder.java
new file mode 100644
index 0000000..67b0614
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CompositeFilterComponentBuilder.java
@@ -0,0 +1,30 @@
+/*
+ * 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.api;
+
+/**
+ * Wraps multiple filter assemblers.
+ */
+public interface CompositeFilterComponentBuilder extends ComponentBuilder<CompositeFilterComponentBuilder> {
+
+ /**
+ * Add a FilterComponent.
+ * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
+ * @return The CompositeFilterComponentBuilder.
+ */
+ CompositeFilterComponentBuilder add(FilterComponentBuilder assembler);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
new file mode 100644
index 0000000..211e59c
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java
@@ -0,0 +1,253 @@
+/*
+ * 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.api;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.util.Builder;
+
+/**
+ * Interface for assembling logging configurations.
+ */
+public interface ConfigurationBuilder<T extends Configuration> extends Builder<T> {
+
+ /**
+ * Set the name of the configuration.
+ *
+ * @param name the name of the {@link Configuration}. By default is {@code "Constructed"}.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setConfigurationName(String name);
+
+ /**
+ * Set the configuration source, if one exists.
+ * @param configurationSource the ConfigurationSource.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource);
+
+ /**
+ * Set the level of the StatusLogger.
+ * @param level The logging level.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setStatusLevel(Level level);
+
+ /**
+ * Set whether the logging should include constructing Plugins.
+ * @param verbosity "disable" will hide messages from plugin construction.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setVerbosity(String verbosity);
+
+ /**
+ * Set the list of packages to search for plugins.
+ * @param packages The comma separated list of packages.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setPackages(String packages);
+
+ /**
+ * Set whether the shutdown hook should be disabled.
+ * @param flag "disable" will prevent the shutdown hook from being set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setShutdownHook(String flag);
+
+ /**
+ * Sets the interval at which the configuration file should be checked for changes.
+ * @param intervalSeconds The number of seconds that should pass between checks of the configuration file.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> setMonitorInterval(String intervalSeconds);
+
+ /**
+ * Adds an AppenderComponent.
+ * @param assembler The AppenderComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> add(AppenderComponentBuilder assembler);
+
+ /**
+ * Adds a CustomLevel component.
+ * @param assembler The CustomLevelComponentBuilder with all of its attributes set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> add(CustomLevelComponentBuilder assembler);
+
+ /**
+ * Add a Logger component.
+ * @param assembler The LoggerComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> add(LoggerComponentBuilder assembler);
+
+ /**
+ * Add the root Logger component.
+ * @param assembler The RootLoggerComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> add(RootLoggerComponentBuilder assembler);
+
+ /**
+ * Add a Filter component.
+ * @param assembler the FilterComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> add(FilterComponentBuilder assembler);
+
+ /**
+ * Add a Property key and value.
+ * @param key The property key.
+ * @param value The property value.
+ * @return this Assembler instance.
+ */
+ ConfigurationBuilder<T> addProperty(String key, String value);
+
+ /**
+ * Returns an Assembler for creating Appenders.
+ * @param name The name of the Appender.
+ * @param pluginName The Plugin type of the Appender.
+ * @return the AppenderComponentBuilder.
+ */
+ AppenderComponentBuilder newAppender(String name, String pluginName);
+
+
+ /**
+ * Returns an Assembler for creating AppenderRefs.
+ * @param ref The name of the Appender being referenced.
+ * @return the AppenderRefComponentBuilder.
+ */
+ AppenderRefComponentBuilder newAppenderRef(String ref);
+
+ /**
+ * Returns an Assembler for creating generic components.
+ * @param name The name of the component (may be null).
+ * @param pluginName The Plugin type of the component.
+ * @return The ComponentBuilder.
+ */
+ @SuppressWarnings("rawtypes")
+ ComponentBuilder newComponent(String name, String pluginName);
+
+ /**
+ * Returns an Assembler for creating generic components.
+ * @param name The name of the component (may be null).
+ * @param pluginName The Plugin type of the component.
+ * @param value The value of the component.
+ * @return The ComponentBuilder.
+ */
+ @SuppressWarnings("rawtypes")
+ ComponentBuilder<ComponentBuilder> newComponent(String name, String pluginName, String value);
+
+ /**
+ * Returns an Asssembler for creating CustomLevels
+ * @param name The name of the custom level.
+ * @param level The integer value to be assigned to the level.
+ * @return The CustomLevelComponentBuilder.
+ */
+ CustomLevelComponentBuilder newCustomLevel(String name, int level);
+
+ /**
+ * Returns an Asssembler for creating Filters.
+ * @param pluginName The Plugin type of the Filter.
+ * @param onMatch "ACCEPT", "DENY", or "NEUTRAL"
+ * @param onMisMatch "ACCEPT", "DENY", or "NEUTRAL"
+ * @return The FilterComponentBuilder.
+ */
+ FilterComponentBuilder newFilter(String pluginName, Filter.Result onMatch, Filter.Result onMisMatch);
+
+ /**
+ * Returns an Asssembler for creating Filters.
+ * @param pluginName The Plugin type of the Filter.
+ * @param onMatch "ACCEPT", "DENY", or "NEUTRAL"
+ * @param onMisMatch "ACCEPT", "DENY", or "NEUTRAL"
+ * @return The FilterComponentBuilder.
+ */
+ FilterComponentBuilder newFilter(String pluginName, String onMatch, String onMisMatch);
+
+ /**
+ * Returns an Assembler for creating Layouts.
+ * @param type The Plugin type of the Layout.
+ * @return The LayoutComponentBuilder.
+ */
+ LayoutComponentBuilder newLayout(String pluginName);
+
+ /**
+ * Returns an Assembler for creating Loggers.
+ * @param name The name of the Logger.
+ * @param level The logging Level to be assigned to the Logger.
+ * @return The LoggerComponentBuilder.
+ */
+ LoggerComponentBuilder newLogger(String name, Level level);
+
+
+ /**
+ * Returns an Assembler for creating Loggers.
+ * @param name The name of the Logger.
+ * @param level The logging Level to be assigned to the Logger.
+ * @return The LoggerComponentBuilder.
+ */
+ LoggerComponentBuilder newLogger(String name, String level);
+
+ /**
+ * Returns an Assembler for creating Async Loggers.
+ * @param name The name of the Logger.
+ * @param level The logging Level to be assigned to the Logger.
+ * @return The LoggerComponentBuilder.
+ */
+ LoggerComponentBuilder newAsyncLogger(String name, Level level);
+
+ /**
+ * Returns an Assembler for creating Async Loggers.
+ * @param name The name of the Logger.
+ * @param level The logging Level to be assigned to the Logger.
+ * @return The LoggerComponentBuilder.
+ */
+ LoggerComponentBuilder newAsyncLogger(String name, String level);
+
+ /**
+ * Returns an Assembler for creating the root Logger.
+ * @param level The logging Level to be assigned to the root Logger.
+ * @return The RootLoggerComponentBuilder.
+ */
+ RootLoggerComponentBuilder newRootLogger(Level level);
+
+ /**
+ * Returns an Assembler for creating the root Logger.
+ * @param level The logging Level to be assigned to the root Logger.
+ * @return The RootLoggerComponentBuilder.
+ */
+ RootLoggerComponentBuilder newRootLogger(String level);
+
+
+ /**
+ * Returns an Assembler for creating the async root Logger.
+ * @param level The logging Level to be assigned to the root Logger.
+ * @return The RootLoggerComponentBuilder.
+ */
+ RootLoggerComponentBuilder newAsyncRootLogger(Level level);
+
+
+ /**
+ * Returns an Assembler for creating the async root Logger.
+ * @param level The logging Level to be assigned to the root Logger.
+ * @return The RootLoggerComponentBuilder.
+ */
+ RootLoggerComponentBuilder newAsyncRootLogger(String level);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/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
new file mode 100644
index 0000000..2cc4db5
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilderFactory.java
@@ -0,0 +1,39 @@
+/*
+ * 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.api;
+
+import org.apache.logging.log4j.core.config.builder.impl.AssembledConfiguration;
+import org.apache.logging.log4j.core.config.builder.impl.DefaultConfigurationBuilder;
+
+/**
+ *
+ */
+public class ConfigurationBuilderFactory {
+
+ /**
+ * Returns the default ConfigurationBuilder to construct Log4j configurations.
+ * @return The ConfigurationBuilder.
+ */
+ public static ConfigurationBuilder<AssembledConfiguration> newConfigurationBuilder() {
+ return new DefaultConfigurationBuilder<>();
+ }
+
+ public static <T extends AssembledConfiguration> ConfigurationBuilder<T> newConfigurationBuilder(Class<T> clazz) {
+ return new DefaultConfigurationBuilder<T>(clazz);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CustomLevelComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CustomLevelComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CustomLevelComponentBuilder.java
new file mode 100644
index 0000000..8ce5801
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/CustomLevelComponentBuilder.java
@@ -0,0 +1,24 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing Filters
+ */
+public interface CustomLevelComponentBuilder extends ComponentBuilder<CustomLevelComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/FilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/FilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/FilterComponentBuilder.java
new file mode 100644
index 0000000..f543f33
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/FilterComponentBuilder.java
@@ -0,0 +1,24 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing Filters
+ */
+public interface FilterComponentBuilder extends ComponentBuilder<FilterComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LayoutComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LayoutComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LayoutComponentBuilder.java
new file mode 100644
index 0000000..5668264
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LayoutComponentBuilder.java
@@ -0,0 +1,24 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing Layouts
+ */
+public interface LayoutComponentBuilder extends ComponentBuilder<LayoutComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LoggerComponentBuilder.java
new file mode 100644
index 0000000..58e7caa
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/LoggerComponentBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing Loggers.
+ */
+public interface LoggerComponentBuilder extends ComponentBuilder<LoggerComponentBuilder> {
+
+ /**
+ * Add an Appender reference to the Logger component.
+ * @param assembler The AppenderRefComponentBuilder with all of its attributes and sub-components set.
+ * @return this Assembler.
+ */
+ LoggerComponentBuilder add(AppenderRefComponentBuilder assembler);
+
+ /**
+ * Add a Filter to the Logger component.
+ * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
+ * @return this Assembler.
+ */
+ LoggerComponentBuilder add(FilterComponentBuilder assembler);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/RootLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/RootLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/RootLoggerComponentBuilder.java
new file mode 100644
index 0000000..7db6ef6
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/RootLoggerComponentBuilder.java
@@ -0,0 +1,37 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing the root Logger.
+ */
+public interface RootLoggerComponentBuilder extends ComponentBuilder<RootLoggerComponentBuilder> {
+
+ /**
+ * Add an Appender reference to the Logger component.
+ * @param assembler The AppenderRefComponentBuilder with all of its attributes and sub-components set.
+ * @return this Assembler.
+ */
+ RootLoggerComponentBuilder add(AppenderRefComponentBuilder assembler);
+
+ /**
+ * Add a Filter to the Logger component.
+ * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
+ * @return this Assembler.
+ */
+ RootLoggerComponentBuilder add(FilterComponentBuilder assembler);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/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
new file mode 100644
index 0000000..8cfbd35
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/AssembledConfiguration.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 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/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderComponentBuilder.java
new file mode 100644
index 0000000..f421c0c
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderComponentBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+
+/**
+ * Holds the Appender Component attributes and subcomponents.
+ */
+public class DefaultAppenderComponentBuilder extends DefaultComponentBuilder<AppenderComponentBuilder> implements
+ AppenderComponentBuilder {
+
+ public DefaultAppenderComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
+ String type) {
+ super(assembler, name, type);
+ }
+
+ @Override
+ public AppenderComponentBuilder add(LayoutComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+
+ @Override
+ public AppenderComponentBuilder add(FilterComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderRefComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderRefComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderRefComponentBuilder.java
new file mode 100644
index 0000000..31329c4
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultAppenderRefComponentBuilder.java
@@ -0,0 +1,41 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.AppenderRefComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+
+/**
+ * Holds the Appender Component attributes and subcomponents.
+ */
+public class DefaultAppenderRefComponentBuilder extends DefaultComponentBuilder<AppenderRefComponentBuilder> implements
+ AppenderRefComponentBuilder {
+
+ public DefaultAppenderRefComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
+ String ref) {
+ super(assembler, "AppenderRef");
+ addAttribute("ref", ref);
+ }
+
+
+ @Override
+ public AppenderRefComponentBuilder add(FilterComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultComponentBuilder.java
new file mode 100644
index 0000000..8e30a8f
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultComponentBuilder.java
@@ -0,0 +1,128 @@
+/*
+ * 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.Level;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.Component;
+import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Generic component that captures attributes and Components in preparation for assembling the Appender's
+ * Component.
+ */
+@SuppressWarnings("rawtypes")
+public class DefaultComponentBuilder<T extends ComponentBuilder> implements ComponentBuilder<T> {
+
+ private ConfigurationBuilder<? extends Configuration> assembler;
+ private String type;
+ private Map<String, String> attributes = new HashMap<>();
+ private List<Component> components = new ArrayList<>();
+ private String name;
+ private String value;
+
+ public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String type) {
+ this(assembler, null, type, null);
+ }
+
+ public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String name, String type) {
+ this(assembler, name, type, null);
+ }
+
+ public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String name, String type,
+ String value) {
+ this.type = type;
+ this.assembler = assembler;
+ this.name = name;
+ this.value = value;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, Level level) {
+ attributes.put(key, level.toString());
+ return (T) this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, String value) {
+ attributes.put(key, value);
+ return (T) this;
+ }
+
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, Enum<?> value) {
+ attributes.put(key, value.name());
+ return (T) this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, int value) {
+ attributes.put(key, Integer.toString(value));
+ return (T) this;
+ }
+
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, boolean value) {
+ attributes.put(key, Boolean.toString(value));
+ return (T) this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addAttribute(String key, Object value) {
+ attributes.put(key, value.toString());
+ return (T) this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T addComponent(ComponentBuilder<?> assembler) {
+ components.add(assembler.build());
+ return (T) this;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public ConfigurationBuilder<? extends Configuration> getBuilder() {
+ return assembler;
+ }
+
+ @Override
+ public Component build() {
+ Component component = new Component(type, name, value);
+ component.getAttributes().putAll(attributes);
+ component.getComponents().addAll(components);
+ return component;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCompositeFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCompositeFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCompositeFilterComponentBuilder.java
new file mode 100644
index 0000000..c2958f2
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCompositeFilterComponentBuilder.java
@@ -0,0 +1,42 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.CompositeFilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultCompositeFilterComponentBuilder extends DefaultComponentBuilder<CompositeFilterComponentBuilder> implements
+ CompositeFilterComponentBuilder {
+
+ public DefaultCompositeFilterComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
+ String onMatch, String onMisMatch) {
+ super(assembler, "Filters");
+ addAttribute("onMatch", onMatch);
+ addAttribute("onMisMatch", onMisMatch);
+ }
+
+ @Override
+ public CompositeFilterComponentBuilder add(FilterComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/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
new file mode 100644
index 0000000..b505de6
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
@@ -0,0 +1,319 @@
+/*
+ * 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.Level;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationException;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.AppenderRefComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.Component;
+import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+import org.apache.logging.log4j.core.config.builder.api.CustomLevelComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LoggerComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
+
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+/**
+ *
+ */
+public class DefaultConfigurationBuilder<T extends AssembledConfiguration> implements ConfigurationBuilder<T> {
+
+ private AssembledConfiguration configuration;
+
+ private final Component root = new Component();
+ private Component loggers;
+ private Component appenders;
+ private Component filters;
+ private Component properties;
+ private Component customLevels;
+ private final Class<?> clazz;
+ private ConfigurationSource source;
+ private int monitorInterval = 0;
+ private Level level = null;
+ private String verbosity = null;
+ private String packages = null;
+ private String shutdownFlag = null;
+ private String name = null;
+
+ /**
+ * The key with which Apache Log4j loads the selector class.
+ *
+ * @see <a href=
+ * "http://logging.apache.org/log4j/2.0/manual/async.html">
+ * Async Loggers</a>
+ */
+ private static final String LOG4J_ASYNC_LOGGERS = "Log4jContextSelector";
+
+ public DefaultConfigurationBuilder() {
+ this(AssembledConfiguration.class);
+ root.addAttribute("name", "Assembled");
+ }
+
+ public <T extends AssembledConfiguration> DefaultConfigurationBuilder(Class<T> clazz) {
+ if (clazz == null) {
+ throw new IllegalArgumentException("A Configuration class must be provided");
+ }
+ this.clazz = clazz;
+ List<Component> components = root.getComponents();
+ properties = new Component("Properties");
+ components.add(properties);
+ customLevels = new Component("CustomLevels");
+ components.add(customLevels);
+ filters = new Component("Filters");
+ components.add(filters);
+ appenders = new Component("Appenders");
+ components.add(appenders);
+ loggers = new Component("Loggers");
+ components.add(loggers);
+ }
+
+ /**
+ * Set the name of the configuration.
+ *
+ * @param name the name of the {@link Configuration}. By default is {@code "Assembled"}.
+ * @return this builder instance
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setConfigurationName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Set the ConfigurationSource.
+ *
+ * @param configurationSource the {@link ConfigurationSource).}
+ * @return this builder instance
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource) {
+ source = configurationSource;
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setMonitorInterval(String intervalSeconds) {
+ monitorInterval = Integer.parseInt(intervalSeconds);
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setStatusLevel(Level level) {
+ this.level = level;
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setVerbosity(String verbosity) {
+ this.verbosity = verbosity;
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setPackages(String packages) {
+ this.packages = packages;
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> setShutdownHook(String flag) {
+ this.shutdownFlag = flag;
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> add(AppenderComponentBuilder assembler) {
+ appenders.getComponents().add(assembler.build());
+ return this;
+ }
+
+ @Override
+ public ConfigurationBuilder<T> add(CustomLevelComponentBuilder assembler) {
+ customLevels.getComponents().add(assembler.build());
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> add(LoggerComponentBuilder assembler) {
+ loggers.getComponents().add(assembler.build());
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> add(RootLoggerComponentBuilder assembler) {
+ for (Component c : loggers.getComponents()) {
+ if (c.getPluginType().equals("root")) {
+ throw new ConfigurationException("root Logger was previously defined");
+ }
+ }
+ loggers.getComponents().add(assembler.build());
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> add(FilterComponentBuilder assembler) {
+ filters.getComponents().add(assembler.build());
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ConfigurationBuilder<T> addProperty(String key, String value) {
+ properties.addComponent(newComponent(key, "Property", value).build());
+ return this;
+ }
+
+ @Override
+ public AppenderComponentBuilder newAppender(String name, String type) {
+ return new DefaultAppenderComponentBuilder(this, name, type);
+ }
+
+
+ @Override
+ public AppenderRefComponentBuilder newAppenderRef(String ref) {
+ return new DefaultAppenderRefComponentBuilder(this, ref);
+ }
+
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public ComponentBuilder<ComponentBuilder> newComponent(String name, String type) {
+ return new DefaultComponentBuilder(this, name, type);
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public ComponentBuilder<ComponentBuilder> newComponent(String name, String type, String value) {
+ return new DefaultComponentBuilder(this, name, type, value);
+ }
+
+ @Override
+ public CustomLevelComponentBuilder newCustomLevel(String name, int level) {
+ return new DefaultCustomLevelComponentBuilder(this, name, level);
+ }
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public FilterComponentBuilder newFilter(String type, String onMatch, String onMisMatch) {
+ return new DefaultFilterComponentBuilder(this, type, onMatch, onMisMatch);
+ }
+
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public FilterComponentBuilder newFilter(String type, Filter.Result onMatch, Filter.Result onMisMatch) {
+ return new DefaultFilterComponentBuilder(this, type, onMatch.name(), onMisMatch.name());
+ }
+
+ @Override
+ public LayoutComponentBuilder newLayout(String type) {
+ return new DefaultLayoutComponentBuilder(this, type);
+ }
+
+ @Override
+ public LoggerComponentBuilder newLogger(String name, String level) {
+ return new DefaultLoggerComponentBuilder(this, name, level);
+ }
+
+ @Override
+ public LoggerComponentBuilder newLogger(String name, Level level) {
+ return new DefaultLoggerComponentBuilder(this, name, level.toString());
+ }
+
+ @Override
+ public LoggerComponentBuilder newAsyncLogger(String name, String level) {
+ return new DefaultLoggerComponentBuilder(this, name, level, "AsyncLogger");
+ }
+
+ @Override
+ public LoggerComponentBuilder newAsyncLogger(String name, Level level) {
+ return new DefaultLoggerComponentBuilder(this, name, level.toString(), "AsyncLogger");
+ }
+
+ @Override
+ public RootLoggerComponentBuilder newRootLogger(String level) {
+ return new DefaultRootLoggerComponentBuilder(this, level);
+ }
+
+ @Override
+ public RootLoggerComponentBuilder newRootLogger(Level level) {
+ return new DefaultRootLoggerComponentBuilder(this, level.toString());
+ }
+
+ @Override
+ public RootLoggerComponentBuilder newAsyncRootLogger(String level) {
+ return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot");
+ }
+
+ @Override
+ public RootLoggerComponentBuilder newAsyncRootLogger(Level level) {
+ return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot");
+ }
+
+ @Override
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public T build() {
+ AssembledConfiguration configuration;
+ try {
+ if (source == null) {
+ source = ConfigurationSource.NULL_SOURCE;
+ }
+ Constructor constructor = clazz.getConstructor(ConfigurationSource.class, Component.class);
+ configuration = (AssembledConfiguration) constructor.newInstance(source, root);
+ configuration.setMonitorInterval(monitorInterval);
+ if (name != null) {
+ configuration.setName(name);
+ }
+ if (level != null) {
+ configuration.getStatusConfiguration().withStatus(level);
+ }
+ if (verbosity != null) {
+ configuration.getStatusConfiguration().withVerbosity(verbosity);
+ }
+ if (packages != null) {
+ configuration.setPluginPackages(packages);
+ }
+ if (shutdownFlag != null) {
+ configuration.setShutdownHook(shutdownFlag);
+ }
+ } catch (Exception ex) {
+ throw new IllegalArgumentException("Invalid Configuration class specified", ex);
+ }
+ configuration.getStatusConfiguration().initialize();
+ configuration.initialize();
+ return (T)configuration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
new file mode 100644
index 0000000..fd6f103
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultCustomLevelComponentBuilder.java
@@ -0,0 +1,33 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.CustomLevelComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultCustomLevelComponentBuilder extends DefaultComponentBuilder<CustomLevelComponentBuilder> implements
+ CustomLevelComponentBuilder {
+
+ public DefaultCustomLevelComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
+ String name, int level) {
+ super(assembler, name, "CustomLevel");
+ addAttribute("level", Integer.toString(level));
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultFilterComponentBuilder.java
new file mode 100644
index 0000000..65181f5
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultFilterComponentBuilder.java
@@ -0,0 +1,34 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultFilterComponentBuilder extends DefaultComponentBuilder<FilterComponentBuilder> implements
+ FilterComponentBuilder {
+
+ public DefaultFilterComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String type,
+ String onMatch, String onMisMatch) {
+ super(assembler, type);
+ addAttribute("onMatch", onMatch);
+ addAttribute("onMisMatch", onMisMatch);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLayoutComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLayoutComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLayoutComponentBuilder.java
new file mode 100644
index 0000000..2ab4b41
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLayoutComponentBuilder.java
@@ -0,0 +1,31 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultLayoutComponentBuilder extends DefaultComponentBuilder<LayoutComponentBuilder> implements
+ LayoutComponentBuilder {
+
+ public DefaultLayoutComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String type) {
+ super(assembler, type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
new file mode 100644
index 0000000..df7265d
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultLoggerComponentBuilder.java
@@ -0,0 +1,66 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.AppenderRefComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LoggerComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultLoggerComponentBuilder extends DefaultComponentBuilder<LoggerComponentBuilder> implements
+ LoggerComponentBuilder {
+
+ /**
+ * Configure a logger.
+ * @param assembler
+ * @param name
+ * @param level
+ */
+ public DefaultLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
+ String level) {
+ super(assembler, name, "Logger");
+ addAttribute("level", level);
+ }
+
+ /**
+ * Configure a logger.
+ * @param assembler
+ * @param name
+ * @param level
+ * @param type
+ */
+ public DefaultLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
+ String level, String type) {
+ super(assembler, name, type);
+ addAttribute("level", level);
+ }
+
+ @Override
+ public LoggerComponentBuilder add(AppenderRefComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+
+ @Override
+ public LoggerComponentBuilder add(FilterComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultRootLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultRootLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultRootLoggerComponentBuilder.java
new file mode 100644
index 0000000..42932b9
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultRootLoggerComponentBuilder.java
@@ -0,0 +1,65 @@
+/*
+ * 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.Configuration;
+import org.apache.logging.log4j.core.config.builder.api.AppenderRefComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
+
+/**
+ *
+ */
+public class DefaultRootLoggerComponentBuilder extends DefaultComponentBuilder<RootLoggerComponentBuilder> implements
+ RootLoggerComponentBuilder {
+
+ /**
+ * Configure the root logger.
+ * @param assembler
+ * @param level
+ */
+ public DefaultRootLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
+ String level) {
+ super(assembler, "", "Root");
+ addAttribute("level", level);
+ }
+
+ /**
+ * Configure the root logger.
+ * @param assembler
+ * @param level
+ * @param type
+ */
+ public DefaultRootLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
+ String level, String type) {
+ super(assembler, "", type);
+ addAttribute("level", level);
+ }
+
+ @Override
+ public RootLoggerComponentBuilder add(AppenderRefComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+
+
+ @Override
+ public RootLoggerComponentBuilder add(FilterComponentBuilder assembler) {
+ addComponent(assembler);
+ return this;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/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 b5701b0..cf57338 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
@@ -19,10 +19,9 @@ package org.apache.logging.log4j.core.config.properties;
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.assembler.api.Component;
-import org.apache.logging.log4j.core.config.assembler.impl.AssembledConfiguration;
+import org.apache.logging.log4j.core.config.builder.api.Component;
+import org.apache.logging.log4j.core.config.builder.impl.AssembledConfiguration;
-import java.io.File;
import java.io.IOException;
/**
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
index bcd64bc..8259297 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/properties/PropertiesConfigurationFactory.java
@@ -21,14 +21,14 @@ import org.apache.logging.log4j.core.config.ConfigurationException;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Order;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.AppenderRefComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
+import org.apache.logging.log4j.core.config.builder.api.FilterComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.LoggerComponentBuilder;
+import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.util.PropertiesUtil;
import org.apache.logging.log4j.util.Strings;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/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 39f8ec7..42ac65e 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
@@ -31,10 +31,10 @@ import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilderFactory;
-import org.apache.logging.log4j.core.config.assembler.impl.AssembledConfiguration;
+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.filter.CompositeFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.junit.After;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/ConfigurationAssemblerTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/ConfigurationAssemblerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/ConfigurationAssemblerTest.java
deleted file mode 100644
index 3e0ef2f..0000000
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/assembler/ConfigurationAssemblerTest.java
+++ /dev/null
@@ -1,59 +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.assembler;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LifeCycle;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- *
- */
-public class ConfigurationAssemblerTest {
-
- @Test
- public void doConfigure() throws Exception {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY, "org.apache.logging.log4j.core.config.assembler.CustomConfigurationFactory");
- Configuration config = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
- assertNotNull("No configuration created", config);
- assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
- Map<String, Appender> appenders = config.getAppenders();
- assertNotNull(appenders);
- assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
- Map<String, LoggerConfig> loggers = config.getLoggers();
- assertNotNull(loggers);
- assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
- Filter filter = config.getFilter();
- assertNotNull("No Filter", filter);
- assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
- Logger logger = LogManager.getLogger(getClass());
- logger.info("Welcome to Log4j!");
- }
-}
[3/3] logging-log4j2 git commit: LOG4J2-952 - rename assembler
package to builder
Posted by rg...@apache.org.
LOG4J2-952 - rename assembler package to builder
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7e73c961
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7e73c961
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7e73c961
Branch: refs/heads/LOG4J2-952
Commit: 7e73c961411d8ed5d2efcd85b194cb2d1f120300
Parents: 0280c88
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Aug 30 16:32:04 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Aug 30 16:32:04 2015 -0700
----------------------------------------------------------------------
.../log4j/core/config/ConfigurationFactory.java | 2 +-
.../assembler/api/AppenderComponentBuilder.java | 43 ---
.../api/AppenderRefComponentBuilder.java | 30 --
.../core/config/assembler/api/Assembler.java | 37 ---
.../core/config/assembler/api/Component.java | 80 -----
.../config/assembler/api/ComponentBuilder.java | 95 ------
.../api/CompositeFilterComponentBuilder.java | 30 --
.../assembler/api/ConfigurationBuilder.java | 253 ---------------
.../api/ConfigurationBuilderFactory.java | 39 ---
.../api/CustomLevelComponentBuilder.java | 24 --
.../assembler/api/FilterComponentBuilder.java | 24 --
.../assembler/api/LayoutComponentBuilder.java | 24 --
.../assembler/api/LoggerComponentBuilder.java | 37 ---
.../api/RootLoggerComponentBuilder.java | 37 ---
.../assembler/impl/AssembledConfiguration.java | 141 --------
.../impl/DefaultAppenderComponentBuilder.java | 46 ---
.../DefaultAppenderRefComponentBuilder.java | 41 ---
.../assembler/impl/DefaultComponentBuilder.java | 128 --------
.../DefaultCompositeFilterComponentBuilder.java | 42 ---
.../impl/DefaultConfigurationBuilder.java | 319 -------------------
.../DefaultCustomLevelComponentBuilder.java | 33 --
.../impl/DefaultFilterComponentBuilder.java | 34 --
.../impl/DefaultLayoutComponentBuilder.java | 31 --
.../impl/DefaultLoggerComponentBuilder.java | 66 ----
.../impl/DefaultRootLoggerComponentBuilder.java | 65 ----
.../builder/api/AppenderComponentBuilder.java | 43 +++
.../api/AppenderRefComponentBuilder.java | 30 ++
.../core/config/builder/api/Assembler.java | 37 +++
.../core/config/builder/api/Component.java | 80 +++++
.../config/builder/api/ComponentBuilder.java | 95 ++++++
.../api/CompositeFilterComponentBuilder.java | 30 ++
.../builder/api/ConfigurationBuilder.java | 253 +++++++++++++++
.../api/ConfigurationBuilderFactory.java | 39 +++
.../api/CustomLevelComponentBuilder.java | 24 ++
.../builder/api/FilterComponentBuilder.java | 24 ++
.../builder/api/LayoutComponentBuilder.java | 24 ++
.../builder/api/LoggerComponentBuilder.java | 37 +++
.../builder/api/RootLoggerComponentBuilder.java | 37 +++
.../builder/impl/AssembledConfiguration.java | 141 ++++++++
.../impl/DefaultAppenderComponentBuilder.java | 46 +++
.../DefaultAppenderRefComponentBuilder.java | 41 +++
.../builder/impl/DefaultComponentBuilder.java | 128 ++++++++
.../DefaultCompositeFilterComponentBuilder.java | 42 +++
.../impl/DefaultConfigurationBuilder.java | 319 +++++++++++++++++++
.../DefaultCustomLevelComponentBuilder.java | 33 ++
.../impl/DefaultFilterComponentBuilder.java | 34 ++
.../impl/DefaultLayoutComponentBuilder.java | 31 ++
.../impl/DefaultLoggerComponentBuilder.java | 66 ++++
.../impl/DefaultRootLoggerComponentBuilder.java | 65 ++++
.../properties/PropertiesConfiguration.java | 5 +-
.../PropertiesConfigurationFactory.java | 16 +-
.../log4j/core/config/TestConfigurator.java | 8 +-
.../assembler/ConfigurationAssemblerTest.java | 59 ----
.../assembler/CustomConfigurationFactory.java | 67 ----
.../builder/ConfigurationAssemblerTest.java | 59 ++++
.../builder/CustomConfigurationFactory.java | 67 ++++
56 files changed, 1840 insertions(+), 1841 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index f0d85b8..a6f5404 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -35,7 +35,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
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.lookup.Interpolator;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderComponentBuilder.java
deleted file mode 100644
index 3bed6b2..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderComponentBuilder.java
+++ /dev/null
@@ -1,43 +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.assembler.api;
-
-/**
- * Assembler for constructing Appenders.
- */
-public interface AppenderComponentBuilder extends ComponentBuilder<AppenderComponentBuilder> {
-
- /**
- * Add a Layout to the Appender component.
- * @param assembler The LayoutComponentBuilder with all of its attributes set.
- * @return this Assembler.
- */
- AppenderComponentBuilder add(LayoutComponentBuilder assembler);
-
- /**
- * Add a Filter to the Appender component.
- * @param assembler The FilterComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler.
- */
- AppenderComponentBuilder add(FilterComponentBuilder assembler);
-
- /**
- * Return the name of the Appender.
- * @return the name of the Appender.
- */
- String getName();
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefComponentBuilder.java
deleted file mode 100644
index c492fe3..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefComponentBuilder.java
+++ /dev/null
@@ -1,30 +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.assembler.api;
-
-/**
- * Assembler for constructing AppenderRefs.
- */
-public interface AppenderRefComponentBuilder extends ComponentBuilder<AppenderRefComponentBuilder> {
-
- /**
- * Add a Filter to the Appender component.
- * @param assembler The FilterComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler.
- */
- AppenderRefComponentBuilder add(FilterComponentBuilder assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Assembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Assembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Assembler.java
deleted file mode 100644
index 7cb9e39..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Assembler.java
+++ /dev/null
@@ -1,37 +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.assembler.api;
-
-/**
- * Gathers information in preparation for creating components. These assemblers are primarily useful for
- * aggregating the information that will be used to create a Configuration.
- *
- * @param <T> the Component class this is a builder for.
- */
-public interface Assembler<T> {
-
- /**
- * Builds the plugin object after all configuration has been set. This will use default values for any
- * unspecified attributes for the plugin.
- *
- * @return the configured plugin instance.
- * @throws org.apache.logging.log4j.core.config.ConfigurationException if there was an error building the plugin
- * object.
- */
- T assemble();
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Component.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Component.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Component.java
deleted file mode 100644
index cd12b39..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/Component.java
+++ /dev/null
@@ -1,80 +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.assembler.api;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Container for assembling Configurations. This class is not normally directly manipulated by users
- * of the Assembler API.
- */
-public class Component {
-
- private final Map<String, String> attributes = new HashMap<>();
- private final List<Component> components = new ArrayList<>();
- private final String pluginType;
- private final String value;
-
- public Component(String pluginType) {
- this(pluginType, null, null);
- }
-
- public Component(String pluginType, String name) {
- this(pluginType, name, null);
- }
-
- public Component(String pluginType, String name, String value) {
- this.pluginType = pluginType;
- this.value = value;
- if (name != null && name.length() > 0) {
- attributes.put("name", name);
- }
- }
-
- public Component() {
- this.pluginType = null;
- this.value = null;
- }
-
-
- public String addAttribute(String key, String value) {
- return attributes.put(key, value);
- }
-
- public void addComponent(Component component) {
- components.add(component);
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public List<Component> getComponents() {
- return components;
- }
-
- public String getPluginType() {
- return pluginType;
- }
-
- public String getValue() {
- return value;
- }
- }
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentBuilder.java
deleted file mode 100644
index 12aea81..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentBuilder.java
+++ /dev/null
@@ -1,95 +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.assembler.api;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.util.Builder;
-
-/**
- * Assembler for arbitrary components and the base class for the provided components.
- */
-@SuppressWarnings("rawtypes")
-public interface ComponentBuilder<T extends ComponentBuilder> extends Builder<Component> {
-
- /**
- * Add an attribute to the component.
- * @param key The attribute key.
- * @param value The value of the attribute.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, String value);
-
- /**
- * Add a logging Level attribute to the component.
- * @param key The attribute key.
- * @param level The logging Level.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, Level level);
-
- /**
- * Add an enumeration.
- * @param key The attribute key.
- * @param value The enumeration.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, Enum<?> value);
-
- /**
- * Add an integer attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, int value);
-
- /**
- * Add a boolean attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, boolean value);
-
- /**
- * Add an Object attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentBuilder.
- */
- T addAttribute(String key, Object value);
-
- /**
- * Add a sub component.
- * @param assembler The Assembler for the subcomponent with all of its attributes and sub-components set.
- * @return The ComponentBuilder.
- */
- T addComponent(ComponentBuilder<?> assembler);
-
- /**
- * Return the name of the component, if any.
- * @return The components name or null if it doesn't have one.
- */
- String getName();
-
- /**
- * Retrieve the ConfigurationBuilder.
- * @return The ConfiguratonAssembler.
- */
- ConfigurationBuilder<? extends Configuration> getBuilder();
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterComponentBuilder.java
deleted file mode 100644
index 1b6d795..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterComponentBuilder.java
+++ /dev/null
@@ -1,30 +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.assembler.api;
-
-/**
- * Wraps multiple filter assemblers.
- */
-public interface CompositeFilterComponentBuilder extends ComponentBuilder<CompositeFilterComponentBuilder> {
-
- /**
- * Add a FilterComponent.
- * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
- * @return The CompositeFilterComponentBuilder.
- */
- CompositeFilterComponentBuilder add(FilterComponentBuilder assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilder.java
deleted file mode 100644
index 72f5ec9..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilder.java
+++ /dev/null
@@ -1,253 +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.assembler.api;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.util.Builder;
-
-/**
- * Interface for assembling logging configurations.
- */
-public interface ConfigurationBuilder<T extends Configuration> extends Builder<T> {
-
- /**
- * Set the name of the configuration.
- *
- * @param name the name of the {@link Configuration}. By default is {@code "Constructed"}.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setConfigurationName(String name);
-
- /**
- * Set the configuration source, if one exists.
- * @param configurationSource the ConfigurationSource.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource);
-
- /**
- * Set the level of the StatusLogger.
- * @param level The logging level.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setStatusLevel(Level level);
-
- /**
- * Set whether the logging should include constructing Plugins.
- * @param verbosity "disable" will hide messages from plugin construction.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setVerbosity(String verbosity);
-
- /**
- * Set the list of packages to search for plugins.
- * @param packages The comma separated list of packages.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setPackages(String packages);
-
- /**
- * Set whether the shutdown hook should be disabled.
- * @param flag "disable" will prevent the shutdown hook from being set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setShutdownHook(String flag);
-
- /**
- * Sets the interval at which the configuration file should be checked for changes.
- * @param intervalSeconds The number of seconds that should pass between checks of the configuration file.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> setMonitorInterval(String intervalSeconds);
-
- /**
- * Adds an AppenderComponent.
- * @param assembler The AppenderComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> add(AppenderComponentBuilder assembler);
-
- /**
- * Adds a CustomLevel component.
- * @param assembler The CustomLevelComponentBuilder with all of its attributes set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> add(CustomLevelComponentBuilder assembler);
-
- /**
- * Add a Logger component.
- * @param assembler The LoggerComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> add(LoggerComponentBuilder assembler);
-
- /**
- * Add the root Logger component.
- * @param assembler The RootLoggerComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> add(RootLoggerComponentBuilder assembler);
-
- /**
- * Add a Filter component.
- * @param assembler the FilterComponentBuilder with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> add(FilterComponentBuilder assembler);
-
- /**
- * Add a Property key and value.
- * @param key The property key.
- * @param value The property value.
- * @return this Assembler instance.
- */
- ConfigurationBuilder<T> addProperty(String key, String value);
-
- /**
- * Returns an Assembler for creating Appenders.
- * @param name The name of the Appender.
- * @param pluginName The Plugin type of the Appender.
- * @return the AppenderComponentBuilder.
- */
- AppenderComponentBuilder newAppender(String name, String pluginName);
-
-
- /**
- * Returns an Assembler for creating AppenderRefs.
- * @param ref The name of the Appender being referenced.
- * @return the AppenderRefComponentBuilder.
- */
- AppenderRefComponentBuilder newAppenderRef(String ref);
-
- /**
- * Returns an Assembler for creating generic components.
- * @param name The name of the component (may be null).
- * @param pluginName The Plugin type of the component.
- * @return The ComponentBuilder.
- */
- @SuppressWarnings("rawtypes")
- ComponentBuilder newComponent(String name, String pluginName);
-
- /**
- * Returns an Assembler for creating generic components.
- * @param name The name of the component (may be null).
- * @param pluginName The Plugin type of the component.
- * @param value The value of the component.
- * @return The ComponentBuilder.
- */
- @SuppressWarnings("rawtypes")
- ComponentBuilder<ComponentBuilder> newComponent(String name, String pluginName, String value);
-
- /**
- * Returns an Asssembler for creating CustomLevels
- * @param name The name of the custom level.
- * @param level The integer value to be assigned to the level.
- * @return The CustomLevelComponentBuilder.
- */
- CustomLevelComponentBuilder newCustomLevel(String name, int level);
-
- /**
- * Returns an Asssembler for creating Filters.
- * @param pluginName The Plugin type of the Filter.
- * @param onMatch "ACCEPT", "DENY", or "NEUTRAL"
- * @param onMisMatch "ACCEPT", "DENY", or "NEUTRAL"
- * @return The FilterComponentBuilder.
- */
- FilterComponentBuilder newFilter(String pluginName, Filter.Result onMatch, Filter.Result onMisMatch);
-
- /**
- * Returns an Asssembler for creating Filters.
- * @param pluginName The Plugin type of the Filter.
- * @param onMatch "ACCEPT", "DENY", or "NEUTRAL"
- * @param onMisMatch "ACCEPT", "DENY", or "NEUTRAL"
- * @return The FilterComponentBuilder.
- */
- FilterComponentBuilder newFilter(String pluginName, String onMatch, String onMisMatch);
-
- /**
- * Returns an Assembler for creating Layouts.
- * @param type The Plugin type of the Layout.
- * @return The LayoutComponentBuilder.
- */
- LayoutComponentBuilder newLayout(String pluginName);
-
- /**
- * Returns an Assembler for creating Loggers.
- * @param name The name of the Logger.
- * @param level The logging Level to be assigned to the Logger.
- * @return The LoggerComponentBuilder.
- */
- LoggerComponentBuilder newLogger(String name, Level level);
-
-
- /**
- * Returns an Assembler for creating Loggers.
- * @param name The name of the Logger.
- * @param level The logging Level to be assigned to the Logger.
- * @return The LoggerComponentBuilder.
- */
- LoggerComponentBuilder newLogger(String name, String level);
-
- /**
- * Returns an Assembler for creating Async Loggers.
- * @param name The name of the Logger.
- * @param level The logging Level to be assigned to the Logger.
- * @return The LoggerComponentBuilder.
- */
- LoggerComponentBuilder newAsyncLogger(String name, Level level);
-
- /**
- * Returns an Assembler for creating Async Loggers.
- * @param name The name of the Logger.
- * @param level The logging Level to be assigned to the Logger.
- * @return The LoggerComponentBuilder.
- */
- LoggerComponentBuilder newAsyncLogger(String name, String level);
-
- /**
- * Returns an Assembler for creating the root Logger.
- * @param level The logging Level to be assigned to the root Logger.
- * @return The RootLoggerComponentBuilder.
- */
- RootLoggerComponentBuilder newRootLogger(Level level);
-
- /**
- * Returns an Assembler for creating the root Logger.
- * @param level The logging Level to be assigned to the root Logger.
- * @return The RootLoggerComponentBuilder.
- */
- RootLoggerComponentBuilder newRootLogger(String level);
-
-
- /**
- * Returns an Assembler for creating the async root Logger.
- * @param level The logging Level to be assigned to the root Logger.
- * @return The RootLoggerComponentBuilder.
- */
- RootLoggerComponentBuilder newAsyncRootLogger(Level level);
-
-
- /**
- * Returns an Assembler for creating the async root Logger.
- * @param level The logging Level to be assigned to the root Logger.
- * @return The RootLoggerComponentBuilder.
- */
- RootLoggerComponentBuilder newAsyncRootLogger(String level);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilderFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilderFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilderFactory.java
deleted file mode 100644
index 13fa3b5..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationBuilderFactory.java
+++ /dev/null
@@ -1,39 +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.assembler.api;
-
-import org.apache.logging.log4j.core.config.assembler.impl.AssembledConfiguration;
-import org.apache.logging.log4j.core.config.assembler.impl.DefaultConfigurationBuilder;
-
-/**
- *
- */
-public class ConfigurationBuilderFactory {
-
- /**
- * Returns the default ConfigurationBuilder to construct Log4j configurations.
- * @return The ConfigurationBuilder.
- */
- public static ConfigurationBuilder<AssembledConfiguration> newConfigurationBuilder() {
- return new DefaultConfigurationBuilder<>();
- }
-
- public static <T extends AssembledConfiguration> ConfigurationBuilder<T> newConfigurationBuilder(Class<T> clazz) {
- return new DefaultConfigurationBuilder<T>(clazz);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelComponentBuilder.java
deleted file mode 100644
index 120e026..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelComponentBuilder.java
+++ /dev/null
@@ -1,24 +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.assembler.api;
-
-/**
- * Assembler for constructing Filters
- */
-public interface CustomLevelComponentBuilder extends ComponentBuilder<CustomLevelComponentBuilder> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterComponentBuilder.java
deleted file mode 100644
index 2526963..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterComponentBuilder.java
+++ /dev/null
@@ -1,24 +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.assembler.api;
-
-/**
- * Assembler for constructing Filters
- */
-public interface FilterComponentBuilder extends ComponentBuilder<FilterComponentBuilder> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutComponentBuilder.java
deleted file mode 100644
index b04f9c3..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutComponentBuilder.java
+++ /dev/null
@@ -1,24 +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.assembler.api;
-
-/**
- * Assembler for constructing Layouts
- */
-public interface LayoutComponentBuilder extends ComponentBuilder<LayoutComponentBuilder> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerComponentBuilder.java
deleted file mode 100644
index 628636c..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerComponentBuilder.java
+++ /dev/null
@@ -1,37 +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.assembler.api;
-
-/**
- * Assembler for constructing Loggers.
- */
-public interface LoggerComponentBuilder extends ComponentBuilder<LoggerComponentBuilder> {
-
- /**
- * Add an Appender reference to the Logger component.
- * @param assembler The AppenderRefComponentBuilder with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- LoggerComponentBuilder add(AppenderRefComponentBuilder assembler);
-
- /**
- * Add a Filter to the Logger component.
- * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- LoggerComponentBuilder add(FilterComponentBuilder assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerComponentBuilder.java
deleted file mode 100644
index edf12b4..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerComponentBuilder.java
+++ /dev/null
@@ -1,37 +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.assembler.api;
-
-/**
- * Assembler for constructing the root Logger.
- */
-public interface RootLoggerComponentBuilder extends ComponentBuilder<RootLoggerComponentBuilder> {
-
- /**
- * Add an Appender reference to the Logger component.
- * @param assembler The AppenderRefComponentBuilder with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- RootLoggerComponentBuilder add(AppenderRefComponentBuilder assembler);
-
- /**
- * Add a Filter to the Logger component.
- * @param assembler The FilterComponentBuilder with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- RootLoggerComponentBuilder add(FilterComponentBuilder assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/AssembledConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/AssembledConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/AssembledConfiguration.java
deleted file mode 100644
index afdb259..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.assembler.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.assembler.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/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderComponentBuilder.java
deleted file mode 100644
index 683cab5..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderComponentBuilder.java
+++ /dev/null
@@ -1,46 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutComponentBuilder;
-
-/**
- * Holds the Appender Component attributes and subcomponents.
- */
-public class DefaultAppenderComponentBuilder extends DefaultComponentBuilder<AppenderComponentBuilder> implements
- AppenderComponentBuilder {
-
- public DefaultAppenderComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
- String type) {
- super(assembler, name, type);
- }
-
- @Override
- public AppenderComponentBuilder add(LayoutComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-
- @Override
- public AppenderComponentBuilder add(FilterComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefComponentBuilder.java
deleted file mode 100644
index 609a434..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefComponentBuilder.java
+++ /dev/null
@@ -1,41 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-
-/**
- * Holds the Appender Component attributes and subcomponents.
- */
-public class DefaultAppenderRefComponentBuilder extends DefaultComponentBuilder<AppenderRefComponentBuilder> implements
- AppenderRefComponentBuilder {
-
- public DefaultAppenderRefComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
- String ref) {
- super(assembler, "AppenderRef");
- addAttribute("ref", ref);
- }
-
-
- @Override
- public AppenderRefComponentBuilder add(FilterComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentBuilder.java
deleted file mode 100644
index c0f2c53..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentBuilder.java
+++ /dev/null
@@ -1,128 +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.assembler.impl;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.Component;
-import org.apache.logging.log4j.core.config.assembler.api.ComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Generic component that captures attributes and Components in preparation for assembling the Appender's
- * Component.
- */
-@SuppressWarnings("rawtypes")
-public class DefaultComponentBuilder<T extends ComponentBuilder> implements ComponentBuilder<T> {
-
- private ConfigurationBuilder<? extends Configuration> assembler;
- private String type;
- private Map<String, String> attributes = new HashMap<>();
- private List<Component> components = new ArrayList<>();
- private String name;
- private String value;
-
- public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String type) {
- this(assembler, null, type, null);
- }
-
- public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String name, String type) {
- this(assembler, name, type, null);
- }
-
- public DefaultComponentBuilder(ConfigurationBuilder<? extends Configuration> assembler, String name, String type,
- String value) {
- this.type = type;
- this.assembler = assembler;
- this.name = name;
- this.value = value;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, Level level) {
- attributes.put(key, level.toString());
- return (T) this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, String value) {
- attributes.put(key, value);
- return (T) this;
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, Enum<?> value) {
- attributes.put(key, value.name());
- return (T) this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, int value) {
- attributes.put(key, Integer.toString(value));
- return (T) this;
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, boolean value) {
- attributes.put(key, Boolean.toString(value));
- return (T) this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T addAttribute(String key, Object value) {
- attributes.put(key, value.toString());
- return (T) this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T addComponent(ComponentBuilder<?> assembler) {
- components.add(assembler.build());
- return (T) this;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public ConfigurationBuilder<? extends Configuration> getBuilder() {
- return assembler;
- }
-
- @Override
- public Component build() {
- Component component = new Component(type, name, value);
- component.getAttributes().putAll(attributes);
- component.getComponents().addAll(components);
- return component;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterComponentBuilder.java
deleted file mode 100644
index 2f80047..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterComponentBuilder.java
+++ /dev/null
@@ -1,42 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.CompositeFilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-
-/**
- *
- */
-public class DefaultCompositeFilterComponentBuilder extends DefaultComponentBuilder<CompositeFilterComponentBuilder> implements
- CompositeFilterComponentBuilder {
-
- public DefaultCompositeFilterComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
- String onMatch, String onMisMatch) {
- super(assembler, "Filters");
- addAttribute("onMatch", onMatch);
- addAttribute("onMisMatch", onMisMatch);
- }
-
- @Override
- public CompositeFilterComponentBuilder add(FilterComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationBuilder.java
deleted file mode 100644
index af89d12..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationBuilder.java
+++ /dev/null
@@ -1,319 +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.assembler.impl;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationException;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.Component;
-import org.apache.logging.log4j.core.config.assembler.api.ComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.CustomLevelComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerComponentBuilder;
-
-import java.lang.reflect.Constructor;
-import java.util.List;
-
-/**
- *
- */
-public class DefaultConfigurationBuilder<T extends AssembledConfiguration> implements ConfigurationBuilder<T> {
-
- private AssembledConfiguration configuration;
-
- private final Component root = new Component();
- private Component loggers;
- private Component appenders;
- private Component filters;
- private Component properties;
- private Component customLevels;
- private final Class<?> clazz;
- private ConfigurationSource source;
- private int monitorInterval = 0;
- private Level level = null;
- private String verbosity = null;
- private String packages = null;
- private String shutdownFlag = null;
- private String name = null;
-
- /**
- * The key with which Apache Log4j loads the selector class.
- *
- * @see <a href=
- * "http://logging.apache.org/log4j/2.0/manual/async.html">
- * Async Loggers</a>
- */
- private static final String LOG4J_ASYNC_LOGGERS = "Log4jContextSelector";
-
- public DefaultConfigurationBuilder() {
- this(AssembledConfiguration.class);
- root.addAttribute("name", "Assembled");
- }
-
- public <T extends AssembledConfiguration> DefaultConfigurationBuilder(Class<T> clazz) {
- if (clazz == null) {
- throw new IllegalArgumentException("A Configuration class must be provided");
- }
- this.clazz = clazz;
- List<Component> components = root.getComponents();
- properties = new Component("Properties");
- components.add(properties);
- customLevels = new Component("CustomLevels");
- components.add(customLevels);
- filters = new Component("Filters");
- components.add(filters);
- appenders = new Component("Appenders");
- components.add(appenders);
- loggers = new Component("Loggers");
- components.add(loggers);
- }
-
- /**
- * Set the name of the configuration.
- *
- * @param name the name of the {@link Configuration}. By default is {@code "Assembled"}.
- * @return this builder instance
- */
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setConfigurationName(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Set the ConfigurationSource.
- *
- * @param configurationSource the {@link ConfigurationSource).}
- * @return this builder instance
- */
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setConfigurationSource(ConfigurationSource configurationSource) {
- source = configurationSource;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setMonitorInterval(String intervalSeconds) {
- monitorInterval = Integer.parseInt(intervalSeconds);
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setStatusLevel(Level level) {
- this.level = level;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setVerbosity(String verbosity) {
- this.verbosity = verbosity;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setPackages(String packages) {
- this.packages = packages;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> setShutdownHook(String flag) {
- this.shutdownFlag = flag;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> add(AppenderComponentBuilder assembler) {
- appenders.getComponents().add(assembler.build());
- return this;
- }
-
- @Override
- public ConfigurationBuilder<T> add(CustomLevelComponentBuilder assembler) {
- customLevels.getComponents().add(assembler.build());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> add(LoggerComponentBuilder assembler) {
- loggers.getComponents().add(assembler.build());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> add(RootLoggerComponentBuilder assembler) {
- for (Component c : loggers.getComponents()) {
- if (c.getPluginType().equals("root")) {
- throw new ConfigurationException("root Logger was previously defined");
- }
- }
- loggers.getComponents().add(assembler.build());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> add(FilterComponentBuilder assembler) {
- filters.getComponents().add(assembler.build());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationBuilder<T> addProperty(String key, String value) {
- properties.addComponent(newComponent(key, "Property", value).build());
- return this;
- }
-
- @Override
- public AppenderComponentBuilder newAppender(String name, String type) {
- return new DefaultAppenderComponentBuilder(this, name, type);
- }
-
-
- @Override
- public AppenderRefComponentBuilder newAppenderRef(String ref) {
- return new DefaultAppenderRefComponentBuilder(this, ref);
- }
-
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public ComponentBuilder<ComponentBuilder> newComponent(String name, String type) {
- return new DefaultComponentBuilder(this, name, type);
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public ComponentBuilder<ComponentBuilder> newComponent(String name, String type, String value) {
- return new DefaultComponentBuilder(this, name, type, value);
- }
-
- @Override
- public CustomLevelComponentBuilder newCustomLevel(String name, int level) {
- return new DefaultCustomLevelComponentBuilder(this, name, level);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public FilterComponentBuilder newFilter(String type, String onMatch, String onMisMatch) {
- return new DefaultFilterComponentBuilder(this, type, onMatch, onMisMatch);
- }
-
-
- @Override
- @SuppressWarnings("rawtypes")
- public FilterComponentBuilder newFilter(String type, Filter.Result onMatch, Filter.Result onMisMatch) {
- return new DefaultFilterComponentBuilder(this, type, onMatch.name(), onMisMatch.name());
- }
-
- @Override
- public LayoutComponentBuilder newLayout(String type) {
- return new DefaultLayoutComponentBuilder(this, type);
- }
-
- @Override
- public LoggerComponentBuilder newLogger(String name, String level) {
- return new DefaultLoggerComponentBuilder(this, name, level);
- }
-
- @Override
- public LoggerComponentBuilder newLogger(String name, Level level) {
- return new DefaultLoggerComponentBuilder(this, name, level.toString());
- }
-
- @Override
- public LoggerComponentBuilder newAsyncLogger(String name, String level) {
- return new DefaultLoggerComponentBuilder(this, name, level, "AsyncLogger");
- }
-
- @Override
- public LoggerComponentBuilder newAsyncLogger(String name, Level level) {
- return new DefaultLoggerComponentBuilder(this, name, level.toString(), "AsyncLogger");
- }
-
- @Override
- public RootLoggerComponentBuilder newRootLogger(String level) {
- return new DefaultRootLoggerComponentBuilder(this, level);
- }
-
- @Override
- public RootLoggerComponentBuilder newRootLogger(Level level) {
- return new DefaultRootLoggerComponentBuilder(this, level.toString());
- }
-
- @Override
- public RootLoggerComponentBuilder newAsyncRootLogger(String level) {
- return new DefaultRootLoggerComponentBuilder(this, level, "AsyncRoot");
- }
-
- @Override
- public RootLoggerComponentBuilder newAsyncRootLogger(Level level) {
- return new DefaultRootLoggerComponentBuilder(this, level.toString(), "AsyncRoot");
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T build() {
- AssembledConfiguration configuration;
- try {
- if (source == null) {
- source = ConfigurationSource.NULL_SOURCE;
- }
- Constructor constructor = clazz.getConstructor(ConfigurationSource.class, Component.class);
- configuration = (AssembledConfiguration) constructor.newInstance(source, root);
- configuration.setMonitorInterval(monitorInterval);
- if (name != null) {
- configuration.setName(name);
- }
- if (level != null) {
- configuration.getStatusConfiguration().withStatus(level);
- }
- if (verbosity != null) {
- configuration.getStatusConfiguration().withVerbosity(verbosity);
- }
- if (packages != null) {
- configuration.setPluginPackages(packages);
- }
- if (shutdownFlag != null) {
- configuration.setShutdownHook(shutdownFlag);
- }
- } catch (Exception ex) {
- throw new IllegalArgumentException("Invalid Configuration class specified", ex);
- }
- configuration.getStatusConfiguration().initialize();
- configuration.initialize();
- return (T)configuration;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelComponentBuilder.java
deleted file mode 100644
index a51fefd..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelComponentBuilder.java
+++ /dev/null
@@ -1,33 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.CustomLevelComponentBuilder;
-
-/**
- *
- */
-public class DefaultCustomLevelComponentBuilder extends DefaultComponentBuilder<CustomLevelComponentBuilder> implements
- CustomLevelComponentBuilder {
-
- public DefaultCustomLevelComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
- String name, int level) {
- super(assembler, name, "CustomLevel");
- addAttribute("level", Integer.toString(level));
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterComponentBuilder.java
deleted file mode 100644
index e27d51a..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterComponentBuilder.java
+++ /dev/null
@@ -1,34 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-
-/**
- *
- */
-public class DefaultFilterComponentBuilder extends DefaultComponentBuilder<FilterComponentBuilder> implements
- FilterComponentBuilder {
-
- public DefaultFilterComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String type,
- String onMatch, String onMisMatch) {
- super(assembler, type);
- addAttribute("onMatch", onMatch);
- addAttribute("onMisMatch", onMisMatch);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutComponentBuilder.java
deleted file mode 100644
index abea81e..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutComponentBuilder.java
+++ /dev/null
@@ -1,31 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutComponentBuilder;
-
-/**
- *
- */
-public class DefaultLayoutComponentBuilder extends DefaultComponentBuilder<LayoutComponentBuilder> implements
- LayoutComponentBuilder {
-
- public DefaultLayoutComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String type) {
- super(assembler, type);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerComponentBuilder.java
deleted file mode 100644
index d5b894b..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerComponentBuilder.java
+++ /dev/null
@@ -1,66 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerComponentBuilder;
-
-/**
- *
- */
-public class DefaultLoggerComponentBuilder extends DefaultComponentBuilder<LoggerComponentBuilder> implements
- LoggerComponentBuilder {
-
- /**
- * Configure a logger.
- * @param assembler
- * @param name
- * @param level
- */
- public DefaultLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
- String level) {
- super(assembler, name, "Logger");
- addAttribute("level", level);
- }
-
- /**
- * Configure a logger.
- * @param assembler
- * @param name
- * @param level
- * @param type
- */
- public DefaultLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler, String name,
- String level, String type) {
- super(assembler, name, type);
- addAttribute("level", level);
- }
-
- @Override
- public LoggerComponentBuilder add(AppenderRefComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-
- @Override
- public LoggerComponentBuilder add(FilterComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerComponentBuilder.java
deleted file mode 100644
index 2af9d97..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerComponentBuilder.java
+++ /dev/null
@@ -1,65 +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.assembler.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.FilterComponentBuilder;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerComponentBuilder;
-
-/**
- *
- */
-public class DefaultRootLoggerComponentBuilder extends DefaultComponentBuilder<RootLoggerComponentBuilder> implements
- RootLoggerComponentBuilder {
-
- /**
- * Configure the root logger.
- * @param assembler
- * @param level
- */
- public DefaultRootLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
- String level) {
- super(assembler, "", "Root");
- addAttribute("level", level);
- }
-
- /**
- * Configure the root logger.
- * @param assembler
- * @param level
- * @param type
- */
- public DefaultRootLoggerComponentBuilder(DefaultConfigurationBuilder<? extends Configuration> assembler,
- String level, String type) {
- super(assembler, "", type);
- addAttribute("level", level);
- }
-
- @Override
- public RootLoggerComponentBuilder add(AppenderRefComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-
-
- @Override
- public RootLoggerComponentBuilder add(FilterComponentBuilder assembler) {
- addComponent(assembler);
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7e73c961/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderComponentBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderComponentBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderComponentBuilder.java
new file mode 100644
index 0000000..e433df6
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/AppenderComponentBuilder.java
@@ -0,0 +1,43 @@
+/*
+ * 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.api;
+
+/**
+ * Assembler for constructing Appenders.
+ */
+public interface AppenderComponentBuilder extends ComponentBuilder<AppenderComponentBuilder> {
+
+ /**
+ * Add a Layout to the Appender component.
+ * @param assembler The LayoutComponentBuilder with all of its attributes set.
+ * @return this Assembler.
+ */
+ AppenderComponentBuilder add(LayoutComponentBuilder assembler);
+
+ /**
+ * Add a Filter to the Appender component.
+ * @param assembler The FilterComponentBuilder with all of its attributes and sub components set.
+ * @return this Assembler.
+ */
+ AppenderComponentBuilder add(FilterComponentBuilder assembler);
+
+ /**
+ * Return the name of the Appender.
+ * @return the name of the Appender.
+ */
+ String getName();
+}