com.ibm.websphere.command
Interface CacheableCommand

All Superinterfaces:
com.ibm.websphere.command.Command, CommandCaller, java.io.Serializable, com.ibm.websphere.command.TargetableCommand
All Known Implementing Classes:
CacheableCommandImpl

public interface CacheableCommand
extends com.ibm.websphere.command.TargetableCommand, CommandCaller

The CacheableCommand interface provides the contract between the client and the command implementation for those commands that participate in the command caching framework. It allows caching metadata to be supplied.


Field Summary
 
Fields inherited from interface com.ibm.websphere.command.Command
serialVersionUID
 
Method Summary
 boolean executeFromCache()
          executeFromCache This method will check the cache to see if the given command is present.
 CommandCaller getCaller()
          Returns the object that called this command instance.
 EntryInfo getEntryInfo()
          This gets the EntryInfo object for this command, which holds caching metadata.
 java.lang.String getId()
          This gets the cache id for the command.
 int getSharingPolicy()
          This gets the sharing policy that dictates how distributed caching is managed.
 void postExecute()
          Allows the command writer to perform actions on the cache after the execution, and potential caching, of the command.
 boolean preExecute()
          Allows the command writer to perform actions on the cache prior to the execution, and potential caching, of the command.
 void setCaller(CommandCaller caller)
          This sets the caller object for a caller who is cached.
 void updateCache()
          This method will cause the current command to be placed into the cache.
 
Methods inherited from interface com.ibm.websphere.command.TargetableCommand
getCommandTarget, getCommandTargetName, hasOutputProperties, performExecute, setCommandTarget, setCommandTargetName, setOutputProperties
 
Methods inherited from interface com.ibm.websphere.command.Command
execute, isReadyToCallExecute, reset
 
Methods inherited from interface com.ibm.websphere.command.CommandCaller
unionDependencies
 

Method Detail

getId

public java.lang.String getId()
This gets the cache id for the command. It typically has a simple relationship to the command class and input properties. However, it can involve any logic that can be invoked in the command client's JVM.

Returns:
The cache id.

getSharingPolicy

public int getSharingPolicy()
This gets the sharing policy that dictates how distributed caching is managed.

Returns:
Either EntryInfo.NOT_SHARED, EntryInfo.SHARED_PULL or EntryInfo.SHARED_PUSH.

getEntryInfo

public EntryInfo getEntryInfo()
This gets the EntryInfo object for this command, which holds caching metadata.

Returns:
The EntryInfo object.

preExecute

public boolean preExecute()
Allows the command writer to perform actions on the cache prior to the execution, and potential caching, of the command.

Returns:
True implies that the command's execution should be terminated, so the performExecute, postExecute and setCommand will not happen.

postExecute

public void postExecute()
Allows the command writer to perform actions on the cache after the execution, and potential caching, of the command. Such actions might include invalidation of commands made invalid by execution of this command.


setCaller

public void setCaller(CommandCaller caller)
This sets the caller object for a caller who is cached. The caller can be another command or a JSP. The caller must support the CommandCaller interface. It allows invalidation dependencies to be added to the caller.

The caller of a command must call this method on the command some time after creating the new command instance, but before calling the execute() method.

Parameters:
caller - The command that called this command.

getCaller

public CommandCaller getCaller()
Returns the object that called this command instance. The caller can be another command or a JSP. The caller must support the CommandCaller interface. It is used by this command to add invalidation dependencies to the caller. The caller must be explicitly set using the setCaller method.

Returns:
The caller of the command.

executeFromCache

public boolean executeFromCache()
                         throws com.ibm.websphere.command.CommandException
executeFromCache This method will check the cache to see if the given command is present. If so then the command is populated with the cached results and true is returned. If the command is not cached, then false is returned and no change is made to the state of the command.

Returns:
true if the command was retrieved from cache
com.ibm.websphere.command.CommandException

updateCache

public void updateCache()
This method will cause the current command to be placed into the cache. Any existing entry with the same cache id will be replaced.



 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.