You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/08/03 13:18:39 UTC

[1/3] incubator-ignite git commit: IGNITE-1185 Locate configuration in class path.

Repository: incubator-ignite
Updated Branches:
  refs/heads/master 93b205758 -> 3c19212a4


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/master
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}.


[3/3] incubator-ignite git commit: IGNITE-1185 Fix javadoc.

Posted by se...@apache.org.
IGNITE-1185 Fix javadoc.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3c19212a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3c19212a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3c19212a

Branch: refs/heads/master
Commit: 3c19212a4094d787631535b0ab06bc7b6765f1a5
Parents: 79f27f4
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Aug 3 14:11:58 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Aug 3 14:11:58 2015 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/internal/util/IgniteUtils.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3c19212a/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 68433cb..f8c4c7e 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
@@ -3358,7 +3358,7 @@ public abstract class IgniteUtils {
 
     /**
      * @param path Resource path.
-     * @return Resource URL inside jar. Or {@code null}.
+     * @return Resource URL inside classpath or {@code null}.
      */
     @Nullable private static URL resolveInClasspath(String path) {
         ClassLoader clsLdr = Thread.currentThread().getContextClassLoader();


[2/3] incubator-ignite git commit: IGNITE-1185 Locate configuration in class path: Add tests.

Posted by se...@apache.org.
IGNITE-1185 Locate configuration in class path: Add tests.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/79f27f4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/79f27f4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/79f27f4a

Branch: refs/heads/master
Commit: 79f27f4a3a2238d8ec196aa92bb35c8d10ce5d36
Parents: 518b623
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Aug 3 13:46:40 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Aug 3 13:46:40 2015 +0300

----------------------------------------------------------------------
 .../src/test/java/config/ignite-test-config.xml | 43 ++++++++++++++++++++
 .../ignite/internal/GridFactorySelfTest.java    |  9 ++++
 2 files changed, 52 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79f27f4a/modules/spring/src/test/java/config/ignite-test-config.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/config/ignite-test-config.xml b/modules/spring/src/test/java/config/ignite-test-config.xml
new file mode 100644
index 0000000..145d124
--- /dev/null
+++ b/modules/spring/src/test/java/config/ignite-test-config.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!--
+    Ignite configuration with all defaults and enabled p2p deployment and enabled events.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+        <property name="localHost" value="127.0.0.1" />
+
+        <property name="gridName" value="config-in-classpath"/>
+
+        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+        <property name="discoverySpi">
+            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+                <property name="ipFinder">
+                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+                        <property name="shared" value="true"/>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/79f27f4a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
index ecc7fb7..fb8cbfe 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
@@ -824,6 +824,15 @@ public class GridFactorySelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testConfigInClassPath() throws Exception {
+        try (Ignite ignite = Ignition.start("config/ignite-test-config.xml")) {
+            assert "config-in-classpath".equals(ignite.name());
+        }
+    }
+
+    /**
      * Test task.
      */
     private static class TestTask extends ComputeTaskSplitAdapter<Void, Void> {