logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1617171 - in /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config: json/JsonConfiguration.java plugins/util/PluginManager.java xml/XmlConfiguration.java
Date Sun, 10 Aug 2014 22:08:29 GMT
Author: mattsicker
Date: Sun Aug 10 22:08:29 2014
New Revision: 1617171

URL: http://svn.apache.org/r1617171
Log:
Add and use method to add multiple packages to PluginManager.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java?rev=1617171&r1=1617170&r2=1617171&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JsonConfiguration.java
Sun Aug 10 22:08:29 2014
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -74,6 +75,7 @@ public class JsonConfiguration extends A
             for (final Map.Entry<String, String> entry : rootNode.getAttributes().entrySet())
{
                 final String key = entry.getKey();
                 final String value = getStrSubstitutor().replace(entry.getValue());
+                // TODO: this duplicates a lot of the XmlConfiguration constructor
                 if ("status".equalsIgnoreCase(key)) {
                     statusConfig.withStatus(value);
                 } else if ("dest".equalsIgnoreCase(key)) {
@@ -83,10 +85,7 @@ public class JsonConfiguration extends A
                 } else if ("verbose".equalsIgnoreCase(entry.getKey())) {
                     statusConfig.withVerbosity(value);
                 } else if ("packages".equalsIgnoreCase(key)) {
-                    final String[] packages = value.split(Patterns.COMMA_SEPARATOR);
-                    for (final String p : packages) {
-                        PluginManager.addPackage(p);
-                    }
+                    PluginManager.addPackages(Arrays.asList(value.split(Patterns.COMMA_SEPARATOR)));
                 } else if ("name".equalsIgnoreCase(key)) {
                     setName(value);
                 } else if ("monitorInterval".equalsIgnoreCase(key)) {

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java?rev=1617171&r1=1617170&r2=1617171&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginManager.java
Sun Aug 10 22:08:29 2014
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
 import java.text.DecimalFormat;
+import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
@@ -96,6 +97,18 @@ public class PluginManager {
     }
 
     /**
+     * Adds a list of package names to be scanned for plugins. Convenience method for {@link
#addPackage(String)}.
+     *
+     * @param packages collection of package names to add. Ignored if {@code null} or empty.
+     */
+    public static void addPackages(final Collection<String> packages) {
+        if (packages == null || packages.isEmpty()) {
+            return;
+        }
+        PACKAGES.addAllAbsent(packages);
+    }
+
+    /**
      * Returns the type of a specified plugin.
      * 
      * @param name The name of the plugin.

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java?rev=1617171&r1=1617170&r2=1617171&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java
Sun Aug 10 22:08:29 2014
@@ -21,6 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -149,10 +150,7 @@ public class XmlConfiguration extends Ab
                 } else if ("verbose".equalsIgnoreCase(key)) {
                     statusConfig.withVerbosity(value);
                 } else if ("packages".equalsIgnoreCase(key)) {
-                    final String[] packages = value.split(Patterns.COMMA_SEPARATOR);
-                    for (final String p : packages) {
-                        PluginManager.addPackage(p);
-                    }
+                    PluginManager.addPackages(Arrays.asList(value.split(Patterns.COMMA_SEPARATOR)));
                 } else if ("name".equalsIgnoreCase(key)) {
                     setName(value);
                 } else if ("strict".equalsIgnoreCase(key)) {



Mime
View raw message