|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.emarsys.ecommon.time.schedule.QueueSchedulingStrategyChain<T>
public class QueueSchedulingStrategyChain<T>
A QueueSchedulingStrategyChain
implements a chain of
responsibility for queue scheduling strategies whilest being
a composited strategy itself and can be used to create
arbitrary, dynamic combinations of existing scheduling
algorithms.
The QueueSchedulingStrategyChain
design is inspired by
the GOF design patterns "Chain of Responsibilty",
"Composite" and "Strategy" although not being very puristic
in their implementation.
As said a QueueSchedulingStrategyChain
is an aggregation of
several concrete QueueSchedulingStrategy
objects that
form a strategy themselves. The "chain" is realised as a
List
of ChainElement
s.
See calculateNextProcessing(QueueScheduler, SchedulableQueueElement)
for detailed informations on the execution flow of the chain.
As defined in QueueSchedulingStrategy
's contract the
configuration/setting of a strategy has to be frozen after its
instantiation, thus it's immutable.
In order to not being forced to create a List
of
ChainElement
s "manually" a ChainFactory
can
be obtained by calling #getFactory(Object)
which is
used to build the chain step by step.
If you want to change the chain's elements you have to create a
new instance - you can easily achieve this by calling
getCloneFactory()
.
QueueSchedulingStrategy
,
Field Summary | |
---|---|
protected java.util.List<ChainElement<T>> |
elements
|
Constructor Summary | |
---|---|
QueueSchedulingStrategyChain(java.util.List<ChainElement<T>> elements)
Creates a new QueueSchedulingStrategyChain consisting
of the passed ChainElement s. |
Method Summary | ||
---|---|---|
java.util.Calendar |
calculateNextProcessing(QueueScheduler<T> scheduler,
SchedulableQueueElement<T> schedulable)
Calculates the next processing date by iterating over the strategy chain elements and for every instance... |
|
ChainFactory<T> |
getCloneFactory()
Allows for "indirect cloning" of QueueSchedulingStrategyChain s
which could be altered through the ChainFactory returned. |
|
static
|
getFactory(QueueSchedulingStrategy<T> strategy)
Creates a ChainFactory for the concrete
strategy instance (which is only used to bind the
type parameter and ensure/enable type safety) passed. |
|
static
|
getFactory(SchedulableQueueElement<T> schedulable)
Creates a ChainFactory for the concrete
schedulable instance (which is only used to bind the
type parameter and ensure/enable type safety) passed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.List<ChainElement<T>> elements
Constructor Detail |
---|
public QueueSchedulingStrategyChain(java.util.List<ChainElement<T>> elements)
QueueSchedulingStrategyChain
consisting
of the passed ChainElement
s.
elements
- Method Detail |
---|
public static <T> ChainFactory<T> getFactory(SchedulableQueueElement<T> schedulable)
ChainFactory
for the concrete
schedulable instance (which is only used to bind the
type parameter and ensure/enable type safety) passed.
public static <T> ChainFactory<T> getFactory(QueueSchedulingStrategy<T> strategy)
ChainFactory
for the concrete
strategy instance (which is only used to bind the
type parameter and ensure/enable type safety) passed.
public java.util.Calendar calculateNextProcessing(QueueScheduler<T> scheduler, SchedulableQueueElement<T> schedulable)
elements
and for every instance...
ChainElement
, i.e. the current result and schedulableChainElement.fires()
the next processing date
will be computed by ChainElement.execute(QueueScheduler)
null
) the
element is asked if the execution should
ChainElement.proceed()
, if not the result will be
returned
calculateNextProcessing
in interface QueueSchedulingStrategy<T>
scheduler
- - the QueueScheduler
that is associated
with this strategy instanceschedulable
- - the SchedulableQueueElement
that
will be (re)scheduled
Calendar
object representing the next
processing date - might be null
.QueueSchedulingStrategy.calculateNextProcessing(com.emarsys.ecommon.time.schedule.QueueScheduler, com.emarsys.ecommon.time.schedule.SchedulableQueueElement)
public ChainFactory<T> getCloneFactory()
QueueSchedulingStrategyChain
s
which could be altered through the ChainFactory
returned.
ChainFactory
instance that is initalized
with the same elements as this instance.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |