ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/21] incubator-ignite git commit: #ignite-556: Add other create from xml methods to Ignite.
Date Mon, 23 Mar 2015 15:06:49 GMT
#ignite-556: Add other create from xml methods to Ignite.


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

Branch: refs/heads/ignite-45
Commit: 33e911c7c9d7088064fc716fb51a7189a68f49c8
Parents: 8a22c32
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Mar 23 14:23:54 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Mar 23 14:23:54 2015 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/Ignite.java |  56 +++++++++-
 .../apache/ignite/internal/IgniteKernal.java    | 101 ++++++++++++++-----
 .../spring/IgniteSpringProcessor.java           |   7 +-
 ...CacheJdbcBlobStoreMultithreadedSelfTest.java |   2 +-
 .../GridProjectionForCachesSelfTest.java        |   2 +-
 .../discovery/GridDiscoveryManagerSelfTest.java |   4 +-
 .../cache/GridCacheClearLocallySelfTest.java    |   2 +-
 .../cache/IgniteDynamicCacheStartSelfTest.java  |   6 +-
 .../GridCacheClientModesAbstractSelfTest.java   |   2 +-
 ...idCacheNearOnlyMultiNodeFullApiSelfTest.java |   2 +-
 .../near/GridCacheNearOnlyTopologySelfTest.java |   8 +-
 ...heNearOnlyLruNearEvictionPolicySelfTest.java |   2 +-
 .../ignite/testframework/junits/IgniteMock.java |  31 +++++-
 .../igfs/IgfsNearOnlyMultiNodeSelfTest.java     |   4 +-
 .../org/apache/ignite/IgniteSpringBean.java     |  45 ++++++++-
 .../spring/IgniteSpringProcessorImpl.java       |  27 ++---
 16 files changed, 225 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index ff4eea6..84ae15f 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -205,7 +205,7 @@ public interface Ignite extends AutoCloseable {
      * @param springCfgPath Spring XML configuration file path or URL.
      * @return Instance of started cache.
      */
-    public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
throws IgniteCheckedException;
+    public <K, V> IgniteCache<K, V> createCache(String springCfgPath);
 
     /**
      * Gets existing cache with the given name or creates new one with the given configuration.
@@ -216,6 +216,14 @@ public interface Ignite extends AutoCloseable {
     public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K,
V> cacheCfg);
 
     /**
+     * Gets existing cache with the given name or creates new one with the given configuration.
+     *
+     * @param springCfgPath Spring XML configuration file path or URL.
+     * @return Existing or newly created cache.
+     */
+    public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath);
+
+    /**
      * Dynamically starts new cache with the given cache configuration.
      * <p>
      * If local node is an affinity node, this method will return the instance of started
cache.
@@ -230,6 +238,18 @@ public interface Ignite extends AutoCloseable {
         NearCacheConfiguration<K, V> nearCfg);
 
     /**
+     * Dynamically starts new cache with the given cache configuration.
+     * <p>
+     * If local node is an affinity node, this method will return the instance of started
cache.
+     * Otherwise, it will create a near cache with the given configuration on local node.
+     *
+     * @param springCfgPath Spring XML configuration file for cache path or URL.
+     * @param nearSpringCfgPath Spring XML configuration file for near cache path or URL.
+     * @return Instance of started cache.
+     */
+    public <K, V> IgniteCache<K, V> createCache(String springCfgPath, String
nearSpringCfgPath);
+
+    /**
      * Gets existing cache with the given cache configuration or creates one if it does not
exist.
      *
      * @param cacheCfg Cache configuration.
@@ -239,14 +259,35 @@ public interface Ignite extends AutoCloseable {
     public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K,
V> cacheCfg, NearCacheConfiguration<K, V> nearCfg);
 
     /**
+     * Gets existing cache with the given cache configuration or creates one if it does not
exist.
+     *
+     * @param springCfgPath Spring XML configuration file for cache path or URL.
+     * @param nearSpringCfgPath Spring XML configuration file for near cache path or URL.
+     * @return {@code IgniteCache} instance.
+     */
+    public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath, String
nearSpringCfgPath);
+
+    /**
      * Starts a near cache on local node if cache was previously started with one of the
      * {@link #createCache(CacheConfiguration)} or {@link #createCache(CacheConfiguration,
NearCacheConfiguration)}
      * methods.
      *
+     * @param cacheName Cache name.
      * @param nearCfg Near cache configuration.
      * @return Cache instance.
      */
-    public <K, V> IgniteCache<K, V> createCache(@Nullable String cacheName, NearCacheConfiguration<K,
V> nearCfg);
+    public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName,
NearCacheConfiguration<K, V> nearCfg);
+
+    /**
+     * Starts a near cache on local node if cache was previously started with one of the
+     * {@link #createCache(CacheConfiguration)} or {@link #createCache(CacheConfiguration,
NearCacheConfiguration)}
+     * methods.
+     *
+     * @param cacheName Cache name.
+     * @param nearSpringCfgPath Spring XML configuration file for near cache path or URL.
+     * @return Cache instance.
+     */
+    public <K, V> IgniteCache<K, V> createNearCache(@Nullable String cacheName,
String nearSpringCfgPath);
 
     /**
      * Gets existing near cache with the given name or creates a new one.
@@ -255,7 +296,16 @@ public interface Ignite extends AutoCloseable {
      * @param nearCfg Near configuration.
      * @return {@code IgniteCache} instance.
      */
-    public <K, V> IgniteCache<K, V> getOrCreateCache(@Nullable String cacheName,
NearCacheConfiguration<K, V> nearCfg);
+    public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable String cacheName,
NearCacheConfiguration<K, V> nearCfg);
+
+    /**
+     * Gets existing near cache with the given name or creates a new one.
+     *
+     * @param cacheName Cache name.
+     * @param nearSpringCfgPath Spring XML configuration file for near cache path or URL.
+     * @return {@code IgniteCache} instance.
+     */
+    public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable String cacheName,
String nearSpringCfgPath);
 
     /**
      * Stops dynamically started cache.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index d1f3f99..6a8ae43 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2276,26 +2276,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
-    public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
throws IgniteCheckedException {
-        if (springCfgPath == null) {
-            return createCache((CacheConfiguration) null);
-        }
-        else {
-            URL url = U.resolveSpringUrl(springCfgPath);
-
-            IgniteSpringProcessor spring = SPRING.create(false);
-
-            IgniteBiTuple<Collection<CacheConfiguration>, ? extends GridSpringResourceContext>
cfgMap =
-                spring.loadCacheConfigurations(url);
-
-            if (cfgMap.size() != 1)
-                throw new IgniteCheckedException("File " + url.toString() + " should have
one cache configuration");
-
-            for (CacheConfiguration cfg : cfgMap.get1())
-                return createCache(cfg);
-        }
-
-        return null;
+    @Override public <K, V> IgniteCache<K, V> createCache(String springCfgPath)
{
+        return createCache(getCacheConfiguration(springCfgPath));
     }
 
     /** {@inheritDoc} */
@@ -2318,6 +2300,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath)
{
+        return getOrCreateCache(getCacheConfiguration(springCfgPath));
+    }
+
+    /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> createCache(
         CacheConfiguration<K, V> cacheCfg,
         NearCacheConfiguration<K, V> nearCfg
@@ -2341,7 +2328,13 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K,
V> cacheCfg, NearCacheConfiguration<K, V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> createCache(String springCfgPath,
String nearSpringCfgPath) {
+        return createCache(getCacheConfiguration(springCfgPath), getNearCacheConfiguration(nearSpringCfgPath));
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K,
V> cacheCfg,
+        NearCacheConfiguration<K, V> nearCfg) {
         A.notNull(cacheCfg, "cacheCfg");
         A.notNull(nearCfg, "nearCfg");
 
@@ -2361,7 +2354,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> createCache(String cacheName, NearCacheConfiguration<K,
V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath,
String nearSpringCfgPath) {
+        return getOrCreateCache(getCacheConfiguration(springCfgPath), getNearCacheConfiguration(nearSpringCfgPath));
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(String cacheName,
NearCacheConfiguration<K, V> nearCfg) {
         A.notNull(nearCfg, "nearCfg");
 
         guard();
@@ -2379,8 +2377,14 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
         }
     }
 
-    @Override
-    public <K, V> IgniteCache<K, V> getOrCreateCache(@Nullable String cacheName,
NearCacheConfiguration<K, V> nearCfg) {
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String
cacheName, String nearSpringCfgPath) {
+        return createNearCache(cacheName, getNearCacheConfiguration(nearSpringCfgPath));
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName,
+        NearCacheConfiguration<K, V> nearCfg) {
         A.notNull(nearCfg, "nearCfg");
 
         guard();
@@ -2399,6 +2403,12 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName,
+        String nearSpringCfgPath) {
+        return getOrCreateNearCache(cacheName, getNearCacheConfiguration(nearSpringCfgPath));
+    }
+
+    /** {@inheritDoc} */
     @Override public void destroyCache(String cacheName) {
         guard();
 
@@ -2838,4 +2848,47 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     @Override public String toString() {
         return S.toString(IgniteKernal.class, this);
     }
+
+    /**
+     * @param springCfgPath Spring XML configuration file path or URL.
+     * @return Cache configuration.
+     */
+    private CacheConfiguration getCacheConfiguration(String springCfgPath) {
+        return getConfiguration(springCfgPath, CacheConfiguration.class);
+    }
+
+    /**
+     * @param nearSpringCfgPath Spring XML configuration file path or URL.
+     * @return Cache configuration.
+     */
+    private NearCacheConfiguration getNearCacheConfiguration(String nearSpringCfgPath) {
+        return getConfiguration(nearSpringCfgPath, NearCacheConfiguration.class);
+    }
+
+    /**
+     * @param springCfgPath Spring XML configuration file path or URL.
+     * @param cl Required type of configuration.
+     * @return Cache configuration.
+     */
+    private <T> T getConfiguration(String springCfgPath, Class<T> cl) {
+        try {
+            if (springCfgPath == null)
+                return null;
+
+            URL url = U.resolveSpringUrl(springCfgPath);
+
+            IgniteSpringProcessor spring = SPRING.create(false);
+
+            IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext>
cfgMap =
+                spring.loadConfigurations(url, cl);
+
+            if (cfgMap.size() != 1)
+                throw new IgniteException("File " + url.toString() + " should have one cache
configuration");
+
+            return F.first(cfgMap.get1());
+        }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java
index cd2e3d4..82ec0ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessor.java
@@ -48,19 +48,20 @@ public interface IgniteSpringProcessor {
         URL cfgUrl, String... excludedProps) throws IgniteCheckedException;
 
     /**
-     * Loads all cache configurations specified within given configuration file.
+     * Loads all configurations with given type specified within given configuration file.
      * <p>
      * Usually Spring XML configuration file will contain only one Cache definition. Note
that
      * Cache configuration bean(s) is retrieved form configuration file by type, so the name
of
      * the Cache configuration bean is ignored.
      *
      * @param cfgUrl Configuration file path or URL. This cannot be {@code null}.
+     * @param cl Required type of configuration.
      * @return Tuple containing all loaded configurations and Spring context used to load
them.
      * @throws IgniteCheckedException If configuration could not be
      *      read.
      */
-    public IgniteBiTuple<Collection<CacheConfiguration>, ? extends GridSpringResourceContext>
loadCacheConfigurations(
-        URL cfgUrl) throws IgniteCheckedException;
+    public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext>
loadConfigurations(
+        URL cfgUrl, Class<T> cl) throws IgniteCheckedException;
 
     /**
      * Loads bean instances that match the given types from given configuration file.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
index b656db4..d3bfb8d 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
@@ -64,7 +64,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr
 
         Ignite grid = startGrid(GRID_CNT - 2);
 
-        grid.createCache((String)null, new NearCacheConfiguration());
+        grid.createNearCache((String) null, new NearCacheConfiguration());
 
         grid = startGrid(GRID_CNT - 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
index d0a01ec..af102c6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionForCachesSelfTest.java
@@ -99,7 +99,7 @@ public class GridProjectionForCachesSelfTest extends GridCommonAbstractTest
{
         for (int i = 0; i < 5; i++)
             startGrid(i);
 
-        grid(1).createCache(CACHE_NAME, new NearCacheConfiguration());
+        grid(1).createNearCache(CACHE_NAME, new NearCacheConfiguration());
 
         grid(2).jcache(null);
         grid(3).jcache(null);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
index 7307438..4a6a4eb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerSelfTest.java
@@ -99,9 +99,9 @@ public class GridDiscoveryManagerSelfTest extends GridCommonAbstractTest
{
 
         IgniteKernal g1 = (IgniteKernal)startGrid(1); // NEAR_ONLY cache.
 
-        grid(1).createCache((String)null, new NearCacheConfiguration());
+        grid(1).createNearCache((String) null, new NearCacheConfiguration());
 
-        grid(1).createCache(CACHE_NAME, new NearCacheConfiguration());
+        grid(1).createNearCache(CACHE_NAME, new NearCacheConfiguration());
 
         assertFalse(g0.context().discovery().hasNearCache(CACHE_NAME, one));
         assertTrue(g0.context().discovery().hasNearCache(CACHE_NAME, two));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java
index 11e31e9..1c6c7e9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheClearLocallySelfTest.java
@@ -148,7 +148,7 @@ public class GridCacheClearLocallySelfTest extends GridCommonAbstractTest
{
             if (i == 1) {
                 NearCacheConfiguration nearCfg = new NearCacheConfiguration();
 
-                ignite.createCache(CACHE_PARTITIONED, nearCfg);
+                ignite.createNearCache(CACHE_PARTITIONED, nearCfg);
             }
 
             if (i == 2)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
index d9757ba..716dff4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
@@ -706,7 +706,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest
{
 
             GridTestUtils.assertThrows(log, new Callable<Object>() {
                 @Override public Object call() throws Exception {
-                    return grid(0).getOrCreateCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
+                    return grid(0).getOrCreateNearCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
                 }
             }, CacheException.class, null);
 
@@ -719,7 +719,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest
{
                 IgniteEx nearGrid = grid(nodeCount());
 
                 nearGrid.getOrCreateCache(cfg, new NearCacheConfiguration());
-                nearGrid.getOrCreateCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
+                nearGrid.getOrCreateNearCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration());
 
                 GridCacheContext<Object, Object> nCtx = ((IgniteKernal)nearGrid)
                         .internalCache(DYNAMIC_CACHE_NAME).context();
@@ -833,7 +833,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest
{
 
                         try {
                             if (nearOnly)
-                                ignite(idx).getOrCreateCache(DYNAMIC_CACHE_NAME, new NearCacheConfiguration<>());
+                                ignite(idx).getOrCreateNearCache(DYNAMIC_CACHE_NAME, new
NearCacheConfiguration<>());
                             else
                                 ignite(idx).getOrCreateCache(cacheCfg, new NearCacheConfiguration<>());
                         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
index f82b47c..8e16231 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheClientModesAbstractSelfTest.java
@@ -51,7 +51,7 @@ public abstract class GridCacheClientModesAbstractSelfTest extends GridCacheAbst
         super.beforeTestsStarted();
 
         if (!clientOnly()) {
-            grid(nearOnlyGridName).createCache((String)null, new NearCacheConfiguration());
+            grid(nearOnlyGridName).createNearCache((String) null, new NearCacheConfiguration());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
index b744ed3..c22692f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
@@ -59,7 +59,7 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
         for (int i = 0; i < gridCount(); i++) {
             if (ignite(i).configuration().isClientMode()) {
                 if (clientHasNearCache())
-                    ignite(i).createCache((String)null, new NearCacheConfiguration<>());
+                    ignite(i).createNearCache((String) null, new NearCacheConfiguration<>());
                 else
                     ignite(i).jcache(null);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
index 9c99910..95442f4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
@@ -113,7 +113,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest
{
                 Ignite ignite = startGrid(i);
 
                 if (cilent)
-                    ignite.createCache((String)null, new NearCacheConfiguration());
+                    ignite.createNearCache((String) null, new NearCacheConfiguration());
             }
 
             for (int i = 0; i < 100; i++)
@@ -135,7 +135,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest
{
                 Ignite ignite = startGrid(i);
 
                 if (cilent)
-                    ignite.createCache((String)null, new NearCacheConfiguration());
+                    ignite.createNearCache((String) null, new NearCacheConfiguration());
             }
 
             cache = false;
@@ -166,7 +166,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest
{
                 Ignite ignite = startGrid(i);
 
                 if (cilent)
-                    ignite.createCache((String)null, new NearCacheConfiguration());
+                    ignite.createNearCache((String) null, new NearCacheConfiguration());
             }
 
             for (int i = 0; i < 10; i++)
@@ -239,7 +239,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest
{
                 Ignite ignite = startGrid(i);
 
                 if (cilent)
-                    ignite.createCache((String)null, new NearCacheConfiguration());
+                    ignite.createNearCache((String) null, new NearCacheConfiguration());
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
index 85cd049..b7704f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/lru/GridCacheNearOnlyLruNearEvictionPolicySelfTest.java
@@ -139,7 +139,7 @@ public class GridCacheNearOnlyLruNearEvictionPolicySelfTest extends GridCommonAb
             NearCacheConfiguration nearCfg = new NearCacheConfiguration();
             nearCfg.setNearEvictionPolicy(new CacheLruEvictionPolicy(EVICTION_MAX_SIZE));
 
-            grid(0).createCache((String)null, nearCfg);
+            grid(0).createNearCache((String) null, nearCfg);
 
             int cnt = 1000;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index fa96112..d3405c4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -171,7 +171,7 @@ public class IgniteMock implements Ignite {
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
throws IgniteCheckedException {
+    @Override public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
{
         return null;
     }
 
@@ -181,13 +181,28 @@ public class IgniteMock implements Ignite {
     }
 
     /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath)
{
+        return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K,
V> cacheCfg,
         @Nullable NearCacheConfiguration<K, V> nearCfg) {
         return null;
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> createCache(String cacheName, NearCacheConfiguration<K,
V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> createCache(String springCfgPath,
String nearSpringCfgPath) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(String cacheName,
NearCacheConfiguration<K, V> nearCfg) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String
cacheName, String nearSpringCfgPath) {
         return null;
     }
 
@@ -197,7 +212,17 @@ public class IgniteMock implements Ignite {
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(@Nullable String
cacheName, NearCacheConfiguration<K, V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath,
String nearSpringCfgPath) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName, NearCacheConfiguration<K, V> nearCfg) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName, String nearSpringCfgPath) {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
index 510d3a7..d3440fc 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsNearOnlyMultiNodeSelfTest.java
@@ -59,9 +59,9 @@ public class IgfsNearOnlyMultiNodeSelfTest extends GridCommonAbstractTest
{
     @Override protected void beforeTestsStarted() throws Exception {
         startGrids(nodeCount());
 
-        grid(0).createCache("data", new NearCacheConfiguration());
+        grid(0).createNearCache("data", new NearCacheConfiguration());
 
-        grid(0).createCache("meta", new NearCacheConfiguration());
+        grid(0).createNearCache("meta", new NearCacheConfiguration());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 4c4b194..883387c 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -240,7 +240,7 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
throws IgniteCheckedException {
+    @Override public <K, V> IgniteCache<K, V> createCache(@Nullable String springCfgPath)
{
         assert g != null;
 
         return g.createCache(springCfgPath);
@@ -254,6 +254,13 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath)
{
+        assert g != null;
+
+        return g.getOrCreateCache(springCfgPath);
+    }
+
+    /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K,
V> cacheCfg,
         NearCacheConfiguration<K, V> nearCfg) {
         assert g != null;
@@ -262,6 +269,13 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createCache(String springCfgPath,
String nearSpringCfgPath) {
+        assert g != null;
+
+        return g.createCache(springCfgPath, nearSpringCfgPath);
+    }
+
+    /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K,
V> cacheCfg, NearCacheConfiguration<K, V> nearCfg) {
         assert g != null;
 
@@ -269,17 +283,38 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> createCache(String cacheName, NearCacheConfiguration<K,
V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(String springCfgPath,
String nearSpringCfgPath) {
+        assert g != null;
+
+        return g.getOrCreateCache(springCfgPath, nearSpringCfgPath);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(String cacheName,
NearCacheConfiguration<K, V> nearCfg) {
+        assert g != null;
+
+        return g.createNearCache(cacheName, nearCfg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> createNearCache(@Nullable String
cacheName, String nearSpringCfgPath) {
+        assert g != null;
+
+        return g.createNearCache(cacheName, nearSpringCfgPath);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName, NearCacheConfiguration<K, V> nearCfg) {
         assert g != null;
 
-        return g.createCache(cacheName, nearCfg);
+        return g.getOrCreateNearCache(cacheName, nearCfg);
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> IgniteCache<K, V> getOrCreateCache(@Nullable String
cacheName, NearCacheConfiguration<K, V> nearCfg) {
+    @Override public <K, V> IgniteCache<K, V> getOrCreateNearCache(@Nullable
String cacheName, String nearSpringCfgPath) {
         assert g != null;
 
-        return g.getOrCreateCache(cacheName, nearCfg);
+        return g.getOrCreateNearCache(cacheName, nearSpringCfgPath);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33e911c7/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java
b/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java
index b068851..263ae17 100644
--- a/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java
+++ b/modules/spring/src/main/java/org/apache/ignite/internal/processors/spring/IgniteSpringProcessorImpl.java
@@ -78,35 +78,20 @@ public class IgniteSpringProcessorImpl implements IgniteSpringProcessor
{
     /** {@inheritDoc} */
     @Override public IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext>
loadConfigurations(
         URL cfgUrl, String... excludedProps) throws IgniteCheckedException {
-        ApplicationContext springCtx = applicationContext(cfgUrl, excludedProps);
-
-        Map<String, IgniteConfiguration> cfgMap;
-
-        try {
-            cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
-        }
-        catch (BeansException e) {
-            throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class
+ ", err=" +
-                e.getMessage() + ']', e);
-        }
-
-        if (cfgMap == null || cfgMap.isEmpty())
-            throw new IgniteCheckedException("Failed to find grid configuration in: " + cfgUrl);
-
-        return F.t(cfgMap.values(), new GridSpringResourceContextImpl(springCtx));
+        return loadConfigurations(cfgUrl, IgniteConfiguration.class);
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteBiTuple<Collection<CacheConfiguration>, ? extends GridSpringResourceContext>
loadCacheConfigurations (
-        URL cfgUrl) throws IgniteCheckedException {
+    @Override public <T> IgniteBiTuple<Collection<T>, ? extends GridSpringResourceContext>
loadConfigurations(
+        URL cfgUrl, Class<T> cl) throws IgniteCheckedException {
         ApplicationContext springCtx = applicationContext(cfgUrl);
-        Map<String, CacheConfiguration> cfgMap;
+        Map<String, T> cfgMap;
 
         try {
-            cfgMap = springCtx.getBeansOfType(CacheConfiguration.class);
+            cfgMap = springCtx.getBeansOfType(cl);
         }
         catch (BeansException e) {
-            throw new IgniteCheckedException("Failed to instantiate bean [type=" + CacheConfiguration.class
+
+            throw new IgniteCheckedException("Failed to instantiate bean [type=" + cl +
                 ", err=" + e.getMessage() + ']', e);
         }
 


Mime
View raw message