You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/08/04 13:32:57 UTC
[22/28] incubator-ignite git commit: IGNITE-1185 Locate configuration
in class path.
IGNITE-1185 Locate configuration in class path.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/518b6239
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/518b6239
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/518b6239
Branch: refs/heads/ignite-1189
Commit: 518b62393fe8d68949c8e615ceda9f6b1ea6abc7
Parents: 93b2057
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Aug 3 12:48:35 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Aug 3 12:48:35 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgnitionEx.java | 17 +----------------
.../apache/ignite/internal/util/IgniteUtils.java | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/518b6239/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 73de99a..3790703 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -583,22 +583,7 @@ public class IgnitionEx {
public static IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext>
loadConfigurations(String springCfgPath) throws IgniteCheckedException {
A.notNull(springCfgPath, "springCfgPath");
-
- URL url;
-
- try {
- url = new URL(springCfgPath);
- }
- catch (MalformedURLException e) {
- url = U.resolveIgniteUrl(springCfgPath);
-
- if (url == null)
- throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath +
- ". Note that this path should be either absolute or a relative local file system path, " +
- "relative to META-INF in classpath or valid URL to IGNITE_HOME.", e);
- }
-
- return loadConfigurations(url);
+ return loadConfigurations(IgniteUtils.resolveSpringUrl(springCfgPath));
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/518b6239/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index ec72a4b..68433cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -3345,6 +3345,9 @@ public abstract class IgniteUtils {
url = U.resolveIgniteUrl(springCfgPath);
if (url == null)
+ url = resolveInClasspath(springCfgPath);
+
+ if (url == null)
throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath +
". Note that this path should be either absolute or a relative local file system path, " +
"relative to META-INF in classpath or valid URL to IGNITE_HOME.", e);
@@ -3354,6 +3357,19 @@ public abstract class IgniteUtils {
}
/**
+ * @param path Resource path.
+ * @return Resource URL inside jar. Or {@code null}.
+ */
+ @Nullable private static URL resolveInClasspath(String path) {
+ ClassLoader clsLdr = Thread.currentThread().getContextClassLoader();
+
+ if (clsLdr == null)
+ return null;
+
+ return clsLdr.getResource(path.replaceAll("\\\\", "/"));
+ }
+
+ /**
* Gets URL representing the path passed in. First the check is made if path is absolute.
* If not, then the check is made if path is relative to {@code META-INF} folder in classpath.
* If not, then the check is made if path is relative to ${IGNITE_HOME}.