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/15 07:48:33 UTC
svn commit: r1587429 - in
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config:
json/JSONConfigurationFactory.java yaml/YAMLConfigurationFactory.java
Author: mattsicker
Date: Tue Apr 15 05:48:33 2014
New Revision: 1587429
URL: http://svn.apache.org/r1587429
Log:
Use Loader.isClassAvailable.
- Make things final.
- Reduce access to public array (!)
- Remove unused field.
Modified:
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JSONConfigurationFactory.java
logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YAMLConfigurationFactory.java
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JSONConfigurationFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JSONConfigurationFactory.java?rev=1587429&r1=1587428&r2=1587429&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JSONConfigurationFactory.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/json/JSONConfigurationFactory.java Tue Apr 15 05:48:33 2014
@@ -20,6 +20,7 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.Order;
import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.helpers.Loader;
/**
*
@@ -31,25 +32,23 @@ public class JSONConfigurationFactory ex
/**
* The file extensions supported by this factory.
*/
- public static final String[] SUFFIXES = new String[] {".json", ".jsn"};
+ private static final String[] SUFFIXES = new String[] {".json", ".jsn"};
- private static String[] dependencies = new String[] {
+ private static final String[] dependencies = new String[] {
"com.fasterxml.jackson.databind.ObjectMapper",
"com.fasterxml.jackson.databind.JsonNode",
"com.fasterxml.jackson.core.JsonParser"
};
- private boolean isActive;
+ private final boolean isActive;
public JSONConfigurationFactory() {
- try {
- for (final String item : dependencies) {
- Class.forName(item);
+ for (final String dependency : dependencies) {
+ if (!Loader.isClassAvailable(dependency)) {
+ LOGGER.debug("Missing dependencies for Json support");
+ isActive = false;
+ return;
}
- } catch (final ClassNotFoundException ex) {
- LOGGER.debug("Missing dependencies for Json support");
- isActive = false;
- return;
}
isActive = true;
}
Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YAMLConfigurationFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YAMLConfigurationFactory.java?rev=1587429&r1=1587428&r2=1587429&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YAMLConfigurationFactory.java (original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/config/yaml/YAMLConfigurationFactory.java Tue Apr 15 05:48:33 2014
@@ -22,6 +22,7 @@ import org.apache.logging.log4j.core.con
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.Order;
import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.helpers.Loader;
@Plugin(name = "YAMLConfigurationFactory", category = "ConfigurationFactory")
@Order(7)
@@ -30,28 +31,24 @@ public class YAMLConfigurationFactory ex
/**
* The file extensions supported by this factory.
*/
- public static final String[] SUFFIXES = new String[] {".yml", ".yaml"};
+ private static final String[] SUFFIXES = new String[] {".yml", ".yaml"};
- private static String[] dependencies = new String[] {
+ private static final String[] dependencies = new String[] {
"com.fasterxml.jackson.databind.ObjectMapper",
"com.fasterxml.jackson.databind.JsonNode",
"com.fasterxml.jackson.core.JsonParser",
"com.fasterxml.jackson.dataformat.yaml.YAMLFactory"
};
- private final File configFile = null;
-
- private boolean isActive;
+ private final boolean isActive;
public YAMLConfigurationFactory() {
- try {
- for (final String item : dependencies) {
- Class.forName(item);
+ for (final String dependency : dependencies) {
+ if (!Loader.isClassAvailable(dependency)) {
+ LOGGER.debug("Missing dependencies for Yaml support");
+ isActive = false;
+ return;
}
- } catch (final ClassNotFoundException ex) {
- LOGGER.debug("Missing dependencies for Yaml support");
- isActive = false;
- return;
}
isActive = true;
}