ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [48/50] incubator-ignite git commit: # Implement Cache.Entry#unwrap() correctly.
Date Wed, 11 Feb 2015 16:12:17 GMT
# Implement Cache.Entry#unwrap() correctly.


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

Branch: refs/heads/ignite-189
Commit: a4f9375f808cab9e3f8f8ea666fe38e5da38d141
Parents: da54496
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Feb 11 18:30:39 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Feb 11 18:30:56 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/cache/CacheEntryEvent.java    | 5 ++++-
 .../ignite/internal/processors/cache/CacheEntryImpl0.java    | 6 +++---
 .../ignite/internal/processors/cache/CacheInvokeEntry.java   | 8 ++++----
 3 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a4f9375f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryEvent.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryEvent.java
index 1ff4be8..ffbc85b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryEvent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryEvent.java
@@ -62,7 +62,10 @@ public class CacheEntryEvent<K, V> extends javax.cache.event.CacheEntryEvent<K,
 
     /** {@inheritDoc} */
     @Override public <T> T unwrap(Class<T> cls) {
-        throw new IllegalArgumentException();
+        if(cls.isAssignableFrom(getClass()))
+            return cls.cast(this);
+
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a4f9375f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
index 05c30c3..d2b1923 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
@@ -47,10 +47,10 @@ public class CacheEntryImpl0<K, V> implements Cache.Entry<K,
V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> cls) {
-        if (!cls.equals(getClass()))
-            throw new IllegalArgumentException("Unwrapping to class is not supported: " +
cls);
+        if(cls.isAssignableFrom(getClass()))
+            return cls.cast(this);
 
-        return (T)this;
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a4f9375f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index f1781bb..829c6a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -89,11 +89,11 @@ public class CacheInvokeEntry<K, V> implements MutableEntry<K,
V> {
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public <T> T unwrap(Class<T> clazz) {
-        if (clazz.equals(Ignite.class))
-            return (T)cctx.kernalContext().grid();
+    @Override public <T> T unwrap(Class<T> cls) {
+        if(cls.isAssignableFrom(getClass()))
+            return cls.cast(this);
 
-        throw new IllegalArgumentException();
+        throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
     }
 
     /**


Mime
View raw message