Interface CacheableCommand

All Superinterfaces:
Command, CommandCaller, Serializable, TargetableCommand
All Known Implementing Classes:
CacheableCommandImpl, CacheableCommandImpl

public interface CacheableCommand extends 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.
  • Method Details

    • getId

      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

      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

      com.ibm.websphere.cache.EntryInfo getEntryInfo()
      This gets the EntryInfo object for this command, which holds caching metadata.
      Returns:
      The EntryInfo object.
    • preExecute

      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

      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

      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

      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

      boolean executeFromCache() throws 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
      Throws:
      CommandException
    • updateCache

      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.