Compoze Software, Inc.

com.compoze.trigger
Class Trigger


java.lang.Object

  |

  +--com.compoze.trigger.Trigger

All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Trigger
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

This class is an association between a time and an action to trigger. Trigger are stored by an implementor of ITriggerList. The Comparable interface is implemented to order triggers by their earliest date in the date list.

See Also:
Serialized Form

Inner Class Summary
 class Trigger.ActionThread
          This class is a thread that invokes the action for this event.
 
Constructor Summary
Trigger()
          Constructor.
Trigger(java.util.Date date, java.util.Collection actions)
          Constructs a trigger with specified date when the trigger executes, and the specified actions to process.
Trigger(java.util.Date date, java.util.Collection actions, java.util.Collection progresses)
          Constructs a trigger with specified date when the trigger executes, specified actions to process, and specified progresses.
Trigger(java.util.Date date, java.util.Collection actions, java.util.Collection progresses, ITimeoutAlgorithm timeout, long lExpiration)
          Constructs a trigger with a specified date when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Trigger(java.util.Date eventDate, DateRecurrence recurrence, int iRemindBeforeHand, java.util.Collection actions)
          Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Trigger(java.util.Date eventDate, DateRecurrence recurrence, int iRemindBeforeHand, ITriggerAction action)
          Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Trigger(java.util.Date eventDate, DateRecurrence recurrence, long lRemindBeforeHand, java.util.Collection actions)
          Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Trigger(java.util.Date eventDate, DateRecurrence recurrence, long lRemindBeforeHand, ITriggerAction action)
          Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Trigger(java.util.Date date, ITriggerAction action)
          Constructs a trigger with specified date when the trigger executes, and the specified action to process.
Trigger(java.util.Date date, ITriggerAction action, ITriggerProgress progress)
          Constructs a trigger with specified date when the trigger executes, a specified action to process, and a specified progress.
Trigger(java.util.Date date, ITriggerAction action, ITriggerProgress progress, ITimeoutAlgorithm timeout, long lExpiration)
          Constructs a trigger with a specified date when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Trigger(IDateList dates, java.util.Collection actions)
          Constructs a trigger with specified date list of when the trigger executes, and specified actions to process.
Trigger(IDateList dates, java.util.Collection actions, java.util.Collection progresses)
          Constructs a trigger with specified date list of when the trigger executes, specified actions to process, and specified progresses.
Trigger(IDateList dates, java.util.Collection actions, java.util.Collection progresses, ITimeoutAlgorithm timeout, long lExpiration)
          Constructs a trigger with a specified date list of when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Trigger(IDateList dates, ITriggerAction action)
          Constructs a trigger with specified date list of when the trigger executes, and the specified action to process.
Trigger(IDateList dates, ITriggerAction action, ITriggerProgress progress)
          Constructs a trigger with specified date list of when the trigger executes, specified action to process, and specified progress.
Trigger(IDateList dates, ITriggerAction action, ITriggerProgress progress, ITimeoutAlgorithm timeout, long lExpiration)
          Constructs a trigger with a specified date list of when the trigger executes, specified action to process, specified progress, timeout algorithm for retries, and an expiration.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this to the passed in trigger event.
 boolean execute()
          Waits for the next date to occur, then trigger the action in a new thread.
 IDateList getDates()
          Gets the list of trigger dates.
 long getEventID()
          Gets the associated event ID.
 long getExpiration()
          Gets the number of milliseconds after each action starts that it expires, or will not be executed if it fails.
 long getID()
          Gets the trigger ID.
 long getRemindBeforeHand()
          Gets the amount of time (in millis) to remind before an event.
 ITimeoutAlgorithm getTimeoutAlgorithm()
          Gets the timeout alogithm.
 java.util.Collection getTriggerActions()
          Gets a collection of trigger actions.
 long getTriggerPK()
          Gets the trigger ID.
 java.util.Collection getTriggerProgresses()
          Gets a colleciton of trigger progresses.
 void setDate(java.util.Date date)
          Sets the date to execute the trigger.
 void setDates(IDateList dates)
          Sets the list of dates to execute the trigger.
 void setEventID(long lEventID)
           
 void setExpiration(long lExpiration)
          Sets the number of milliseconds after each action starts that it expires, or will not be executed if it fails.
 void setOffset(long lOffset)
          Sets the time offset between the client and the server.
 void setRemindBeforeHand(long lRemindBeforeHand)
          Sets the amount of time (in millis) to remind before a trigger.
 void setTimeoutAlgorithm(ITimeoutAlgorithm timeout)
          Sets the timeout algorithm.
 void setTriggerAction(ITriggerAction action)
          Sets action to trigger to the specified action.
 void setTriggerActions(java.util.Collection actions)
          Sets the trigger actions.
 void setTriggerProgresses(java.util.Collection progresses)
          Sets the progress indicators to be notified as the trigger is processes.
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Trigger


public Trigger()
Constructor.

Trigger


public Trigger(java.util.Date eventDate,
               DateRecurrence recurrence,
               int iRemindBeforeHand,
               ITriggerAction action)
Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Parameters:
eventDate - the date the event is to occur
recurrence - the recurrence for the event
iRemindBeforeHand - the number of minutes to remind before event
action - the action to process (ITriggerAction)

Trigger


public Trigger(java.util.Date eventDate,
               DateRecurrence recurrence,
               int iRemindBeforeHand,
               java.util.Collection actions)
Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Parameters:
eventDate - the date the event is to occur
recurrence - the recurrence for the event
iRemindBeforeHand - the number of minutes to remind before event
actions - the collection of actions to process (ITriggerAction)

Trigger


public Trigger(java.util.Date eventDate,
               DateRecurrence recurrence,
               long lRemindBeforeHand,
               ITriggerAction action)
Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Parameters:
eventDate - the date the event is to occur
recurrence - the recurrence for the event
lRemindBeforeHand - the number of minutes(in millis) to remind before event
action - the action to process (ITriggerAction)

Trigger


public Trigger(java.util.Date eventDate,
               DateRecurrence recurrence,
               long lRemindBeforeHand,
               java.util.Collection actions)
Constructs a trigger with specified event date, specified number of minutes to remind before event, and the specified action to process.
Parameters:
eventDate - the date the event is to occur
recurrence - the recurrence for the event
lRemindBeforeHand - the number of minutes(in millis) to remind before event
actions - the collection of actions to process (ITriggerAction)

Trigger


public Trigger(java.util.Date date,
               ITriggerAction action)
Constructs a trigger with specified date when the trigger executes, and the specified action to process.
Parameters:
date - the date to trigger action
action - the trigger action interface to notify

Trigger


public Trigger(java.util.Date date,
               java.util.Collection actions)
Constructs a trigger with specified date when the trigger executes, and the specified actions to process.
Parameters:
dates - the dates to trigger the action
action - the trigger action interface to notify

Trigger


public Trigger(IDateList dates,
               ITriggerAction action)
Constructs a trigger with specified date list of when the trigger executes, and the specified action to process.
Parameters:
dates - the dates to trigger the action
action - the trigger action interface to notify

Trigger


public Trigger(IDateList dates,
               java.util.Collection actions)
Constructs a trigger with specified date list of when the trigger executes, and specified actions to process.
Parameters:
dates - the dates to trigger the action
actions - the trigger action interface to notify

Trigger


public Trigger(java.util.Date date,
               ITriggerAction action,
               ITriggerProgress progress)
Constructs a trigger with specified date when the trigger executes, a specified action to process, and a specified progress.
Parameters:
date - the date to trigger the action
action - the trigger action interface to notify
progress - the trigger progress interface to notify

Trigger


public Trigger(java.util.Date date,
               java.util.Collection actions,
               java.util.Collection progresses)
Constructs a trigger with specified date when the trigger executes, specified actions to process, and specified progresses.
Parameters:
date - the date to trigger the action
actions - the trigger action interfaces to notify
progresses - the trigger progress interfaces to notify

Trigger


public Trigger(IDateList dates,
               ITriggerAction action,
               ITriggerProgress progress)
Constructs a trigger with specified date list of when the trigger executes, specified action to process, and specified progress.
Parameters:
dates - the dates to trigger the action
action - the trigger action interface to notify
progress - the trigger progress interface to notify

Trigger


public Trigger(IDateList dates,
               java.util.Collection actions,
               java.util.Collection progresses)
Constructs a trigger with specified date list of when the trigger executes, specified actions to process, and specified progresses.
Parameters:
dates - the dates to trigger the action
actions - the trigger action interfaces to notify
progresses - the trigger progress interfaces to notify

Trigger


public Trigger(java.util.Date date,
               ITriggerAction action,
               ITriggerProgress progress,
               ITimeoutAlgorithm timeout,
               long lExpiration)
Constructs a trigger with a specified date when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Parameters:
date - the date to trigger the action
action - the trigger action interface to notify
progress - the trigger progress interface to notify
timeout - the timeout alogortihm for retries
lExpiration - the time after which if actions does not succeed they are considered a failure (0 for indefinite) in milliseconds

Trigger


public Trigger(java.util.Date date,
               java.util.Collection actions,
               java.util.Collection progresses,
               ITimeoutAlgorithm timeout,
               long lExpiration)
Constructs a trigger with a specified date when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Parameters:
date - the date to trigger the action
actions - the trigger action interfaces to notify
progresses - the trigger progress interfaces to notify
timeout - the timeout alogortihm for retries
lExpiration - the time after which if actions do not succeed they are considered a failure (0 for indefinite) in milliseconds

Trigger


public Trigger(IDateList dates,
               ITriggerAction action,
               ITriggerProgress progress,
               ITimeoutAlgorithm timeout,
               long lExpiration)
Constructs a trigger with a specified date list of when the trigger executes, specified action to process, specified progress, timeout algorithm for retries, and an expiration.
Parameters:
dates - the dates to trigger the action
action - the trigger action interface to notify
progress - the trigger progress interface to notify
timeout - the timeout alogortihm for retries
lExpiration - the time after which if actions do not succeed they are considered a failure (0 for indefinite) in milliseconds

Trigger


public Trigger(IDateList dates,
               java.util.Collection actions,
               java.util.Collection progresses,
               ITimeoutAlgorithm timeout,
               long lExpiration)
Constructs a trigger with a specified date list of when the trigger executes, specified actions to process, specified progresses, timeout algorithm for retries, and an expiration.
Parameters:
dates - the dates to trigger the action
actions - the trigger action interfaces to notify
progresses - the trigger progress interfaces to notify
timeout - the timeout alogortihm for retries
lExpiration - the time after which if actions do not succeed they are considered a failure (0 for indefinite) in milliseconds
Method Detail

getTriggerPK


public long getTriggerPK()
Gets the trigger ID. This number is the unique primary key for the trigger. This is the same method as getID().
Returns:
the trigger ID (primary key)
See Also:
getID()

getID


public long getID()
Gets the trigger ID. This number is the unique primary key for the trigger. This is the same method as getTriggerPK().
Returns:
the trigger ID (primary key)
See Also:
getTriggerPK()

setEventID


public void setEventID(long lEventID)

getEventID


public long getEventID()
Gets the associated event ID.
Returns:
the event id or 0 if not set

getRemindBeforeHand


public long getRemindBeforeHand()
Gets the amount of time (in millis) to remind before an event.
Returns:
the amount of time to reminder before trigger (in millis)

setRemindBeforeHand


public void setRemindBeforeHand(long lRemindBeforeHand)
Sets the amount of time (in millis) to remind before a trigger.
Parameters:
lRemindBeforeHand - the amount of time (in millis)

getDates


public IDateList getDates()
Gets the list of trigger dates.
Returns:
a list of dates to execute trigger

setDates


public void setDates(IDateList dates)
Sets the list of dates to execute the trigger.
Parameters:
dateList - a list of dates to execute the trigger (may not be null)

setDate


public void setDate(java.util.Date date)
Sets the date to execute the trigger.
Parameters:
date - the date of trigger

getTriggerActions


public java.util.Collection getTriggerActions()
Gets a collection of trigger actions.
Returns:
a collection of ITriggerAction objects

setTriggerActions


public void setTriggerActions(java.util.Collection actions)
Sets the trigger actions.
Parameters:
actions - a collection of ITriggerAction objects (may not be null)

setTriggerAction


public void setTriggerAction(ITriggerAction action)
Sets action to trigger to the specified action. All existing actions are removed.
Parameters:
action - the action to set (may not be null)

getTriggerProgresses


public java.util.Collection getTriggerProgresses()
Gets a colleciton of trigger progresses.
Returns:
a collection of ITriggerProgress objects (unmodifiable)

setTriggerProgresses


public void setTriggerProgresses(java.util.Collection progresses)
Sets the progress indicators to be notified as the trigger is processes.
Parameters:
progresses - a collection of ITriggerProgress objects (may not be null)

getExpiration


public long getExpiration()
Gets the number of milliseconds after each action starts that it expires, or will not be executed if it fails.
Returns:
the number of milliseconds between starting a trigger and expiring (0 if not set)

setExpiration


public void setExpiration(long lExpiration)
Sets the number of milliseconds after each action starts that it expires, or will not be executed if it fails.
Parameters:
lExpiration - the number of milliseconds between starting a trigger and expiring (0 if not set)

getTimeoutAlgorithm


public ITimeoutAlgorithm getTimeoutAlgorithm()
Gets the timeout alogithm.
Returns:
the timeout algorithm

setTimeoutAlgorithm


public void setTimeoutAlgorithm(ITimeoutAlgorithm timeout)
Sets the timeout algorithm.
Parameters:
timeout - the timeout algorithm (may not be null)

setOffset


public void setOffset(long lOffset)
Sets the time offset between the client and the server.
Parameters:
lOffset - the offset in milliseconds

execute


public boolean execute()
                throws java.lang.InterruptedException
Waits for the next date to occur, then trigger the action in a new thread.
Returns:
true if there are more dates for this event to trigger, false if there are no more dates
Throws:
java.lang.InterruptedException - if the sleep before the trigger was interrupted
See Also:
Trigger.ActionThread

compareTo


public int compareTo(java.lang.Object o)
Compares this to the passed in trigger event. The trigger dates lists for both this object and the specified object may not be null.
Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the object to compare to
Returns:
-1, 0 or 1

toString


public java.lang.String toString()
Returns the string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this object

Compoze Software, Inc.

Copyright ©1999-2001 Compoze Software, Inc. All rights reserved.