Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1 [created] f0773f5dc


# ignite-1


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

Branch: refs/heads/ignite-1
Commit: f0773f5dc9d163921d9ce1f55378e202974b6f53
Parents: a4f69c4
Author: sboikov <sboi...@gridgain.com>
Authored: Wed Dec 10 15:23:53 2014 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Wed Dec 10 16:45:34 2014 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/ignite/Ignite.java |   2 +-
 .../java/org/apache/ignite/IgniteCache.java     |   4 +-
 .../processors/cache/IgniteCacheProxy.java      | 589 +++++++++++++++++++
 .../org/gridgain/grid/kernal/GridKernal.java    |  17 +-
 .../processors/cache/GridCacheProcessor.java    |  23 +
 .../processors/cache/IgniteCacheTest.java       | 115 ++++
 .../bamboo/GridDataGridTestSuite.java           |   3 +
 .../java/org/gridgain/grid/GridSpringBean.java  |   6 +-
 8 files changed, 752 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/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 94fcce8..d53e8a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -230,7 +230,7 @@ public interface Ignite extends AutoCloseable {
      * @param name Cache name.
      * @return Instance of the cache for the specified name.
      */
-    public <K, V> GridCache<K, V> jcache(@Nullable String name);
+    public <K, V> IgniteCache<K, V> jcache(@Nullable String name);
 
     /**
      * Gets grid transactions facade.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java 
b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 6a05ce5..0b513ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -170,7 +170,7 @@ public interface IgniteCache<K, V> extends 
javax.cache.Cache<K, V>, IgniteAsyncS
 
     public Lock lock(K key) throws CacheException;
 
-    public Lock lockAll(Set<K> keys) throws CacheException;
+    public Lock lockAll(Set<? extends K> keys) throws CacheException;
 
     /**
      * Checks if any node owns a lock for this key.
@@ -241,7 +241,7 @@ public interface IgniteCache<K, V> extends 
javax.cache.Cache<K, V>, IgniteAsyncS
      * @return Peeked value.
      * @throws NullPointerException If key is {@code null}.
      */
-    @Nullable public V localPeek(K key, GridCachePeekMode... peekModes);
+    @Nullable public V localPeek(K key, CachePeekMode... peekModes);
 
     /**
      * This method unswaps cache entries by given keys, if any, from swap 
storage

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
new file mode 100644
index 0000000..044f433
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -0,0 +1,589 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.lang.*;
+import org.gridgain.grid.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.kernal.processors.cache.*;
+import org.gridgain.grid.util.tostring.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.expiry.*;
+import javax.cache.integration.*;
+import javax.cache.processor.*;
+import java.io.*;
+import java.util.*;
+import java.util.concurrent.locks.*;
+
+/**
+ * Cache proxy.
+ */
+public class IgniteCacheProxy<K, V> implements IgniteCache<K, V>, 
Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Context. */
+    private GridCacheContext<K, V> ctx;
+
+    /** Gateway. */
+    private GridCacheGateway<K, V> gate;
+
+    /** Cache. */
+    @GridToStringInclude
+    private GridCacheAdapter<K, V> delegate;
+
+    /**
+     * @param delegate Delegate.
+     */
+    public IgniteCacheProxy(GridCacheAdapter<K, V> delegate) {
+        assert delegate != null;
+
+        this.delegate = delegate;
+
+        ctx = delegate.context();
+
+        gate = ctx.gate();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheConfiguration<K, V> getConfiguration() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Entry<K, V> randomEntry() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> withExpiryPolicy(ExpiryPolicy plc) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadCache(@Nullable IgniteBiPredicate p, @Nullable 
Object... args) throws CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localLoadCache(@Nullable IgniteBiPredicate p, 
@Nullable Object... args) throws CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V getAndPutIfAbsent(K key, V val) throws 
CacheException {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.putIfAbsent(key, val);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll(IgnitePredicate filter) throws 
CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lock(K key) throws CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Lock lockAll(Set<? extends K> keys) throws CacheException 
{
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLocked(Object key) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLockedByThread(Object key) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterable<Entry<K, V>> localEntries(GridCachePeekMode... 
peekModes) throws CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> localPartition(int part) throws CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localEvict(Collection<? extends K> keys) {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+        try {
+            delegate.evictAll(keys);
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public V localPeek(K key, CachePeekMode... peekModes) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localPromote(Set<? extends K> keys) throws 
CacheException {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                delegate.promoteAll(keys);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean clear(Collection<? extends K> keys) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int size(CachePeekMode... peekModes) throws 
CacheException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public int localSize(CachePeekMode... peekModes) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public V get(K key) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.get(key);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public Map<K, V> getAll(Set<? extends K> keys) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.getAll(keys);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean containsKey(K key) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void loadAll(Set<? extends K> keys,
+        boolean replaceExistingValues,
+        CompletionListener completionLsnr) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void put(K key, V val) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                delegate.putx(key, val, null);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndPut(K key, V val) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.put(key, val);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void putAll(Map<? extends K, ? extends V> map) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                delegate.putAll(map, null);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean putIfAbsent(K key, V val) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.putxIfAbsent(key, val);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.removex(key);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean remove(K key, V oldVal) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.remove(key, oldVal);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndRemove(K key) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.remove(key, (GridCacheEntryEx<K, V>)null);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V oldVal, V newVal) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.replace(key, oldVal, newVal);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean replace(K key, V val) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.replacex(key, val);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public V getAndReplace(K key, V val) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                return delegate.replace(key, val);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll(Set<? extends K> keys) {
+        try {
+            GridCacheProjectionImpl<K, V> prev = gate.enter(null);
+
+            try {
+                delegate.removeAll(keys);
+            }
+            finally {
+                gate.leave(prev);
+            }
+        }
+        catch (GridException e) {
+            throw new CacheException(e);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void removeAll() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void clear() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T invoke(K key, EntryProcessor<K, V, T> 
entryProcessor, Object... args)
+        throws EntryProcessorException {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> Map<K, T> invokeAll(Set<? extends K> keys,
+        EntryProcessor<K, V, T> entryProcessor,
+        Object... args) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getName() {
+        return delegate.name();
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheManager getCacheManager() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void close() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isClosed() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> clazz) {
+        if (clazz.equals(IgniteCache.class))
+            return (T)this;
+
+        throw new IllegalArgumentException("Unsupported class: " + clazz);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void 
registerCacheEntryListener(CacheEntryListenerConfiguration 
cacheEntryLsnrConfiguration) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void 
deregisterCacheEntryListener(CacheEntryListenerConfiguration 
cacheEntryLsnrConfiguration) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Iterator<Cache.Entry<K, V>> iterator() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<Entry<K, V>> query(QueryPredicate<K, V> 
filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> QueryCursor<R> query(QueryReducer<Entry<K, V>, R> 
rmtRdc, QueryPredicate<K, V> filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<List<?>> queryFields(QuerySqlPredicate<K, V> 
filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> QueryCursor<R> queryFields(QueryReducer<List<?>, R> 
rmtRdc, QuerySqlPredicate<K, V> filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<Entry<K, V>> localQuery(QueryPredicate<K, V> 
filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public QueryCursor<List<?>> 
localQueryFields(QuerySqlPredicate<K, V> filter) {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteCache<K, V> enableAsync() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isAsync() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> IgniteFuture<R> future() {
+        // TODO IGNITE-1.
+        throw new UnsupportedOperationException();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(delegate);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked"})
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        delegate = (GridCacheAdapter<K, V>)in.readObject();
+
+        ctx = delegate.context();
+
+        gate = ctx.gate();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(IgniteCacheProxy.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java 
b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
index bdc80b9..f61c020 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridKernal.java
@@ -2926,8 +2926,21 @@ public class GridKernal extends ClusterGroupAdapter 
implements GridEx, IgniteMBe
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> GridCache<K, V> jcache(@Nullable String name) {
-        throw new UnsupportedOperationException();
+    @Override public <K, V> IgniteCache<K, V> jcache(@Nullable String name) {
+        guard();
+
+        try {
+            if (!dbUsageRegistered) {
+                GridLicenseUseRegistry.onUsage(DATA_GRID, getClass());
+
+                dbUsageRegistered = true;
+            }
+
+            return ctx.cache().publicJCache(name);
+        }
+        finally {
+            unguard();
+        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
index 8f63358..505c4f1 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
@@ -13,6 +13,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.fs.*;
+import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.*;
 import org.gridgain.grid.*;
@@ -1576,6 +1577,28 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * @param name Cache name.
+     * @param <K> type of keys.
+     * @param <V> type of values.
+     * @return Cache instance for given name.
+     */
+    @SuppressWarnings("unchecked")
+    public <K, V> IgniteCache<K, V> publicJCache(@Nullable String name) {
+        if (log.isDebugEnabled())
+            log.debug("Getting public cache for name: " + name);
+
+        if (sysCaches.contains(name))
+            throw new IllegalStateException("Failed to get cache because it is 
system cache: " + name);
+
+        GridCacheAdapter<K, V> cache = (GridCacheAdapter<K, 
V>)caches.get(name);
+
+        if (cache == null)
+            throw new IllegalArgumentException("Cache is not configured: " + 
name);
+
+        return new IgniteCacheProxy<>(cache);
+    }
+
+    /**
      * @return All configured public cache instances.
      */
     public Collection<GridCache<?, ?>> publicCaches() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
new file mode 100644
index 0000000..a390fad
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTest.java
@@ -0,0 +1,115 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.marshaller.optimized.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.testframework.junits.common.*;
+
+/**
+ *
+ */
+public class IgniteCacheTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new 
TcpDiscoveryVmIpFinder(true);
+
+    /**
+     * @return Grids count to start.
+     */
+    protected int gridCount() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        int cnt = gridCount();
+
+        assert cnt >= 1 : "At least one grid must be started";
+
+        startGridsMultiThreaded(cnt);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+
+        disco.setIpFinder(ipFinder);
+
+        if (isDebug())
+            disco.setAckTimeout(Integer.MAX_VALUE);
+
+        cfg.setDiscoverySpi(disco);
+
+        cfg.setCacheConfiguration(cacheConfiguration(gridName));
+
+        cfg.setMarshaller(new IgniteOptimizedMarshaller(false));
+
+        return cfg;
+    }
+
+    /**
+     * @param gridName Grid name.
+     * @return Cache configuration.
+     * @throws Exception In case of error.
+     */
+    protected GridCacheConfiguration cacheConfiguration(String gridName) 
throws Exception {
+        GridCacheConfiguration cfg = defaultCacheConfiguration();
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPutGetRemove() throws Exception {
+        IgniteCache<Integer, String> cache = jcache();
+
+        for (int i = 0; i < 10; i++)
+            cache.put(i, String.valueOf(i));
+
+        for (int i = 0; i < 10; i++)
+            assertEquals(String.valueOf(i), cache.get(i));
+
+        for (int i = 0; i < 10; i++)
+            cache.remove(i);
+
+        for (int i = 0; i < 10; i++)
+            assertNull(cache.get(i));
+    }
+
+    /**
+     * @return Cache.
+     */
+    protected <K, V> IgniteCache<K, V> jcache() {
+        return jcache(0);
+    }
+
+    /**
+     * @param idx Grid index.
+     * @return Cache.
+     */
+    protected <K, V> IgniteCache<K, V> jcache(int idx) {
+        return grid(idx).jcache(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
index 3f53e58..3bed59a 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
@@ -10,6 +10,7 @@
 package org.gridgain.testsuites.bamboo;
 
 import junit.framework.*;
+import org.apache.ignite.internal.processors.cache.*;
 import org.gridgain.grid.*;
 import org.gridgain.grid.cache.affinity.fair.*;
 import org.gridgain.grid.cache.store.*;
@@ -36,6 +37,8 @@ public class GridDataGridTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Gridgain In-Memory Data Grid Test 
Suite");
 
+        suite.addTestSuite(IgniteCacheTest.class);
+
         // Affinity tests.
         suite.addTestSuite(GridCachePartitionFairAffinityNodesSelfTest.class);
         suite.addTestSuite(GridCacheAffinityBackupsSelfTest.class);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0773f5d/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java 
b/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
index 370f542..d8c2734 100644
--- a/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
+++ b/modules/spring/src/main/java/org/gridgain/grid/GridSpringBean.java
@@ -257,8 +257,10 @@ public class GridSpringBean extends 
GridMetadataAwareAdapter implements Ignite,
     }
 
     /** {@inheritDoc} */
-    @Override public <K, V> GridCache<K, V> jcache(@Nullable String name) {
-        throw new UnsupportedOperationException();
+    @Override public <K, V> IgniteCache<K, V> jcache(@Nullable String name) {
+        assert g != null;
+
+        return g.jcache(name);
     }
 
     /** {@inheritDoc} */

Reply via email to