com.ibm.websphere.command

Class CacheableCommandImpl

  • All Implemented Interfaces:
    Sizeable, CacheableCommand, Command, CommandCaller, TargetableCommand, java.io.Serializable


    public abstract class CacheableCommandImpl
    extends TargetableCommandImpl
    implements CacheableCommand, Sizeable
    This CacheableCommandImpl abstract class provides an implementation for all CacheableCommand interface methods except those that the command writer must write. This class provides a runtime for command execution that interacts with the CommandCache. It also provides the contract between this command runtime and the command writer.

    CacheableCommandImpl is a super class of all CacheableCommands.

    See Also:
    Serialized Form
    • Constructor Detail

      • CacheableCommandImpl

        public CacheableCommandImpl()
    • Method Detail

      • getId

        public final java.lang.String getId()
        This is the method in the CacheableCommand interface. This must be implemented by the command writer.
        Specified by:
        getId in interface CacheableCommand
        Returns:
        The cache id.
      • getSharingPolicy

        public final int getSharingPolicy()
        This is the method in the CacheableCommand interface. This should be implemented by the command writer only if the default of EntryInfo.SHARED_PULL is not desired.
        Specified by:
        getSharingPolicy in interface CacheableCommand
        Returns:
        The sharing policy id.
      • preExecute

        public boolean preExecute()
        This implements the CacheableCommand interface. This should be implemented by the command writer only if there is something that needs to be done prior to executing the command on the server.
        Specified by:
        preExecute in interface CacheableCommand
        Returns:
        True implies that the command's execution should be terminated, so the performExecute, postExecute and setCommand will not happen.
      • postExecute

        public void postExecute()
        Implements the CacheableCommand interface. This should be implemented by the command writer only if there is something that needs to be done after executing the command on the server.
        Specified by:
        postExecute in interface CacheableCommand
      • execute

        public void execute()
                     throws CommandException
        This implements the method in the Command interface, overriding the implementation in TargetableCommandImpl.

        It does the following:

        • Throws an UnsetInputPropertiesException if this command's isReadyToCallExecute method returns false.
        • Get the CommandTarget for this command from the targetPolicy.
        • If it is cached, return the cached command. The command may be cached locally or in the coordinator for the command.
        • If it is not cached, call the CommandTargetProxy.executeCommand method to execute the command, which calls the TargetableCommand.performExecute method, and cache it. The command may be run locally or in the coordinator for the command. The command may be cached after execution, depending on the sharing policy.
        • If the hasOutputProperties method returns true and the returned command is not the same instance as this command, it calls the setOutputProperties method so that the results will be copied into this command.
        • Set the time of execution of the command.
        Specified by:
        execute in interface Command
        Overrides:
        execute in class TargetableCommandImpl
        Throws:
        CommandException - The superclass for all command exceptions.
      • setCaller

        public void setCaller(CommandCaller caller)
        Implements the CacheableCommand interface method.
        Specified by:
        setCaller in interface CacheableCommand
        Parameters:
        caller - The command that called this command.
      • unionDependencies

        public void unionDependencies(EntryInfo entryInfo)
        This is called by the CommandCache to add dependencies to this command.
        Specified by:
        unionDependencies in interface CommandCaller
        Parameters:
        entryInfo - This command's entryInfo.
      • getEntryInfo

        public EntryInfo getEntryInfo()
        The gets this command's EntryInfo object, which holds its caching metadata.
        Specified by:
        getEntryInfo in interface CacheableCommand
        Returns:
        The EntryInfo object.
      • executeFromCache

        public 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.
        Specified by:
        executeFromCache in interface CacheableCommand
        Returns:
        true if the command was retrieved from cache
        Throws:
        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.
        Specified by:
        updateCache in interface CacheableCommand
      • prepareMetadata

        protected void prepareMetadata()
        This method implements the default command cache policy
      • invalidateEntries

        protected void invalidateEntries()
      • getObjectSize

        public long getObjectSize()
        Description copied from interface: Sizeable
        Returns an implementation-specific size of the object.
        Specified by:
        getObjectSize in interface Sizeable
        Returns:
        estimated size of object
      • setObjectSize

        public void setObjectSize(long objectSize)
IBM WebSphere Application ServerTM
Release 8.5