org.osesb.scheduledjobs
Class ScheduledJobConfiguration

java.lang.Object
  extended by org.osesb.configuration.XMLConfiguration
      extended by org.osesb.scheduledjobs.ScheduledJobConfiguration

public class ScheduledJobConfiguration
extends XMLConfiguration

Configuration class for ScheduledJob(s) that a scheduled job configuration content model in a XML configuration file and sets configurationProperties.

ScheduledJobConfiguration is used by ScheduledJobManager to start ScheduledJob(s).

A ScheduledJobManager loads and starts ScheduledJobs that are configured by ScheduledJobConfiguration(s). ScheduledJobConfiguration extends XMLConfiguration to include the following properties:

ScheduledJob(s) can be configured as Quartz Jobs or as Runnable(s) For Quartz ScheduledJob(s), scheduledJobConfiguration is set by execute(). For Runnable ScheduledJob(s), scheduledJobConfiguration is set by the constructor that takes a ScheduledJobConfiguration as the parameter.

Generally, ScheduledJob(s) are used by the framework to poll external systems for data and send messages to an osESB transport handler for processing. ScheduledJob(s) are therefore useful in situations where an external system cannot send messages to osESB directly, but instead, generates events for processing by osESB.

Out of the box, there are ScheduledJob classes that poll databases, JMS Destinations, and file systems for changes and send messages to an osESB transport handler for processing. Current ScheduledJob classes include:

ScheduledJobManager(s) do not depend on a J2EE application server and can be deployed anywhere, but are typically deployed on the same platform that hosts the J2EE app server that runs osESB.

ScheduledJob(s) communicate with osESB transport handlers using a org.osesb.msgrouting.configuration.ClientGateway. Typically, the ClientGateway configures a org.osesb.messagepipeline.MessagePipeline with org.osesb.messagepipeline.PipelineStage(s) that:

Since:
Version .9

Field Summary
static java.lang.String JOB_CONFIGURATION_CONTENTMODEL
          The default content model tag name for schedule properties.
protected  XMLConfiguration jobConfiguration
          The <job-configuration> element contains the application-specific properties that are required to execute the job.
static java.lang.String SCHEDULE_CONFIGURATION_CONTENTMODEL
          The default content model tag name for schedule properties.
protected  XMLConfiguration scheduleConfiguration
          The <schedule-configuration> element includes the repeat interval for periodic jobs OR a cron expression for cron jobs.
static java.lang.String SCHEDULEDJOB_CONFIGURATION_CONTENTMODEL
          The default ScheduledJobConfiguration content model tag name.
 
Fields inherited from class org.osesb.configuration.XMLConfiguration
configFilePath, configurationProperties, constructedFromConfigFile, contentModelElement, ftpClientConfiguration, jaxrpcClientConfiguration, jdbcConfiguration, jmsClientConfiguration, log, rootConfigurationAttributes, smtpClientConfiguration, systemProperties, thisClassName
 
Constructor Summary
ScheduledJobConfiguration(org.w3c.dom.Element contentModelElement)
          Creates a new instance of ScheduledJobConfiguration given the content model Element.
ScheduledJobConfiguration(java.lang.String configFile)
          Creates a new instance of ScheduledJobConfiguration given a XML configuration file.
ScheduledJobConfiguration(java.lang.String configFile, java.lang.String xpathExpression)
          Creates a new instance of ScheduledJobConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.
 
Method Summary
 java.lang.String getCronExpression()
          Returns the configured cron expression for the scheduled job.
 boolean getDisplayStartupMessageFlag()
          Returns the displayStartupMessageFlag for the ScheduledJobConfiguration.
 int getHeartbeatIntervalSeconds()
          Returns optional the heartbeatInterval, which defines the number of seconds between "health" messages that a ScheduledJob will write a health message to the info log.
 XMLConfiguration getJobConfiguration()
          Returns the job configuration, which is given by the <job-configuration> element, which contains the application-specific properties that are required to execute the job.
 int getRepeatIntervalAsSeconds()
          Get the configured repeat interval for the ScheduledJob in seconds irrespective of the configuration property was set.
 int getRepeatIntervalHours()
          The scheduled job will fire every repeatIntervalHours hours.
 int getRepeatIntervalMinutes()
          The scheduled job will fire every repeatIntervalMinutes minutes.
 int getRepeatIntervalSeconds()
          The scheduled job will fire every repeatIntervalSeconds seconds.
 XMLConfiguration getScheduleConfiguration()
          Returns the schedule configuration, which is given by the <schedule-configuration> element.
 java.lang.String getScheduledJobName()
          Returns the name of the ScheduledJob, which is given by the name attribute of the root element of the content model.
protected  void loadJobConfiguration()
          Loads the jobConfiguration enclosed within this configuration.
protected  void loadScheduleConfiguration()
          Loads the scheduleConfiguration enclosed within this configuration.
static void main(java.lang.String[] args)
          main() For testing.
 void setConfigFilePath(java.lang.String configFile)
          Set the configuration file name.
 void setDebugFlag(boolean debugFlag)
          Set the debugFlag.
 void setJobConfiguration(XMLConfiguration jobConfiguration)
          Sets the job configuration, which is given by the <job-configuration> element, which contains the application-specific properties that are required to execute the job.
 void setRepeatIntervalHours(int repeatIntervalHours)
          The scheduled job will fire every repeatIntervalHours hours.
 void setRepeatIntervalMinutes(int repeatIntervalMinutes)
          The scheduled job will fire every repeatIntervalMinutes minutes.
 void setRepeatIntervalSeconds(int repeatIntervalSeconds)
          The scheduled job will fire every N seconds.
 void setScheduleConfiguration(XMLConfiguration scheduleConfiguration)
          Sets the schedule configuration, which is given by the <schedule-configuration> element.
 java.lang.String toString()
          Returns the String representation of this ScheduledJobConfiguration.
 
Methods inherited from class org.osesb.configuration.XMLConfiguration
checkXMLConfigurationClass, clear, doEncryptionInstructions, getBooleanConfigurationProperty, getBooleanRootConfigurationAttribute, getConfigFilePath, getConfigurationAttribute, getConfigurationAttributes, getConfigurationElement, getConfigurationElements, getConfigurationProperties, getConfigurationProperty, getConfigurationProperty, getContentModelElement, getDebugFlag, getDocument, getEncryptionInstructions, getFTPClientConfiguration, getIntConfigurationProperty, getIntRootConfigurationAttribute, getJAXRPCClientConfiguration, getJDBCConfiguration, getJMSClientConfiguration, getLongConfigurationProperty, getLongRootConfigurationAttribute, getName, getRootConfigurationAttribute, getRootConfigurationAttributes, getSMTPClientConfiguration, getSystemProperties, getSystemProperty, isConfigurationElementEmpty, loadConfiguration, loadExternalConfiguration, loadFTPClientConfiguration, loadJAXRPCClientConfiguration, loadJDBCConfiguration, loadJMSClientConfiguration, loadPropertiesFromContentModel, loadSMTPClientConfiguration, loadSystemProperties, mergeConfigurationProperties, setConfigurationProperty, setFTPClientConfiguration, setJAXRPCClientConfiguration, setJDBCConfiguration, setJMSClientConfiguration, setName, setRootConfigurationAttribute, setSMTPClientConfiguration, setSystemProperties, setSystemProperty, writeConfigurationFile, writeConfigurationFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCHEDULEDJOB_CONFIGURATION_CONTENTMODEL

public static final java.lang.String SCHEDULEDJOB_CONFIGURATION_CONTENTMODEL
The default ScheduledJobConfiguration content model tag name.

See Also:
Constant Field Values

SCHEDULE_CONFIGURATION_CONTENTMODEL

public static final java.lang.String SCHEDULE_CONFIGURATION_CONTENTMODEL
The default content model tag name for schedule properties.

See Also:
Constant Field Values

JOB_CONFIGURATION_CONTENTMODEL

public static final java.lang.String JOB_CONFIGURATION_CONTENTMODEL
The default content model tag name for schedule properties.

See Also:
Constant Field Values

scheduleConfiguration

protected XMLConfiguration scheduleConfiguration
The <schedule-configuration> element includes the repeat interval for periodic jobs OR a cron expression for cron jobs. Periodic jobs start executing when the first interval after the job start time expires and then repeat indefinitely. Cron jobs are executed according to the configured cron expression.
  • <job-configuration>, which contains the application-specific properties that are required to execute the job.


  • jobConfiguration

    protected XMLConfiguration jobConfiguration
    The <job-configuration> element contains the application-specific properties that are required to execute the job.

    Constructor Detail

    ScheduledJobConfiguration

    public ScheduledJobConfiguration(java.lang.String configFile)
                              throws java.lang.Exception
    Creates a new instance of ScheduledJobConfiguration given a XML configuration file. The root element of the XML configuration file is the starting element for the configuration.

    Parameters:
    configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
    Throws:
    java.lang.Exception - if there is a problem reading or parsing the configuration file.

    ScheduledJobConfiguration

    public ScheduledJobConfiguration(java.lang.String configFile,
                                     java.lang.String xpathExpression)
                              throws java.lang.Exception
    Creates a new instance of ScheduledJobConfiguration given a XML configuration file and a XPath expression that evaluates to the element that marks the beginning of the configuration.

    An empty xpathExpression implies that the root element of the XML configuration file is the starting element for the configuration.

    Parameters:
    configFile - The path to the XML configuration file, which is specified as a resource path or as a file system path that is relative to the path specified by the ConfigurationConstants.CONFIG_PATH_SYSTEMPROPERTY System Property.
    xpathExpression - A XPath expression that evaluates to the element that marks the beginning of the configuration.
    Throws:
    java.lang.Exception - if there is a problem reading or parsing the configuration file.

    ScheduledJobConfiguration

    public ScheduledJobConfiguration(org.w3c.dom.Element contentModelElement)
                              throws java.lang.Exception
    Creates a new instance of ScheduledJobConfiguration given the content model Element.

    Parameters:
    contentModelElement - The top level Element for the for the configuration.
    Throws:
    java.lang.Exception - if there is a fatal error transversing the configuration content model enclosed by contentModelElement.
    Method Detail

    loadScheduleConfiguration

    protected final void loadScheduleConfiguration()
                                            throws java.lang.Exception
    Loads the scheduleConfiguration enclosed within this configuration.

    Throws:
    java.lang.Exception - if there is a fatal error transversing the DOM that contains the configuration content models.

    loadJobConfiguration

    protected final void loadJobConfiguration()
                                       throws java.lang.Exception
    Loads the jobConfiguration enclosed within this configuration.

    Throws:
    java.lang.Exception - if there is a fatal error transversing the DOM that contains the configuration content models.

    getScheduledJobName

    public java.lang.String getScheduledJobName()
    Returns the name of the ScheduledJob, which is given by the name attribute of the root element of the content model.

    Returns:
    the name of the ScheduledJob.

    getDisplayStartupMessageFlag

    public boolean getDisplayStartupMessageFlag()
    Returns the displayStartupMessageFlag for the ScheduledJobConfiguration.

    Returns:
    the ScheduledJobConfiguration displayStartupMessageFlag.

    getHeartbeatIntervalSeconds

    public int getHeartbeatIntervalSeconds()
    Returns optional the heartbeatInterval, which defines the number of seconds between "health" messages that a ScheduledJob will write a health message to the info log.

    Returns:
    the ScheduledJob heartbeatInterval.

    getScheduleConfiguration

    public XMLConfiguration getScheduleConfiguration()
    Returns the schedule configuration, which is given by the <schedule-configuration> element. The schedule configuration includes the repeat interval for periodic jobs OR a cron expression for cron jobs. Periodic jobs start executing when the first interval after the job start time expires and then repeat indefinitely. Cron jobs are executed according to the configured cron expression.

    Returns:
    the scheduleConfiguration as an XMLConfiguration.

    setScheduleConfiguration

    public void setScheduleConfiguration(XMLConfiguration scheduleConfiguration)
    Sets the schedule configuration, which is given by the <schedule-configuration> element. The schedule configuration includes the repeat interval for periodic jobs OR a cron expression for cron jobs. Periodic jobs start executing when the first interval after the job start time expires and then repeat indefinitely. Cron jobs are executed according to the configured cron expression.

    Parameters:
    scheduleConfiguration - as an XMLConfiguration.

    getJobConfiguration

    public XMLConfiguration getJobConfiguration()
    Returns the job configuration, which is given by the <job-configuration> element, which contains the application-specific properties that are required to execute the job.

    Returns:
    the jobConfiguration as an XMLConfiguration.

    setJobConfiguration

    public void setJobConfiguration(XMLConfiguration jobConfiguration)
    Sets the job configuration, which is given by the <job-configuration> element, which contains the application-specific properties that are required to execute the job.

    Parameters:
    jobConfiguration - as an XMLConfiguration.

    getCronExpression

    public java.lang.String getCronExpression()
    Returns the configured cron expression for the scheduled job.

    Returns:
    the configured cron expression for the scheduled job.

    getRepeatIntervalSeconds

    public int getRepeatIntervalSeconds()
    The scheduled job will fire every repeatIntervalSeconds seconds.

    Returns:
    the number of seconds to pause between firing the ScheduledJob.

    setRepeatIntervalSeconds

    public void setRepeatIntervalSeconds(int repeatIntervalSeconds)
    The scheduled job will fire every N seconds.

    Parameters:
    repeatIntervalSeconds - The number of seconds to pause between firing the ScheduledJob.

    getRepeatIntervalMinutes

    public int getRepeatIntervalMinutes()
    The scheduled job will fire every repeatIntervalMinutes minutes.

    Returns:
    the number of minutes to pause between firing the ScheduledJob.

    setRepeatIntervalMinutes

    public void setRepeatIntervalMinutes(int repeatIntervalMinutes)
    The scheduled job will fire every repeatIntervalMinutes minutes.

    Parameters:
    repeatIntervalMinutes - The number of minutes to pause between firing the ScheduledJob.

    getRepeatIntervalHours

    public int getRepeatIntervalHours()
    The scheduled job will fire every repeatIntervalHours hours.

    Returns:
    the number of hours to pause between firing the ScheduledJob.

    getRepeatIntervalAsSeconds

    public int getRepeatIntervalAsSeconds()
    Get the configured repeat interval for the ScheduledJob in seconds irrespective of the configuration property was set.

    Returns:
    the configured repeat interval for the ScheduledJob in seconds.

    setRepeatIntervalHours

    public void setRepeatIntervalHours(int repeatIntervalHours)
    The scheduled job will fire every repeatIntervalHours hours.

    Parameters:
    repeatIntervalHours - The number of minutes to pause between firing the ScheduledJob.

    setConfigFilePath

    public void setConfigFilePath(java.lang.String configFile)
    Set the configuration file name.

    Overrides:
    setConfigFilePath in class XMLConfiguration
    Parameters:
    configFile - the configuration file name.

    setDebugFlag

    public void setDebugFlag(boolean debugFlag)
    Set the debugFlag.

    Overrides:
    setDebugFlag in class XMLConfiguration
    Parameters:
    debugFlag - The debugFlag.

    toString

    public java.lang.String toString()
    Returns the String representation of this ScheduledJobConfiguration.

    Overrides:
    toString in class XMLConfiguration
    Returns:
    the String representation of this ScheduledJobConfiguration.

    main

    public static void main(java.lang.String[] args)
    main() For testing.

    Parameters:
    args - commandline arguments