[jbosscache-commits] JBoss Cache SVN: r5585 - core/trunk/src/main/java/org/jboss/cache/invocation.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Fri Apr 18 05:32:50 EDT 2008
Author: mircea.markus
Date: 2008-04-18 05:32:50 -0400 (Fri, 18 Apr 2008)
New Revision: 5585
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
Log:
JBCACHE-1222 - bug fixing - check state before executing commands
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-17 18:07:17 UTC (rev 5584)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-18 09:32:50 UTC (rev 5585)
@@ -333,6 +333,7 @@
public void move(Fqn<?> nodeToMove, Fqn<?> newParent) throws NodeNotExistsException
{
+ checkState();
MoveCommand command = commandsFactory.buildMoveCommand(nodeToMove, newParent);
invoke(command);
}
@@ -354,6 +355,7 @@
public void evict(Fqn<?> fqn, boolean recursive)
{
+ checkState();
List<Fqn> nodesToEvict = cacheData.getNodesForEviction(fqn, recursive);
for (Fqn aFqn : nodesToEvict)
{
@@ -368,6 +370,7 @@
public V get(Fqn<?> fqn, K key)
{
+ checkState();
GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, true);
return (V) invoke(command);
}
@@ -379,6 +382,7 @@
public boolean removeNode(Fqn<?> fqn)
{
+ checkState();
// special case if we are removing the root. Remove all children instead.
if (fqn.isRoot())
{
@@ -406,6 +410,11 @@
}
}
+ private void checkState()
+ {
+ if (!getCacheStatus().allowInvocations()) throw new IllegalStateException("Cache is not in STARTED state");
+ }
+
public boolean removeNode(String fqn)
{
return removeNode(Fqn.fromString(fqn));
@@ -413,6 +422,7 @@
public NodeSPI<K, V> getNode(Fqn<?> fqn)
{
+ checkState();
GetNodeCommand command = commandsFactory.buildGetNodeCommand(fqn);
return (NodeSPI) invoke(command);
}
@@ -424,6 +434,7 @@
public V remove(Fqn<?> fqn, K key) throws CacheException
{
+ checkState();
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
RemoveKeyCommand command = commandsFactory.buildRemoveKeyCommand(tx, fqn, key, true);
return (V) invoke(command);
@@ -436,6 +447,7 @@
public void put(Fqn<?> fqn, Map<K, V> data)
{
+ checkState();
PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data, true, false);
invoke(command);
}
@@ -447,6 +459,7 @@
public void putForExternalRead(Fqn<?> fqn, K key, V value)
{
+ checkState();
// if the node exists then this should be a no-op.
if (peek(fqn, false, false) == null)
{
@@ -464,6 +477,7 @@
public V put(Fqn<?> fqn, K key, V value)
{
+ checkState();
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false, false);
return (V) invoke(command);
@@ -498,6 +512,7 @@
*/
public Map<K, V> getData(Fqn<?> fqn)
{
+ checkState();
GetDataMapCommand command = commandsFactory.buildGetDataMapCommand(fqn);
return (Map<K, V>) invoke(command);
}
@@ -523,6 +538,7 @@
*/
public Set<K> getKeys(Fqn<?> fqn)
{
+ checkState();
GetKeysCommand command = commandsFactory.buildGetKeysCommand(fqn);
return (Set<K>) invoke(command);
}
@@ -540,6 +556,7 @@
*/
public void clearData(Fqn fqn)
{
+ checkState();
GlobalTransaction tx = getCurrentTransaction();
invoke(commandsFactory.buildRemoveDataCommand(tx, fqn, true, false, false));
}
More information about the jbosscache-commits
mailing list