com.ibm.commerce.scheduler.commands

Class AddJobCmdImpl

  • All Implemented Interfaces:
    AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, AddJobCmd, Protectable, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable
    Direct Known Subclasses:
    AddBroadcastJobCmdImpl, ContractDeployCmdImpl, EditJobCmdImpl


    public class AddJobCmdImpl
    extends ControllerCommandImpl
    implements AddJobCmd

    This class adds a job to the WebSphere Commerce Server's scheduler.

    The parameters passed to the command are:

    • pathInfo (required): This is the name of the command that the schedule job should execute.
    • start (required): This indicates when to start executing the job.
    • URL (required): This is the URL to which we should be redirected after the command has finished executing.
    • name (optional): This is the logon id of the job's user identity. The default value is the current user scheduling the job. Valid values include any existing users that have the access control authority to create a scheduled job.
    • queryString (optional): This is an object that represents the parameters specified when executing the job. This will be in the form of a URL query string. A value of n1=v1 indicates that parameter n1 will have a value of v1 when the job is executing. The default value is null which means there will be no parameters specified when the job is executing.
    • host (optional): This is the scheduler instance that should execute the job. Each scheduler instance can have a unique instance name (by default it is the WebSphere Commerce Server's web server host name). A scheduled job can run on a particular scheduler instance if specified. The default value is null which means that the job will run on any scheduler instance.
    • interval (optional): This is the time (in seconds) that indicates how often the job should be re-executed. The default value is 0 which means that the job will only be executed once. The value of the interval must be greater than or equal to 0.
    • attempts (optional): This is the number of attempts required to execute the job successfully. The default value is 0 which means the job will only have one attempt of a successful execution. The value specified must be greater than or equal to 0. If this parameter is specified, then the delay parameter should be specified as well.
    • delay (optional): This is the time (in seconds) that indicates how long to wait before attempting to run the job again. This parameter must have a value greater than or equal to 0 and if this parameter is specified, then the attempts parameter must be specified as well.
    • schedulerPolicy (optional): This is the policy of the job when it fails to be executed. The default value is 0. A value of 0 indicates that the job will not be retried. A value of 1 means the job will be retried.
    • priority (optional): This is the priority of the job. The default value is java.lang.Thread.NORM_PRIORTY. Valid values must be between the range of java.lang.Thread.MIN_PRIORITY and java.lang.Thread.MAX_PRIORITY.
    • applicationType (optional): This is the application type of the job. This is defined in the scheduler instance configuration. The default application types are default, broadcast, auction and inventory but others may be added. The default value is null which represents the default application type. A valid value must be one of the defined application types.
    • storeId (optional): this is the store identity of the job. The default value is the current store in the command context. Valid values include stores for which the current user has access control authority.
    • checkCmdId (optional): This is the task command used to determine whether the job needs to be executed or not. The default value is null which means that the job will always be executed. Valid values include any check command id found in the CHKCMD table.

    This command will verify the value specified for the schedule job. If any value is missing or incorrect, an exception is thrown. If the values are okay, the new schedule job is added by adding a record to the SCHCONFIG and SCHACTIVE tables. The information found in the SCHCONFIG table contains the configuration information for executing the schedule job. The record in the SCHACTIVE record will determine when to execute the job next.

    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AddJobCmdImpl

        public AddJobCmdImpl()
        This is the default constructor for this class. It calls the constructor from the superclass.
    • Method Detail

      • getApplicationType

        public java.lang.String getApplicationType()
        This method gets the application type for the job to be added.
        Returns:
        This method returns the application type of the job.
      • getAttempts

        public java.lang.Integer getAttempts()
        This method gets the number of re-attempts when error occurs.
        Returns:
        This method returns the number of attempts needed to execute the job successfully.
      • getCheckCommandId

        public java.lang.Integer getCheckCommandId()
        This method gets the id of the check command. This is found in the CHKCMD table.
        Returns:
        This method returns the id of the check task command.
      • getDelay

        public java.lang.Integer getDelay()
        This method gets the delay time between re-attempts when an error occurs.
        Returns:
        This method returns the delay time in seconds that indicates when to re-execute the job in the case of a failed run.
      • getHost

        public java.lang.String getHost()
        This method gets the scheduler instance name that uniquely identifies the scheduler for a JVM of the WebSphere Commerce instance.
        Returns:
        This method returns the scheduler instance name.
      • getInterfaceName

        public java.lang.String getInterfaceName()
        This method gets the interface name of the task command which will determine whether the job needs to be executed.
        Returns:
        This method returns the interface name of the task command.
      • getJobId

        public java.lang.Long getJobId()
        This method gets the job's reference number.
        Specified by:
        getJobId in interface AddJobCmd
        Returns:
        This method returns the job reference number.
      • getJobInstanceId

        public java.lang.Long getJobInstanceId()
        This method gets the job's instance number.
        Specified by:
        getJobInstanceId in interface AddJobCmd
        Returns:
        This method returns the job instance number.
      • getResources

        public AccessVector getResources()
                                  throws ECException
        This method gets the resources when creating the schedule job. The two possible resources are the store and the user identity of the job.
        Specified by:
        getResources in interface ECCommand
        Overrides:
        getResources in class AbstractECTargetableCommand
        Returns:
        This method returns the resources of the schedule job that will need some access control verification.
        Throws:
        ECException - This is thrown if there are any problems obtaining the resources.
      • getStoreId

        public java.lang.Integer getStoreId()
        This method gets the store for which this schedule job will run.
        Specified by:
        getStoreId in interface ECCommand
        Overrides:
        getStoreId in class AbstractECTargetableCommand
        Returns:
        This method returns the job's store identity.
      • getUserRefNum

        public java.lang.Long getUserRefNum()
        This method gets the user reference number of the user identity of the scheduler job.
        Returns:
        This method returns the user reference number of the job's user identity.
      • performExecute

        public void performExecute()
                            throws ECException

        This method adds a new schedule job to the Commerce's Scheduler. This is done by adding a record to the SCHCONFIG table and SCHACTIVE table. The entry in the SCHCONFIG table will contain the configuration for executing the job. The record in the SCHACTIVE table will contain the information when to execute the job. After the two records are created, the local Commerce scheduler will be notified that a new job was added. This is done in case it needs to wake up earlier to process the newly added job.

        The response properties will contain the required information to redirect to the specified URL.

        Specified by:
        performExecute in interface ECCommand
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class AbstractECTargetableCommand
        Throws:
        ECException - If there are any problems adding the records to the scheduler tables or notifying the scheduler about the newly added job.
      • setApplicationType

        public void setApplicationType(java.lang.String applicationType)
        This method sets the job's application type.
        Specified by:
        setApplicationType in interface AddJobCmd
        Parameters:
        applicationType - The job's application type.
      • setAttempts

        public void setAttempts(java.lang.Integer attempts)
        This method sets the number of retry attempts.
        Specified by:
        setAttempts in interface AddJobCmd
        Parameters:
        attempts - The number of attempts to successfully execute the job.
      • setCheckCommandId

        public void setCheckCommandId(java.lang.Integer chkCmdId)
        This method sets the id of the check command defined in the CHKCMD table. This is the command that will determine whether the job needs executing or not.
        Parameters:
        chkCmdId - The id of the check command.
      • setDelay

        public void setDelay(java.lang.Integer delay)
        This method sets the delay time between re-attempts.
        Specified by:
        setDelay in interface AddJobCmd
        Parameters:
        delay - The delay in seconds before the job is exectued again because of a fail run.
      • setEndTime

        public void setEndTime(java.sql.Timestamp endTime)
        This method sets the end time of the job.
        Parameters:
        endTime - The job's end time.
      • setErrorUrl

        public void setErrorUrl(java.lang.String url)
        This method sets the URL to be redirected to at the end of the command.
        Parameters:
        url - The URL to redirect to.
      • setHost

        public void setHost(java.lang.String host)
        This method sets the name of the scheduler instance that should run the schedule job.
        Specified by:
        setHost in interface AddJobCmd
        Parameters:
        host - The name of the scheduler instance.
      • setInterfaceName

        public void setInterfaceName(java.lang.String interfaceName)
        This method sets the interface name of the task command which will determine whether the job needs executing or not.
        Parameters:
        interfaceName - The interface name of the check command.
      • setInterval

        public void setInterval(java.lang.Integer interval)
        This method sets the frequency to re-execute the schedule job.
        Specified by:
        setInterval in interface AddJobCmd
        Parameters:
        interval - The interval in seconds to wait before re-executing the job. 0 means the job will only be executed once.
      • setJobId

        public void setJobId(java.lang.Long newJobId)
        This method sets the job id.
        Parameters:
        newJobId - The jobs id.
      • setJobInfo

        public void setJobInfo(TypedProperty property)
                        throws ECException
        This method sets the job information and adds the new schedule job.
        Parameters:
        property - The parameters when calling the AddJob command.
        Throws:
        ECException - if there is a problem with either the parameters passed to create the schedule job or with the actual creation of the schedule job.
      • setName

        public void setName(java.lang.String name)
        This method sets the user identity to run the schedule job.
        Specified by:
        setName in interface AddJobCmd
        Parameters:
        name - The logon id of the job's user identity.
      • setPathInfo

        public void setPathInfo(java.lang.String command)
        This method sets the name of the command to be added to the scheduler.
        Specified by:
        setPathInfo in interface AddJobCmd
        Parameters:
        command - The command to be executed.
      • setPriority

        public void setPriority(java.lang.Integer priority)
        This method sets the priority of the job.
        Parameters:
        priority - The job's priority.
      • setQueryString

        public void setQueryString(java.lang.String parameters)
        This method sets the query string associated with the job. This will be translated into parameters passed to the command when executing. The format is similar to a URL query string which means that n1=v1&n2=v2 means two parameters will be passed to the command, one being n1 with a value of v1 and the other n2 with a value of v2.
        Specified by:
        setQueryString in interface AddJobCmd
        Parameters:
        parameters - The parameters passed to the command when executing.
      • setDescription

        public void setDescription(java.lang.String description)
      • setSequence

        public void setSequence(java.lang.Integer policy)
        This method sets the sequence. The policy for handling missed runs. The default is 0, meaning that missed job will all be skipped except for one.
        Specified by:
        setSequence in interface AddJobCmd
        Parameters:
        policy - The job's sequence. This value should either be 0 or 1.
      • setStartTime

        public void setStartTime(java.sql.Timestamp startTime)
        This method sets the start time to execute the schedule job.
        Specified by:
        setStartTime in interface AddJobCmd
        Parameters:
        startTime - The job's start time.
      • setStoreId

        public void setStoreId(java.lang.Integer storeId)
        This method sets the store id of the schedule job.
        Specified by:
        setStoreId in interface AddJobCmd
        Parameters:
        storeId - The id of the store to whose behalf the job will be executed.
      • setStringEndTime

        public void setStringEndTime(java.lang.String endTime)
        This method sets the job's end time.
        Parameters:
        endTime - The end time of the job.
      • setStringStartTime

        public void setStringStartTime(java.lang.String startTime)
        This method sets the job's start time.
        Parameters:
        startTime - The job's start time.
      • setUrl

        public void setUrl(java.lang.String url)
        This method sets the URL to be redirected to at the end of the command.
        Specified by:
        setUrl in interface AddJobCmd
        Parameters:
        url - The URL to redirect to.
      • setUserRefNum

        public void setUserRefNum(java.lang.Long refnum)
        This method sets the user reference number that represents the job's user identity.
        Specified by:
        setUserRefNum in interface AddJobCmd
        Parameters:
        refnum - The user reference number.