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/30 21:46:16 UTC
[1/3] logging-log4j2 git commit: LOG4J2-952 - Create initialize
lifecycle phase. Rename classes to be Builders
Repository: logging-log4j2
Updated Branches:
refs/heads/LOG4J2-952 b8f29d8a9 -> 0280c886f
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..c0f2c53
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterAssembler.java
deleted file mode 100644
index 39f9c11..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCompositeFilterAssembler.java
+++ /dev/null
@@ -1,40 +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.CompositeFilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-
-/**
- *
- */
-public class DefaultCompositeFilterAssembler extends DefaultComponentAssembler<CompositeFilterAssembler> implements CompositeFilterAssembler {
-
- public DefaultCompositeFilterAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String onMatch, String onMisMatch) {
- super(assembler, "Filters");
- addAttribute("onMatch", onMatch);
- addAttribute("onMisMatch", onMisMatch);
- }
-
- @Override
- public CompositeFilterAssembler add(FilterAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..2f80047
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationAssembler.java
deleted file mode 100644
index c72ef49..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultConfigurationAssembler.java
+++ /dev/null
@@ -1,318 +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.AppenderAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.Component;
-import org.apache.logging.log4j.core.config.assembler.api.ComponentAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.CustomLevelAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerAssembler;
-
-import java.lang.reflect.Constructor;
-import java.util.List;
-
-/**
- *
- */
-public class DefaultConfigurationAssembler<T extends AssembledConfiguration> implements ConfigurationAssembler<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 DefaultConfigurationAssembler() {
- this(AssembledConfiguration.class);
- root.addAttribute("name", "Assembled");
- }
-
- public <T extends AssembledConfiguration> DefaultConfigurationAssembler(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 ConfigurationAssembler<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 ConfigurationAssembler<T> setConfigurationSource(ConfigurationSource configurationSource) {
- source = configurationSource;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> setMonitorInterval(String intervalSeconds) {
- monitorInterval = Integer.parseInt(intervalSeconds);
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> setStatusLevel(Level level) {
- this.level = level;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> setVerbosity(String verbosity) {
- this.verbosity = verbosity;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> setPackages(String packages) {
- this.packages = packages;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> setShutdownHook(String flag) {
- this.shutdownFlag = flag;
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> add(AppenderAssembler assembler) {
- appenders.getComponents().add(assembler.assemble());
- return this;
- }
-
- @Override
- public ConfigurationAssembler<T> add(CustomLevelAssembler assembler) {
- customLevels.getComponents().add(assembler.assemble());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> add(LoggerAssembler assembler) {
- loggers.getComponents().add(assembler.assemble());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> add(RootLoggerAssembler assembler) {
- for (Component c : loggers.getComponents()) {
- if (c.getPluginType().equals("root")) {
- throw new ConfigurationException("root Logger was previously defined");
- }
- }
- loggers.getComponents().add(assembler.assemble());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> add(FilterAssembler assembler) {
- filters.getComponents().add(assembler.assemble());
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public ConfigurationAssembler<T> addProperty(String key, String value) {
- properties.addComponent(newComponent(key, "Property", value).assemble());
- return this;
- }
-
- @Override
- public AppenderAssembler newAppender(String name, String type) {
- return new DefaultAppenderAssembler(this, name, type);
- }
-
-
- @Override
- public AppenderRefAssembler newAppenderRef(String ref) {
- return new DefaultAppenderRefAssembler(this, ref);
- }
-
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public ComponentAssembler<ComponentAssembler> newComponent(String name, String type) {
- return new DefaultComponentAssembler(this, name, type);
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public ComponentAssembler<ComponentAssembler> newComponent(String name, String type, String value) {
- return new DefaultComponentAssembler(this, name, type, value);
- }
-
- @Override
- public CustomLevelAssembler newCustomLevel(String name, int level) {
- return new DefaultCustomLevelAssembler(this, name, level);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public FilterAssembler newFilter(String type, String onMatch, String onMisMatch) {
- return new DefaultFilterAssembler(this, type, onMatch, onMisMatch);
- }
-
-
- @Override
- @SuppressWarnings("rawtypes")
- public FilterAssembler newFilter(String type, Filter.Result onMatch, Filter.Result onMisMatch) {
- return new DefaultFilterAssembler(this, type, onMatch.name(), onMisMatch.name());
- }
-
- @Override
- public LayoutAssembler newLayout(String type) {
- return new DefaultLayoutAssembler(this, type);
- }
-
- @Override
- public LoggerAssembler newLogger(String name, String level) {
- return new DefaultLoggerAssembler(this, name, level);
- }
-
- @Override
- public LoggerAssembler newLogger(String name, Level level) {
- return new DefaultLoggerAssembler(this, name, level.toString());
- }
-
- @Override
- public LoggerAssembler newAsyncLogger(String name, String level) {
- return new DefaultLoggerAssembler(this, name, level, "AsyncLogger");
- }
-
- @Override
- public LoggerAssembler newAsyncLogger(String name, Level level) {
- return new DefaultLoggerAssembler(this, name, level.toString(), "AsyncLogger");
- }
-
- @Override
- public RootLoggerAssembler newRootLogger(String level) {
- return new DefaultRootLoggerAssembler(this, level);
- }
-
- @Override
- public RootLoggerAssembler newRootLogger(Level level) {
- return new DefaultRootLoggerAssembler(this, level.toString());
- }
-
- @Override
- public RootLoggerAssembler newAsyncRootLogger(String level) {
- return new DefaultRootLoggerAssembler(this, level, "AsyncRoot");
- }
-
- @Override
- public RootLoggerAssembler newAsyncRootLogger(Level level) {
- return new DefaultRootLoggerAssembler(this, level.toString(), "AsyncRoot");
- }
-
- @Override
- @SuppressWarnings({"unchecked", "rawtypes"})
- public T assemble() {
- 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();
- return (T)configuration;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..af89d12
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelAssembler.java
deleted file mode 100644
index 8b5bfed..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultCustomLevelAssembler.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.CustomLevelAssembler;
-
-/**
- *
- */
-public class DefaultCustomLevelAssembler extends DefaultComponentAssembler<CustomLevelAssembler> implements
- CustomLevelAssembler {
-
- public DefaultCustomLevelAssembler(DefaultConfigurationAssembler<? 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/20fd2273/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
new file mode 100644
index 0000000..a51fefd
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterAssembler.java
deleted file mode 100644
index f615846..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultFilterAssembler.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.FilterAssembler;
-
-/**
- *
- */
-public class DefaultFilterAssembler extends DefaultComponentAssembler<FilterAssembler> implements FilterAssembler {
-
- public DefaultFilterAssembler(DefaultConfigurationAssembler<? 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/20fd2273/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
new file mode 100644
index 0000000..e27d51a
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutAssembler.java
deleted file mode 100644
index 08da646..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLayoutAssembler.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.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutAssembler;
-
-/**
- *
- */
-public class DefaultLayoutAssembler extends DefaultComponentAssembler<LayoutAssembler> implements LayoutAssembler {
-
- public DefaultLayoutAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String type) {
- super(assembler, type);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..abea81e
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerAssembler.java
deleted file mode 100644
index 22a1e51..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultLoggerAssembler.java
+++ /dev/null
@@ -1,63 +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.AppenderRefAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerAssembler;
-
-/**
- *
- */
-public class DefaultLoggerAssembler extends DefaultComponentAssembler<LoggerAssembler> implements LoggerAssembler {
-
- /**
- * Configure a logger.
- * @param assembler
- * @param name
- * @param level
- */
- public DefaultLoggerAssembler(DefaultConfigurationAssembler<? 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 DefaultLoggerAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String name, String level, String type) {
- super(assembler, name, type);
- addAttribute("level", level);
- }
-
- @Override
- public LoggerAssembler add(AppenderRefAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-
- @Override
- public LoggerAssembler add(FilterAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..d5b894b
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerAssembler.java
deleted file mode 100644
index d5ad8dd..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultRootLoggerAssembler.java
+++ /dev/null
@@ -1,62 +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.AppenderRefAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerAssembler;
-
-/**
- *
- */
-public class DefaultRootLoggerAssembler extends DefaultComponentAssembler<RootLoggerAssembler> implements RootLoggerAssembler {
-
- /**
- * Configure the root logger.
- * @param assembler
- * @param level
- */
- public DefaultRootLoggerAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String level) {
- super(assembler, "", "Root");
- addAttribute("level", level);
- }
-
- /**
- * Configure the root logger.
- * @param assembler
- * @param level
- * @param type
- */
- public DefaultRootLoggerAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String level, String type) {
- super(assembler, "", type);
- addAttribute("level", level);
- }
-
- @Override
- public RootLoggerAssembler add(AppenderRefAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-
-
- @Override
- public RootLoggerAssembler add(FilterAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..2af9d97
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/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 aa40697..bcd64bc 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.AppenderAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ComponentAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LoggerAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.RootLoggerAssembler;
+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.plugins.Plugin;
import org.apache.logging.log4j.core.util.PropertiesUtil;
import org.apache.logging.log4j.util.Strings;
@@ -65,42 +65,42 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
} catch (IOException ioe) {
throw new ConfigurationException("Unable to load " + source.toString(), ioe);
}
- ConfigurationAssembler<PropertiesConfiguration> assembler = newConfiguration(PropertiesConfiguration.class);
+ ConfigurationBuilder<PropertiesConfiguration> builder = newConfigurationBuilder(PropertiesConfiguration.class);
String value = properties.getProperty(STATUS_KEY);
if (value != null) {
- assembler.setStatusLevel(Level.toLevel(value, Level.ERROR));
+ builder.setStatusLevel(Level.toLevel(value, Level.ERROR));
} else {
- assembler.setStatusLevel(Level.ERROR);
+ builder.setStatusLevel(Level.ERROR);
}
value = properties.getProperty(SHUTDOWN_HOOK);
if (value != null) {
- assembler.setShutdownHook(value);
+ builder.setShutdownHook(value);
}
value = properties.getProperty(VERBOSE);
if (value != null) {
- assembler.setVerbosity(value);
+ builder.setVerbosity(value);
}
value = properties.getProperty(PACKAGES);
if (value != null) {
- assembler.setPackages(value);
+ builder.setPackages(value);
}
value = properties.getProperty(CONFIG_NAME);
if (value != null) {
- assembler.setConfigurationName(value);
+ builder.setConfigurationName(value);
}
value = properties.getProperty(MONITOR_INTERVAL);
if (value != null) {
- assembler.setMonitorInterval(value);
+ builder.setMonitorInterval(value);
}
Properties props = PropertiesUtil.extractSubset(properties, "property");
for (String key : props.stringPropertyNames()) {
- assembler.addProperty(key, props.getProperty(key));
+ builder.addProperty(key, props.getProperty(key));
}
Properties levelProps = PropertiesUtil.extractSubset(properties, "customLevel");
if (levelProps.size() > 0) {
for (String key : levelProps.stringPropertyNames()) {
- assembler.add(assembler.newCustomLevel(key, Integer.parseInt(props.getProperty(key))));
+ builder.add(builder.newCustomLevel(key, Integer.parseInt(props.getProperty(key))));
}
}
@@ -109,7 +109,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
String[] filterNames = filterProp.split(",");
for (String filterName : filterNames) {
String name = filterName.trim();
- assembler.add(createFilter(assembler, name, PropertiesUtil.extractSubset(properties, "filter." + name)));
+ builder.add(createFilter(builder, name, PropertiesUtil.extractSubset(properties, "filter." + name)));
}
}
String appenderProp = properties.getProperty("appenders");
@@ -117,8 +117,8 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
String[] appenderNames = appenderProp.split(",");
for (String appenderName : appenderNames) {
String name = appenderName.trim();
- assembler.add(
- createAppender(assembler, name, PropertiesUtil.extractSubset(properties, "appender." + name)));
+ builder.add(
+ createAppender(builder, name, PropertiesUtil.extractSubset(properties, "appender." + name)));
}
}
String loggerProp = properties.getProperty("loggers");
@@ -127,21 +127,21 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
for (String loggerName : loggerNames) {
String name = loggerName.trim();
if (!name.equals("root")) {
- assembler.add(
- createLogger(assembler, name, PropertiesUtil.extractSubset(properties, "logger." + name)));
+ builder.add(
+ createLogger(builder, name, PropertiesUtil.extractSubset(properties, "logger." + name)));
}
}
}
props = PropertiesUtil.extractSubset(properties, "rootLogger");
if (props.size() > 0) {
- assembler.add(createRootLogger(assembler, props));
+ builder.add(createRootLogger(builder, props));
}
- return assembler.assemble();
+ return builder.build();
}
- private AppenderAssembler createAppender(ConfigurationAssembler<PropertiesConfiguration> assembler, String key, Properties properties) {
+ private AppenderComponentBuilder createAppender(ConfigurationBuilder<PropertiesConfiguration> builder, String key, Properties properties) {
String name = properties.getProperty(CONFIG_NAME);
if (Strings.isEmpty(name)) {
throw new ConfigurationException("No name attribute provided for Appender " + key);
@@ -152,7 +152,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
throw new ConfigurationException("No type attribute provided for Appender " + key);
}
properties.remove(CONFIG_TYPE);
- AppenderAssembler appenderAssembler = assembler.newAppender(name, type);
+ AppenderComponentBuilder appenderAssembler = builder.newAppender(name, type);
String filters = properties.getProperty("filters");
if (filters != null) {
properties.remove("filters");
@@ -160,19 +160,19 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
for (String filterName : filterNames) {
filterName = filterName.trim();
Properties filterProps = PropertiesUtil.extractSubset(properties, "filter." + filterName);
- appenderAssembler.add(createFilter(assembler, filterName, filterProps));
+ appenderAssembler.add(createFilter(builder, filterName, filterProps));
}
}
Properties layoutProps = PropertiesUtil.extractSubset(properties, "layout");
if (layoutProps.size() > 0) {
- appenderAssembler.add(createLayout(assembler, name, layoutProps));
+ appenderAssembler.add(createLayout(builder, name, layoutProps));
}
processRemainingProperties(appenderAssembler, name, properties);
return appenderAssembler;
}
- private FilterAssembler createFilter(ConfigurationAssembler<PropertiesConfiguration> assembler, String key, Properties properties) {
+ private FilterComponentBuilder createFilter(ConfigurationBuilder<PropertiesConfiguration> assembler, String key, Properties properties) {
String type = properties.getProperty(CONFIG_TYPE);
if (Strings.isEmpty(type)) {
throw new ConfigurationException("No type attribute provided for Appender " + key);
@@ -186,18 +186,18 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
if (onMisMatch != null) {
properties.remove("onMisMatch");
}
- FilterAssembler filterAssembler = assembler.newFilter(type, onMatch, onMisMatch);
+ FilterComponentBuilder filterAssembler = assembler.newFilter(type, onMatch, onMisMatch);
processRemainingProperties(filterAssembler, key, properties);
return filterAssembler;
}
- private AppenderRefAssembler createAppenderRef(ConfigurationAssembler<PropertiesConfiguration> assembler, String key, Properties properties) {
+ private AppenderRefComponentBuilder createAppenderRef(ConfigurationBuilder<PropertiesConfiguration> assembler, String key, Properties properties) {
String ref = properties.getProperty("ref");
if (Strings.isEmpty(ref)) {
throw new ConfigurationException("No ref attribute provided for AppenderRef " + key);
}
properties.remove("ref");
- AppenderRefAssembler appenderRefAssembler = assembler.newAppenderRef(ref);
+ AppenderRefComponentBuilder appenderRefAssembler = assembler.newAppenderRef(ref);
String level = properties.getProperty("level");
if (!Strings.isEmpty(level)) {
appenderRefAssembler.addAttribute("level", level);
@@ -215,7 +215,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
return appenderRefAssembler;
}
- private LoggerAssembler createLogger(ConfigurationAssembler<PropertiesConfiguration> assembler, String key, Properties properties) {
+ private LoggerComponentBuilder createLogger(ConfigurationBuilder<PropertiesConfiguration> assembler, String key, Properties properties) {
String name = properties.getProperty(CONFIG_NAME);
if (Strings.isEmpty(name)) {
throw new ConfigurationException("No name attribute provided for Logger " + key);
@@ -225,7 +225,7 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
if (level != null) {
properties.remove("level");
}
- LoggerAssembler loggerAssembler;
+ LoggerComponentBuilder loggerAssembler;
String type = properties.getProperty(CONFIG_TYPE);
if (type != null) {
if (type.equalsIgnoreCase("asyncLogger")) {
@@ -263,12 +263,12 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
return loggerAssembler;
}
- private RootLoggerAssembler createRootLogger(ConfigurationAssembler<PropertiesConfiguration> assembler, Properties properties) {
+ private RootLoggerComponentBuilder createRootLogger(ConfigurationBuilder<PropertiesConfiguration> assembler, Properties properties) {
String level = properties.getProperty("level");
if (level != null) {
properties.remove("level");
}
- RootLoggerAssembler loggerAssembler;
+ RootLoggerComponentBuilder loggerAssembler;
String type = properties.getProperty(CONFIG_TYPE);
if (type != null) {
if (type.equalsIgnoreCase("asyncRoot")) {
@@ -302,19 +302,19 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
return loggerAssembler;
}
- private LayoutAssembler createLayout(ConfigurationAssembler<PropertiesConfiguration> assembler, String appenderName, Properties properties) {
+ private LayoutComponentBuilder createLayout(ConfigurationBuilder<PropertiesConfiguration> assembler, String appenderName, Properties properties) {
String type = properties.getProperty(CONFIG_TYPE);
if (Strings.isEmpty(type)) {
throw new ConfigurationException("No type attribute provided for Layout on Appender " + appenderName);
}
properties.remove(CONFIG_TYPE);
- LayoutAssembler layoutAssembler = assembler.newLayout(type);
+ LayoutComponentBuilder layoutAssembler = assembler.newLayout(type);
processRemainingProperties(layoutAssembler, appenderName, properties);
return layoutAssembler;
}
@SuppressWarnings("rawtypes")
- private ComponentAssembler<?> createComponent(ComponentAssembler parent, String key, Properties properties) {
+ private ComponentBuilder<?> createComponent(ComponentBuilder parent, String key, Properties properties) {
String name = properties.getProperty(CONFIG_NAME);
if (name != null) {
properties.remove(CONFIG_NAME);
@@ -324,14 +324,13 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
throw new ConfigurationException("No type attribute provided for component " + key);
}
properties.remove(CONFIG_TYPE);
- @SuppressWarnings("unchecked")
- ComponentAssembler<?> componentAssembler = parent.getAssembler().newComponent(name, type);
+ @SuppressWarnings("unchecked") ComponentBuilder<?> componentAssembler = parent.getBuilder().newComponent(name, type);
processRemainingProperties(componentAssembler, name, properties);
return componentAssembler;
}
@SuppressWarnings({"unchecked", "rawtypes"})
- private void processRemainingProperties(ComponentAssembler assembler, String name, Properties properties) {
+ private void processRemainingProperties(ComponentBuilder assembler, String name, Properties properties) {
while (properties.size() > 0) {
String propertyName = properties.stringPropertyNames().iterator().next();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
index a62d066..f715495 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/server/JmsServer.java
@@ -80,6 +80,10 @@ public class JmsServer extends LogEventListener implements MessageListener, Life
}
@Override
+ public void initialize() {
+ }
+
+ @Override
public void start() {
if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
try {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
index 9945b4d..7e432be 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DefaultShutdownCallbackRegistry.java
@@ -114,6 +114,10 @@ public class DefaultShutdownCallbackRegistry implements ShutdownCallbackRegistry
state.get().name());
}
+ @Override
+ public void initialize() {
+ }
+
/**
* Registers the shutdown thread only if this is initialized.
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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 9bbecf8..39f8ec7 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,9 +31,9 @@ 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.AppenderAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssemblerFactory;
+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.filter.CompositeFilter;
import org.apache.logging.log4j.core.layout.PatternLayout;
@@ -362,12 +362,12 @@ public class TestConfigurator {
@Test
public void testAssembler() throws Exception {
- ConfigurationAssembler<AssembledConfiguration> assembler = ConfigurationAssemblerFactory.newConfiguration();
+ ConfigurationBuilder<AssembledConfiguration> assembler = ConfigurationBuilderFactory.newConfigurationBuilder();
assembler.setStatusLevel(Level.ERROR);
- assembler.setConfigurationName("AssemblyTest");
+ assembler.setConfigurationName("BuilderTest");
assembler.add(assembler.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
.addAttribute("level", Level.DEBUG));
- AppenderAssembler appenderAssembler = assembler.newAppender("Stdout", "CONSOLE").addAttribute("target",
+ 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"));
@@ -378,10 +378,10 @@ public class TestConfigurator {
add(assembler.newAppenderRef("Stdout")).
addAttribute("additivity", false));
assembler.add(assembler.newRootLogger(Level.ERROR).add(assembler.newAppenderRef("Stdout")));
- ctx = Configurator.initialize(assembler.assemble());
+ ctx = Configurator.initialize(assembler.build());
final Configuration config = ctx.getConfiguration();
assertNotNull("No configuration", config);
- assertEquals("Unexpected Configuration", "AssemblyTest", config.getName());
+ assertEquals("Unexpected Configuration", "BuilderTest", config.getName());
assertThat(config.getAppenders(), hasSize(equalTo(1)));
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
index 21e7f65..96c7bcf 100644
--- 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
@@ -22,8 +22,8 @@ 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.AppenderAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssembler;
+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;
@@ -48,11 +48,11 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
@Override
public Configuration getConfiguration(final String name, final URI configLocation) {
- ConfigurationAssembler<AssembledConfiguration> assembler = newConfiguration();
+ ConfigurationBuilder<AssembledConfiguration> assembler = newConfigurationBuilder();
assembler.setStatusLevel(Level.ERROR);
assembler.add(assembler.newFilter("ThresholdFilter", Filter.Result.ACCEPT, Filter.Result.NEUTRAL)
.addAttribute("level", Level.DEBUG));
- AppenderAssembler appenderAssembler = assembler.newAppender("Stdout", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
+ 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,
@@ -62,6 +62,6 @@ public class CustomConfigurationFactory extends ConfigurationFactory {
add(assembler.newAppenderRef("Stdout")).
addAttribute("additivity", false));
assembler.add(assembler.newRootLogger(Level.ERROR).add(assembler.newAppenderRef("Stdout")));
- return assembler.assemble();
+ return assembler.build();
}
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/test/resources/log4j2-properties.properties
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j2-properties.properties b/log4j-core/src/test/resources/log4j2-properties.properties
index 56afedf..35d2c90 100644
--- a/log4j-core/src/test/resources/log4j2-properties.properties
+++ b/log4j-core/src/test/resources/log4j2-properties.properties
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+status = DEBUG
+
filters = Threshold
filter.Threshold.type = ThresholdFilter
[3/3] logging-log4j2 git commit: LOG4J2-952 - change status logging
level to error
Posted by rg...@apache.org.
LOG4J2-952 - change status logging level to error
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0280c886
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0280c886
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0280c886
Branch: refs/heads/LOG4J2-952
Commit: 0280c886fa66f45aafa440458e9e13a771233d20
Parents: 20fd227
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Aug 30 12:46:00 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Aug 30 12:46:00 2015 -0700
----------------------------------------------------------------------
log4j-core/src/test/resources/log4j2-properties.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0280c886/log4j-core/src/test/resources/log4j2-properties.properties
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j2-properties.properties b/log4j-core/src/test/resources/log4j2-properties.properties
index 35d2c90..716a9ca 100644
--- a/log4j-core/src/test/resources/log4j2-properties.properties
+++ b/log4j-core/src/test/resources/log4j2-properties.properties
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-status = DEBUG
+status = ERROR
filters = Threshold
[2/3] logging-log4j2 git commit: LOG4J2-952 - Create initialize
lifecycle phase. Rename classes to be Builders
Posted by rg...@apache.org.
LOG4J2-952 - Create initialize lifecycle phase. Rename classes to be Builders
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/20fd2273
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/20fd2273
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/20fd2273
Branch: refs/heads/LOG4J2-952
Commit: 20fd22733df1b03a10132f84369dbd20abfb55ab
Parents: b8f29d8
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Aug 30 12:33:58 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Aug 30 12:38:24 2015 -0700
----------------------------------------------------------------------
.../logging/log4j/core/AbstractLifeCycle.java | 5 +
.../apache/logging/log4j/core/LifeCycle.java | 4 +
.../core/config/AbstractConfiguration.java | 21 +-
.../log4j/core/config/ConfigurationFactory.java | 4 +-
.../config/assembler/api/AppenderAssembler.java | 43 ---
.../assembler/api/AppenderComponentBuilder.java | 43 +++
.../assembler/api/AppenderRefAssembler.java | 30 --
.../api/AppenderRefComponentBuilder.java | 30 ++
.../assembler/api/ComponentAssembler.java | 94 ------
.../config/assembler/api/ComponentBuilder.java | 95 ++++++
.../assembler/api/CompositeFilterAssembler.java | 30 --
.../api/CompositeFilterComponentBuilder.java | 30 ++
.../assembler/api/ConfigurationAssembler.java | 252 ---------------
.../api/ConfigurationAssemblerFactory.java | 39 ---
.../assembler/api/ConfigurationBuilder.java | 253 +++++++++++++++
.../api/ConfigurationBuilderFactory.java | 39 +++
.../assembler/api/CustomLevelAssembler.java | 24 --
.../api/CustomLevelComponentBuilder.java | 24 ++
.../config/assembler/api/FilterAssembler.java | 24 --
.../assembler/api/FilterComponentBuilder.java | 24 ++
.../config/assembler/api/LayoutAssembler.java | 24 --
.../assembler/api/LayoutComponentBuilder.java | 24 ++
.../config/assembler/api/LoggerAssembler.java | 37 ---
.../assembler/api/LoggerComponentBuilder.java | 37 +++
.../assembler/api/RootLoggerAssembler.java | 37 ---
.../api/RootLoggerComponentBuilder.java | 37 +++
.../impl/DefaultAppenderAssembler.java | 44 ---
.../impl/DefaultAppenderComponentBuilder.java | 46 +++
.../impl/DefaultAppenderRefAssembler.java | 39 ---
.../DefaultAppenderRefComponentBuilder.java | 41 +++
.../impl/DefaultComponentAssembler.java | 127 --------
.../assembler/impl/DefaultComponentBuilder.java | 128 ++++++++
.../impl/DefaultCompositeFilterAssembler.java | 40 ---
.../DefaultCompositeFilterComponentBuilder.java | 42 +++
.../impl/DefaultConfigurationAssembler.java | 318 ------------------
.../impl/DefaultConfigurationBuilder.java | 319 +++++++++++++++++++
.../impl/DefaultCustomLevelAssembler.java | 33 --
.../DefaultCustomLevelComponentBuilder.java | 33 ++
.../assembler/impl/DefaultFilterAssembler.java | 33 --
.../impl/DefaultFilterComponentBuilder.java | 34 ++
.../assembler/impl/DefaultLayoutAssembler.java | 30 --
.../impl/DefaultLayoutComponentBuilder.java | 31 ++
.../assembler/impl/DefaultLoggerAssembler.java | 63 ----
.../impl/DefaultLoggerComponentBuilder.java | 66 ++++
.../impl/DefaultRootLoggerAssembler.java | 62 ----
.../impl/DefaultRootLoggerComponentBuilder.java | 65 ++++
.../PropertiesConfigurationFactory.java | 85 +++--
.../log4j/core/net/server/JmsServer.java | 4 +
.../util/DefaultShutdownCallbackRegistry.java | 4 +
.../log4j/core/config/TestConfigurator.java | 16 +-
.../assembler/CustomConfigurationFactory.java | 10 +-
.../test/resources/log4j2-properties.properties | 2 +
52 files changed, 1535 insertions(+), 1484 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
index f4fabab..08d273b 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractLifeCycle.java
@@ -111,6 +111,11 @@ public class AbstractLifeCycle implements LifeCycle, Serializable {
}
@Override
+ public void initialize() {
+ this.state = State.INITIALIZED;
+ }
+
+ @Override
public void start() {
this.setStarted();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
index 7dfdbe9..4562f5a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
@@ -33,6 +33,8 @@ public interface LifeCycle {
* Status of a life cycle like a {@link LoggerContext}.
*/
public enum State {
+ /** Object is in its initial state and not yet initialized */
+ INITIAL,
/** Initialized but not yet started. */
INITIALIZED,
/** In the process of starting. */
@@ -51,6 +53,8 @@ public interface LifeCycle {
* @return the life-cycle state
*/
State getState();
+
+ void initialize();
void start();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index aedd25b..d16e556 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -117,6 +117,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
componentMap.put(Configuration.CONTEXT_PROPERTIES, properties);
pluginManager = new PluginManager(Node.CATEGORY);
rootNode = new Node();
+ setState(State.INITIAL);
}
@Override
@@ -138,9 +139,8 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
* Initialize the configuration.
*/
@Override
- public void start() {
- LOGGER.debug("Starting configuration {}", this);
- this.setStarting();
+ public void initialize() {
+ LOGGER.debug("Initializing configuration {}", this);
pluginManager.collectPlugins(pluginPackages);
final PluginManager levelPlugins = new PluginManager(Level.CATEGORY);
levelPlugins.collectPlugins(pluginPackages);
@@ -159,6 +159,21 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
setup();
setupAdvertisement();
doConfigure();
+ setState(State.INITIALIZED);
+ LOGGER.debug("Configuration {} initialized", this);
+ }
+
+ /**
+ * Start the configuration
+ */
+ @Override
+ public void start() {
+ // Preserve the prior behavior of initializing during start if not initialized.
+ if (getState().equals(State.INITIAL)) {
+ initialize();
+ }
+ LOGGER.debug("Starting configuration {}", this);
+ this.setStarting();
final Set<LoggerConfig> alreadyStarted = new HashSet<>();
for (final LoggerConfig logger : loggers.values()) {
logger.start();
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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 7ff8a2b..f0d85b8 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.ConfigurationAssemblerFactory;
+import org.apache.logging.log4j.core.config.assembler.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;
@@ -71,7 +71,7 @@ import org.apache.logging.log4j.util.Strings;
* be called in their respective order. DefaultConfiguration is always called
* last if no configuration has been returned.
*/
-public abstract class ConfigurationFactory extends ConfigurationAssemblerFactory {
+public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
/**
* Allow the ConfigurationFactory class to be specified as a system property.
*/
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderAssembler.java
deleted file mode 100644
index 95d343a..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderAssembler.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 AppenderAssembler extends ComponentAssembler<AppenderAssembler> {
-
- /**
- * Add a Layout to the Appender component.
- * @param assembler The LayoutAssembler with all of its attributes set.
- * @return this Assembler.
- */
- AppenderAssembler add(LayoutAssembler assembler);
-
- /**
- * Add a Filter to the Appender component.
- * @param assembler The FilterAssembler with all of its attributes and sub components set.
- * @return this Assembler.
- */
- AppenderAssembler add(FilterAssembler 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/20fd2273/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
new file mode 100644
index 0000000..3bed6b2
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefAssembler.java
deleted file mode 100644
index c055faa..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/AppenderRefAssembler.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 AppenderRefAssembler extends ComponentAssembler<AppenderRefAssembler> {
-
- /**
- * Add a Filter to the Appender component.
- * @param assembler The FilterAssembler with all of its attributes and sub components set.
- * @return this Assembler.
- */
- AppenderRefAssembler add(FilterAssembler assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..c492fe3
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentAssembler.java
deleted file mode 100644
index 3c21e5a..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ComponentAssembler.java
+++ /dev/null
@@ -1,94 +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;
-
-/**
- * Assembler for arbitrary components and the base class for the provided components.
- */
-@SuppressWarnings("rawtypes")
-public interface ComponentAssembler<T extends ComponentAssembler> extends Assembler<Component> {
-
- /**
- * Add an attribute to the component.
- * @param key The attribute key.
- * @param value The value of the attribute.
- * @return The ComponentAssembler.
- */
- 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 ComponentAssembler.
- */
- T addAttribute(String key, Level level);
-
- /**
- * Add an enumeration.
- * @param key The attribute key.
- * @param value The enumeration.
- * @return The ComponentAssembler.
- */
- T addAttribute(String key, Enum<?> value);
-
- /**
- * Add an integer attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentAssembler.
- */
- T addAttribute(String key, int value);
-
- /**
- * Add a boolean attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentAssembler.
- */
- T addAttribute(String key, boolean value);
-
- /**
- * Add an Object attribute.
- * @param key The attribute key.
- * @param value The integer value.
- * @return The ComponentAssembler.
- */
- 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 ComponentAssembler.
- */
- T addComponent(ComponentAssembler<?> 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 ConfigurationAssembler.
- * @return The ConfiguratonAssembler.
- */
- ConfigurationAssembler<? extends Configuration> getAssembler();
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..12aea81
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterAssembler.java
deleted file mode 100644
index 4ab8f7e..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CompositeFilterAssembler.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 CompositeFilterAssembler extends ComponentAssembler<CompositeFilterAssembler> {
-
- /**
- * Add a FilterComponent.
- * @param assembler The FilterAssembler with all of its attributes and sub-components set.
- * @return The CompositeFilterAssembler.
- */
- CompositeFilterAssembler add(FilterAssembler assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..1b6d795
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssembler.java
deleted file mode 100644
index 600515b..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssembler.java
+++ /dev/null
@@ -1,252 +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;
-
-/**
- * Interface for assembling logging configurations.
- */
-public interface ConfigurationAssembler<T extends Configuration> extends Assembler<T> {
-
- /**
- * Set the name of the configuration.
- *
- * @param name the name of the {@link Configuration}. By default is {@code "Constructed"}.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> setConfigurationName(String name);
-
- /**
- * Set the configuration source, if one exists.
- * @param configurationSource the ConfigurationSource.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> setConfigurationSource(ConfigurationSource configurationSource);
-
- /**
- * Set the level of the StatusLogger.
- * @param level The logging level.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<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.
- */
- ConfigurationAssembler<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.
- */
- ConfigurationAssembler<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.
- */
- ConfigurationAssembler<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.
- */
- ConfigurationAssembler<T> setMonitorInterval(String intervalSeconds);
-
- /**
- * Adds an AppenderComponent.
- * @param assembler The AppenderAssembler with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> add(AppenderAssembler assembler);
-
- /**
- * Adds a CustomLevel component.
- * @param assembler The CustomLevelAssembler with all of its attributes set.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> add(CustomLevelAssembler assembler);
-
- /**
- * Add a Logger component.
- * @param assembler The LoggerAssembler with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> add(LoggerAssembler assembler);
-
- /**
- * Add the root Logger component.
- * @param assembler The RootLoggerAssembler with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> add(RootLoggerAssembler assembler);
-
- /**
- * Add a Filter component.
- * @param assembler the FilterAssembler with all of its attributes and sub components set.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<T> add(FilterAssembler assembler);
-
- /**
- * Add a Property key and value.
- * @param key The property key.
- * @param value The property value.
- * @return this Assembler instance.
- */
- ConfigurationAssembler<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 AppenderAssembler.
- */
- AppenderAssembler newAppender(String name, String pluginName);
-
-
- /**
- * Returns an Assembler for creating AppenderRefs.
- * @param ref The name of the Appender being referenced.
- * @return the AppenderRefAssembler.
- */
- AppenderRefAssembler 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 ComponentAssembler.
- */
- @SuppressWarnings("rawtypes")
- ComponentAssembler 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 ComponentAssembler.
- */
- @SuppressWarnings("rawtypes")
- ComponentAssembler<ComponentAssembler> 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 CustomLevelAssembler.
- */
- CustomLevelAssembler 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 FilterAssembler.
- */
- FilterAssembler 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 FilterAssembler.
- */
- FilterAssembler newFilter(String pluginName, String onMatch, String onMisMatch);
-
- /**
- * Returns an Assembler for creating Layouts.
- * @param type The Plugin type of the Layout.
- * @return The LayoutAssembler.
- */
- LayoutAssembler 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 LoggerAssembler.
- */
- LoggerAssembler 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 LoggerAssembler.
- */
- LoggerAssembler 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 LoggerAssembler.
- */
- LoggerAssembler 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 LoggerAssembler.
- */
- LoggerAssembler 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 RootLoggerAssembler.
- */
- RootLoggerAssembler 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 RootLoggerAssembler.
- */
- RootLoggerAssembler 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 RootLoggerAssembler.
- */
- RootLoggerAssembler 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 RootLoggerAssembler.
- */
- RootLoggerAssembler newAsyncRootLogger(String level);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssemblerFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssemblerFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssemblerFactory.java
deleted file mode 100644
index 85e1c89..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/ConfigurationAssemblerFactory.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.DefaultConfigurationAssembler;
-
-/**
- *
- */
-public class ConfigurationAssemblerFactory {
-
- /**
- * Returns the default ConfigurationAssembler to construct Log4j configurations.
- * @return The ConfigurationAssembler.
- */
- public static ConfigurationAssembler<AssembledConfiguration> newConfiguration() {
- return new DefaultConfigurationAssembler<>();
- }
-
- public static <T extends AssembledConfiguration> ConfigurationAssembler<T> newConfiguration(Class<T> clazz) {
- return new DefaultConfigurationAssembler<>(clazz);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..72f5ec9
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/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
new file mode 100644
index 0000000..13fa3b5
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelAssembler.java
deleted file mode 100644
index c37ab9e..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/CustomLevelAssembler.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 CustomLevelAssembler extends ComponentAssembler<CustomLevelAssembler> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..120e026
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.assembler.api;
+
+/**
+ * Assembler for constructing Filters
+ */
+public interface CustomLevelComponentBuilder extends ComponentBuilder<CustomLevelComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterAssembler.java
deleted file mode 100644
index cf95228..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/FilterAssembler.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 FilterAssembler extends ComponentAssembler<FilterAssembler> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..2526963
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.assembler.api;
+
+/**
+ * Assembler for constructing Filters
+ */
+public interface FilterComponentBuilder extends ComponentBuilder<FilterComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutAssembler.java
deleted file mode 100644
index 954ea51..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LayoutAssembler.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 LayoutAssembler extends ComponentAssembler<LayoutAssembler> {
-
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..b04f9c3
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.assembler.api;
+
+/**
+ * Assembler for constructing Layouts
+ */
+public interface LayoutComponentBuilder extends ComponentBuilder<LayoutComponentBuilder> {
+
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerAssembler.java
deleted file mode 100644
index fd6b673..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/LoggerAssembler.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 LoggerAssembler extends ComponentAssembler<LoggerAssembler> {
-
- /**
- * Add an Appender reference to the Logger component.
- * @param assembler The AppenderRefAssembler with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- LoggerAssembler add(AppenderRefAssembler assembler);
-
- /**
- * Add a Filter to the Logger component.
- * @param assembler The FilterAssembler with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- LoggerAssembler add(FilterAssembler assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..628636c
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerAssembler.java
deleted file mode 100644
index dfd01ba..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/api/RootLoggerAssembler.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 RootLoggerAssembler extends ComponentAssembler<RootLoggerAssembler> {
-
- /**
- * Add an Appender reference to the Logger component.
- * @param assembler The AppenderRefAssembler with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- RootLoggerAssembler add(AppenderRefAssembler assembler);
-
- /**
- * Add a Filter to the Logger component.
- * @param assembler The FilterAssembler with all of its attributes and sub-components set.
- * @return this Assembler.
- */
- RootLoggerAssembler add(FilterAssembler assembler);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..edf12b4
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderAssembler.java
deleted file mode 100644
index be94a88..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderAssembler.java
+++ /dev/null
@@ -1,44 +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.AppenderAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.LayoutAssembler;
-
-/**
- * Holds the Appender Component attributes and subcomponents.
- */
-public class DefaultAppenderAssembler extends DefaultComponentAssembler<AppenderAssembler> implements AppenderAssembler {
-
- public DefaultAppenderAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String name, String type) {
- super(assembler, name, type);
- }
-
- @Override
- public AppenderAssembler add(LayoutAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-
- @Override
- public AppenderAssembler add(FilterAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..683cab5
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefAssembler.java
deleted file mode 100644
index b91aa82..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultAppenderRefAssembler.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.impl;
-
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.assembler.api.AppenderRefAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.FilterAssembler;
-
-/**
- * Holds the Appender Component attributes and subcomponents.
- */
-public class DefaultAppenderRefAssembler extends DefaultComponentAssembler<AppenderRefAssembler> implements AppenderRefAssembler {
-
- public DefaultAppenderRefAssembler(DefaultConfigurationAssembler<? extends Configuration> assembler, String ref) {
- super(assembler, "AppenderRef");
- addAttribute("ref", ref);
- }
-
-
- @Override
- public AppenderRefAssembler add(FilterAssembler assembler) {
- addComponent(assembler);
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/20fd2273/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
new file mode 100644
index 0000000..609a434
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/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.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/20fd2273/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentAssembler.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentAssembler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentAssembler.java
deleted file mode 100644
index a8851bd..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/assembler/impl/DefaultComponentAssembler.java
+++ /dev/null
@@ -1,127 +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.ComponentAssembler;
-import org.apache.logging.log4j.core.config.assembler.api.ConfigurationAssembler;
-
-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 DefaultComponentAssembler<T extends ComponentAssembler> implements ComponentAssembler<T> {
-
- private ConfigurationAssembler<? 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 DefaultComponentAssembler(ConfigurationAssembler<? extends Configuration> assembler, String type) {
- this(assembler, null, type, null);
- }
-
- public DefaultComponentAssembler(ConfigurationAssembler<? extends Configuration> assembler, String name, String type) {
- this(assembler, name, type, null);
- }
-
- public DefaultComponentAssembler(ConfigurationAssembler<? 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(ComponentAssembler<?> assembler) {
- components.add(assembler.assemble());
- return (T) this;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public ConfigurationAssembler<? extends Configuration> getAssembler() {
- return assembler;
- }
-
- @Override
- public Component assemble() {
- Component component = new Component(type, name, value);
- component.getAttributes().putAll(attributes);
- component.getComponents().addAll(components);
- return component;
- }
-}