com.emarsys.ecommon.time.schedule
Interface QueueSchedulingStrategy<T>

All Known Implementing Classes:
ConstantQueueSchedulingStrategy, DelayedLinearQueueSchedulingStrategy, FixedQueueSchedulingStrategy, LinearQueueSchedulingStrategy, MockSchedulingStrategy, QueueSchedulingStrategyChain

public interface QueueSchedulingStrategy<T>

A QueueSchedulingStrategy encapsulates a concrete policy on when to process a SchedulableQueueElement. Thus it represents a time based, stateless scheduling algorithm.

A concrete Class implementing this interface specifies the generic scheduling algorithm and a concrete instance applies fixed configuration values to the algorithm. So two instances of the same class implementing QueueSchedulingStrategy could nevertheless represent different scheduling mechanisms due to their configuration, specified by constructor parameters.

Note that the configuration of the strategy is frozen with its instantiation; possible corresponding getter methods must not return different values during the lifetime of the strategy. Iff there's a change needed in the algorithms initial parameters then a new instance with changed settings has to be created and used for the actual scheduling.

Author:
Michael "kULO" Kulovits

See Also:
QueueScheduler, SchedulableQueueElement

Method Summary
 java.util.Calendar calculateNextProcessing(QueueScheduler<T> scheduler, SchedulableQueueElement<T> schedulable)
           Performs the concrete scheduling algorithm defined by this QueueSchedulingStrategy on the passed SchedulableQueueElement.
 

Method Detail

calculateNextProcessing

java.util.Calendar calculateNextProcessing(QueueScheduler<T> scheduler,
                                           SchedulableQueueElement<T> schedulable)

Performs the concrete scheduling algorithm defined by this QueueSchedulingStrategy on the passed SchedulableQueueElement.

All information needed by the algorithm should be retrieved from the passed schedulable and scheduler instances.

The passed schedulable should not be altered by this algorithm. In order to decouple the scheduling algorithm as much as possible and to preserve flexibility and reusabiltiy the schedulable should itself be responsible for changing its internal state in its SchedulableQueueElement.getScheduled(QueueScheduler) method.

Parameters:
scheduler - - the QueueScheduler that is associated with this strategy instance
schedulable - - the SchedulableQueueElement that will be (re)scheduled
Returns:
the next scheduled date for the passed SchedulableQueueElement



Copyright © 2010 emarsys AG. All Rights Reserved.