This commit is contained in:
Costin Leau
2011-07-13 13:05:28 +03:00
parent 9d1d15e5b6
commit 84e19d24bb

View File

@@ -20,6 +20,8 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -91,6 +93,52 @@ public class GemfireTemplate extends GemfireAccessor {
return this.exposeNativeRegion;
}
public boolean containsKey(final Object key) {
return execute(new GemfireCallback<Boolean>() {
@SuppressWarnings("unchecked")
public Boolean doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return region.containsKey(key);
}
});
}
public boolean containsKeyOnServer(final Object key) {
return execute(new GemfireCallback<Boolean>() {
@SuppressWarnings("unchecked")
public Boolean doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return region.containsKeyOnServer(key);
}
});
}
public boolean containsValue(final Object value) {
return execute(new GemfireCallback<Boolean>() {
@SuppressWarnings("unchecked")
public Boolean doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return region.containsValue(value);
}
});
}
public boolean containsValueForKey(final Object key) {
return execute(new GemfireCallback<Boolean>() {
@SuppressWarnings("unchecked")
public Boolean doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return region.containsValueForKey(key);
}
});
}
public <K, V> void create(final K key, final V value) {
execute(new GemfireCallback<Object>() {
@SuppressWarnings("unchecked")
public Object doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
region.create(key, value);
return null;
}
});
}
public <K, V> V get(final K key) {
return execute(new GemfireCallback<V>() {
@SuppressWarnings("unchecked")
@@ -109,6 +157,15 @@ public class GemfireTemplate extends GemfireAccessor {
});
}
public <K, V> V putIfAbsent(final K key, final V value) {
return execute(new GemfireCallback<V>() {
@SuppressWarnings("unchecked")
public V doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return (V) region.putIfAbsent(key, value);
}
});
}
public <K, V> V remove(final K key) {
return execute(new GemfireCallback<V>() {
@SuppressWarnings("unchecked")
@@ -118,6 +175,43 @@ public class GemfireTemplate extends GemfireAccessor {
});
}
public <K, V> V replace(final K key, final V value) {
return execute(new GemfireCallback<V>() {
@SuppressWarnings("unchecked")
public V doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return (V) region.replace(key, value);
}
});
}
public <K, V> boolean replace(final K key, final V oldValue, final V newValue) {
return execute(new GemfireCallback<Boolean>() {
@SuppressWarnings("unchecked")
public Boolean doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return region.replace(key, oldValue, newValue);
}
});
}
public <K, V> Map<K, V> getAll(final Collection<?> keys) {
return execute(new GemfireCallback<Map<K, V>>() {
@SuppressWarnings("unchecked")
public Map<K, V> doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
return (Map<K, V>) region.getAll(keys);
}
});
}
public <K, V> void putAll(final Map<? extends K, ? extends V> map) {
execute(new GemfireCallback<Object>() {
@SuppressWarnings("unchecked")
public Object doInGemfire(Region region) throws GemFireCheckedException, GemFireException {
region.putAll(map);
return null;
}
});
}
/**
* Shortcut for {@link Region#query(String)} method. Filters the values of this region using the predicate given as a string with the syntax of the WHERE clause of the query language.
* The predefined variable this may be used inside the predicate to denote the current element being filtered.