You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/04/27 03:26:52 UTC
svn commit: r1590335 - in
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util:
PluginManager.java PluginRegistry.java
Author: mattsicker
Date: Sun Apr 27 01:26:52 2014
New Revision: 1590335
URL: http://svn.apache.org/r1590335
Log:
Update documentation.
- Make the hasCategory method make more sense as well.
- Added warning message to PluginManager.main.
Modified:
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/plugins/util/PluginRegistry.java
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=1590335&r1=1590334&r2=1590335&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 Apr 27 01:26:52 2014
@@ -87,6 +87,7 @@ public class PluginManager {
@Deprecated // use PluginProcessor instead
public static void main(final String[] args) throws Exception {
+ System.err.println("WARNING: this tool is superseded by the annotation processor included in log4j-core.");
if (args == null || args.length < 1) {
System.err.println("A target directory must be specified");
System.exit(-1);
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java?rev=1590335&r1=1590334&r2=1590335&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.java Sun Apr 27 01:26:52 2014
@@ -32,6 +32,15 @@ public class PluginRegistry<T extends Se
private final ConcurrentMap<String, ConcurrentMap<String, T>> categories =
new ConcurrentHashMap<String, ConcurrentMap<String, T>>();
+ /**
+ * Gets or creates a plugin category if not already available. Category names are case-insensitive. The
+ * ConcurrentMap that is returned should also be treated as a case-insensitive plugin map where names should be
+ * converted to lowercase before retrieval or storage.
+ *
+ * @param category the plugin category to look up or create.
+ * @return the plugin map for the given category name.
+ * @throws IllegalArgumentException if the argument is {@code null}
+ */
public ConcurrentMap<String, T> getCategory(final String category) {
if (category == null) {
throw new IllegalArgumentException("Category name cannot be null.");
@@ -41,22 +50,52 @@ public class PluginRegistry<T extends Se
return categories.get(key);
}
+ /**
+ * Returns the number of plugin categories currently available. This is primarily useful for serialization.
+ *
+ * @return the number of plugin categories.
+ */
public int getCategoryCount() {
return categories.size();
}
+ /**
+ * Indicates whether or not any plugin categories have been registered. Note that this does not necessarily
+ * indicate if any plugins are registered as categories may be empty.
+ *
+ * @return {@code true} if there any categories registered.
+ */
public boolean isEmpty() {
return categories.isEmpty();
}
+ /**
+ * Resets the registry to an empty state.
+ */
public void clear() {
categories.clear();
}
- public boolean hasCategory(final String key) {
- return categories.containsKey(key);
+ /**
+ * Indicates whether or not the given category name is registered and has plugins in that category.
+ *
+ * @param category the plugin category name to check.
+ * @return {@code true} if the category exists and has plugins registered.
+ * @throws IllegalArgumentException if the argument is {@code null}
+ */
+ public boolean hasCategory(final String category) {
+ if (category == null) {
+ throw new IllegalArgumentException("Category name cannot be null.");
+ }
+ final String key = category.toLowerCase();
+ return categories.containsKey(key) && !categories.get(key).isEmpty();
}
+ /**
+ * Gets an entry set for iterating over the registered plugin categories.
+ *
+ * @return an entry set of the registered plugin categories.
+ */
public Set<Map.Entry<String, ConcurrentMap<String, T>>> getCategories() {
return categories.entrySet();
}