[jbosscache-commits] JBoss Cache SVN: r7257 - in core/trunk/src/main/java/org/jboss/cache: invocation and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri Dec 5 19:30:40 EST 2008
Author: genman
Date: 2008-12-05 19:30:40 -0500 (Fri, 05 Dec 2008)
New Revision: 7257
Modified:
core/trunk/src/main/java/org/jboss/cache/Cache.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
Log:
JBCACHE-1442 - Add "setData()" call
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-12-06 00:27:51 UTC (rev 7256)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-12-06 00:30:40 UTC (rev 7257)
@@ -575,4 +575,30 @@
* @since 3.0
*/
void removeInterceptor(Class<? extends CommandInterceptor> interceptorType);
+
+ /**
+ * Sets all of the mappings from the specified map in a {@link Node}, replacing the
+ * existing data of that node, or creates a new node with the data.
+ * The operation is essentially the inverse of {@link #getData(Fqn)}.
+ * <p/>
+ * For caches that write to a cache loader, this operation is the most efficient,
+ * as the existing data need not be loaded to be merged.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to set the data for
+ * @param data mappings to copy
+ * @throws IllegalStateException if the cache is not in a started state
+ * @since 3.1
+ */
+ void setData(Fqn fqn, Map<? extends K, ? extends V> data);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #replace(Fqn, java.util.Map)}
+ *
+ * @param fqn String representation of the Fqn
+ * @param data data map to insert
+ * @throws IllegalStateException if the cache is not in a started state
+ * @since 3.1
+ */
+ void setData(String fqn, Map<? extends K, ? extends V> data);
+
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-12-06 00:27:51 UTC (rev 7256)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-12-06 00:30:40 UTC (rev 7257)
@@ -520,10 +520,7 @@
public void put(Fqn fqn, Map<? extends K, ? extends V> data)
{
- InvocationContext ctx = invocationContextContainer.get();
- cacheStatusCheck(ctx);
- PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data);
- invoker.invoke(ctx, command);
+ invokePut(fqn, data, true);
}
public void put(String fqn, Map<? extends K, ? extends V> data)
@@ -660,4 +657,22 @@
throw new IllegalStateException("Cache not in STARTED state!");
}
}
+
+ private void invokePut(Fqn fqn, Map<? extends K, ? extends V> data, boolean erase) {
+ InvocationContext ctx = invocationContextContainer.get();
+ cacheStatusCheck(ctx);
+ PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data);
+ command.setErase(erase);
+ invoker.invoke(ctx, command);
+ }
+
+ public void setData(Fqn fqn, Map<? extends K, ? extends V> data)
+ {
+ invokePut(fqn, data, true);
+ }
+
+ public void setData(String fqn, Map<? extends K, ? extends V> data)
+ {
+ setData(Fqn.fromString(fqn), data);
+ }
}
More information about the jbosscache-commits
mailing list