ehcache

net.sf.ehcache.transaction.xa
Class VersionAwareWrapper

java.lang.Object
  extended by net.sf.ehcache.transaction.xa.VersionAwareWrapper
All Implemented Interfaces:
Command, VersionAwareCommand

public class VersionAwareWrapper
extends java.lang.Object
implements Command, VersionAwareCommand

Wraps a Command, that will first be checked against the optimistic locking strategy before being executed against the Store.

Author:
Nabib El-Rahman

Field Summary
 
Fields inherited from interface net.sf.ehcache.transaction.Command
EXPIRE_ALL_ELEMENTS, NULL, PUT, PUT_WITH_WRITER, REMOVE, REMOVE_ALL, REMOVE_WITH_WRITER
 
Constructor Summary
VersionAwareWrapper(Command command)
          Constructor
VersionAwareWrapper(Command command, long version, java.lang.Object key)
          Constructor
 
Method Summary
 boolean execute(CacheWriterManager cacheWriterManager)
          Executes the command on some cacheWriterManager
 boolean execute(Store store)
          Executes the command on some store
 java.lang.String getCommandName()
          
 java.lang.Object getKey()
          Getter to the key of the Element this command affects
 long getVersion()
          getter to the version of the Element this affects
 boolean isPut(java.lang.Object key)
          Is this command represents adding a key to the store
 boolean isRemove(java.lang.Object key)
          Is this command represents removing a key to the store
 boolean isVersionAware()
          Checks whether this command aware of any version scheme of the Element if affects
 boolean isWriteCommand()
          Checks whether this command is a write command to the underlying store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionAwareWrapper

public VersionAwareWrapper(Command command)
Constructor

Parameters:
command - the underlying command

VersionAwareWrapper

public VersionAwareWrapper(Command command,
                           long version,
                           java.lang.Object key)
Constructor

Parameters:
command - the underlying command
version - the version
key - the key
Method Detail

isWriteCommand

public boolean isWriteCommand()
Checks whether this command is a write command to the underlying store

Specified by:
isWriteCommand in interface VersionAwareCommand
Returns:
true if the command would mutate the store on Command.execute(net.sf.ehcache.store.Store)

execute

public boolean execute(Store store)
Executes the command on some store

Specified by:
execute in interface Command
Parameters:
store - the Store on which to execute the command
Returns:
true if the store was mutated, false otherwise

execute

public boolean execute(CacheWriterManager cacheWriterManager)
Executes the command on some cacheWriterManager

Specified by:
execute in interface Command
Parameters:
cacheWriterManager - the CacheWriterManager on which to execute the command
Returns:
true if the CacheWriterManager was called

isPut

public boolean isPut(java.lang.Object key)
Is this command represents adding a key to the store

Specified by:
isPut in interface Command
Parameters:
key - the key
Returns:
true, if this command would try to add an Element for key, otherwise false

isRemove

public boolean isRemove(java.lang.Object key)
Is this command represents removing a key to the store

Specified by:
isRemove in interface Command
Parameters:
key - the key
Returns:
true, if this command would try to remove an Element for key, otherwise false

isVersionAware

public boolean isVersionAware()
Checks whether this command aware of any version scheme of the Element if affects

Specified by:
isVersionAware in interface VersionAwareCommand
Returns:
true if so

getVersion

public long getVersion()
getter to the version of the Element this affects

Specified by:
getVersion in interface VersionAwareCommand
Returns:
version number

getKey

public java.lang.Object getKey()
Getter to the key of the Element this command affects

Specified by:
getKey in interface VersionAwareCommand
Returns:
key

getCommandName

public java.lang.String getCommandName()

Specified by:
getCommandName in interface Command
Returns:
the command name

ehcache

true