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/10/02 00:17:59 UTC
[3/7] git commit: Small refactor (extract methods).
Small refactor (extract methods).
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0d836d30
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0d836d30
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0d836d30
Branch: refs/heads/master
Commit: 0d836d30916339c066621daf5a276e3f3536de97
Parents: 2f5c79d
Author: Matt Sicker <ma...@apache.org>
Authored: Wed Oct 1 15:33:32 2014 -0500
Committer: Matt Sicker <ma...@apache.org>
Committed: Wed Oct 1 15:33:32 2014 -0500
----------------------------------------------------------------------
.../log4j/core/config/ConfigurationFactory.java | 21 ++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0d836d30/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 028bf43..ad8b8c6 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
@@ -254,17 +254,9 @@ public abstract class ConfigurationFactory {
LOGGER.error("Cannot locate file {}", configLocation.getPath(), ex);
}
}
- final String scheme = configLocation.getScheme();
- final boolean isClassLoaderScheme = scheme != null && scheme.equals(CLASS_LOADER_SCHEME);
- final boolean isClassPathScheme = scheme != null && !isClassLoaderScheme && scheme.equals(CLASS_PATH_SCHEME);
- if (scheme == null || isClassLoaderScheme || isClassPathScheme) {
+ if (isClassLoaderUri(configLocation)) {
final ClassLoader loader = LoaderUtil.getThreadContextClassLoader();
- String path;
- if (isClassLoaderScheme || isClassPathScheme) {
- path = configLocation.getSchemeSpecificPart();
- } else {
- path = configLocation.getPath();
- }
+ final String path = extractClassLoaderUriPath(configLocation);
final ConfigurationSource source = getInputFromResource(path, loader);
if (source != null) {
return source;
@@ -284,6 +276,15 @@ public abstract class ConfigurationFactory {
return null;
}
+ private static boolean isClassLoaderUri(final URI uri) {
+ final String scheme = uri.getScheme();
+ return scheme == null || scheme.equals(CLASS_LOADER_SCHEME) || scheme.equals(CLASS_PATH_SCHEME);
+ }
+
+ private static String extractClassLoaderUriPath(final URI uri) {
+ return uri.getScheme() == null ? uri.getPath() : uri.getSchemeSpecificPart();
+ }
+
/**
* Load the configuration from the location represented by the String.
* @param config The configuration location.