com.emarsys.ecommon.time.schedule
Class SchedulableQueueElementProxy<T>

java.lang.Object
  extended by com.emarsys.ecommon.time.schedule.SchedulableQueueElementProxy<T>
All Implemented Interfaces:
SchedulableQueueElement<T>, GenericAdapter<T>

public class SchedulableQueueElementProxy<T>
extends java.lang.Object
implements SchedulableQueueElement<T>

A proxy for SchedulableQueueElements that allows for some manipulations.

Author:
Michael "kULO" Kulovits

Field Summary
protected  SchedulableQueueElement<T> schedulable
           
protected  int scheduledCountOffset
           
 
Constructor Summary
SchedulableQueueElementProxy(SchedulableQueueElement<T> schedulable)
           
 
Method Summary
 T getConcreteInstance()
           
 java.util.Calendar getLastProcessing()
           Returns the schedulable's last processing date.
 java.util.Calendar getMaxScheduleDate()
           Returns the maximum schedule date which defines a date in the future and must not be exceeded on reschedulings.
 int getMinSchedulingInterval()
           Returns the minimal scheduling interval in milliseconds that is compulsory for this SchedulableQueueElement.
 java.util.Calendar getNextProcessing()
           Returns the next scheduled date which a priori is null.
static
<T> SchedulableQueueElementProxy<T>
getProxy(SchedulableQueueElement<T> schedulable)
          Factory method.
 java.util.Calendar getQueueingDate()
           Returns the schedulable's queueing date.
 java.util.Calendar getScheduled(QueueScheduler<T> scheduler)
           (Re)schedules this queue element using the passed QueueScheduler.
 int getScheduledCount()
          Will add the scheduledCountOffset to #schedulable#getScheduledCount() (or subtract if the prior is negative), but the value won't be < 0.
 int getScheduledCountOffset()
           
 java.util.Calendar now()
           Returns the schedulables notion of the current time.
 void setScheduledCountOffset(int scheduledCountOffset)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schedulable

protected SchedulableQueueElement<T> schedulable

scheduledCountOffset

protected int scheduledCountOffset
Constructor Detail

SchedulableQueueElementProxy

public SchedulableQueueElementProxy(SchedulableQueueElement<T> schedulable)
Parameters:
schedulable -
Method Detail

getProxy

public static final <T> SchedulableQueueElementProxy<T> getProxy(SchedulableQueueElement<T> schedulable)
Factory method.

Type Parameters:
T -
Parameters:
schedulable -
Returns:

getScheduledCountOffset

public int getScheduledCountOffset()
Returns:
the scheduledCountOffset

setScheduledCountOffset

public void setScheduledCountOffset(int scheduledCountOffset)
Parameters:
scheduledCountOffset - the scheduledCountOffset to set

getConcreteInstance

public T getConcreteInstance()
Specified by:
getConcreteInstance in interface GenericAdapter<T>
Returns:
See Also:
GenericAdapter.getConcreteInstance()

getLastProcessing

public java.util.Calendar getLastProcessing()
Description copied from interface: SchedulableQueueElement

Returns the schedulable's last processing date.

The last scheduled date refers to the time of the last rescheduling, i.e. on the last call to SchedulableQueueElement.getScheduled(QueueScheduler) this value should have been set to SchedulableQueueElement.now().

A priori the last scheduled date is null.

Specified by:
getLastProcessing in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.getLastProcessing()

getMaxScheduleDate

public java.util.Calendar getMaxScheduleDate()
Description copied from interface: SchedulableQueueElement

Returns the maximum schedule date which defines a date in the future and must not be exceeded on reschedulings.

Specified by:
getMaxScheduleDate in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.getMaxScheduleDate()

getMinSchedulingInterval

public int getMinSchedulingInterval()
Description copied from interface: SchedulableQueueElement

Returns the minimal scheduling interval in milliseconds that is compulsory for this SchedulableQueueElement.

On getting scheduled (see SchedulableQueueElement.getScheduled(QueueScheduler)) this schedulable must not set its next processing date either to a value >= (SchedulableQueueElement.now() + minSchedulingInterval) or to null (which is actually the dequeueing of the schedulable queue element).

Specified by:
getMinSchedulingInterval in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.getMinSchedulingInterval()

getNextProcessing

public java.util.Calendar getNextProcessing()
Description copied from interface: SchedulableQueueElement

Returns the next scheduled date which a priori is null.

Specified by:
getNextProcessing in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.getNextProcessing()

getQueueingDate

public java.util.Calendar getQueueingDate()
Description copied from interface: SchedulableQueueElement

Returns the schedulable's queueing date.

The queueing date represents the timestamp when this SchedulableQueueElement has been added to the queuing mechanism.

Specified by:
getQueueingDate in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.getQueueingDate()

getScheduled

public java.util.Calendar getScheduled(QueueScheduler<T> scheduler)
Description copied from interface: SchedulableQueueElement

(Re)schedules this queue element using the passed QueueScheduler.

The passed QueueScheduler will be used to retrieve a QueueSchedulingStrategy for this SchedulableQueueElement that will be used to calculate the date of the next processing which will be set to the new value, see SchedulableQueueElement.getNextProcessing().
Futhermore the last processing date will be set to the current time.

The SchedulableQueueElement must not set its next processing date to a value that's not at least SchedulableQueueElement.getMinSchedulingInterval() millis after the last processing date (which is SchedulableQueueElement.now() during SchedulableQueueElement.getScheduled(QueueScheduler)).

Specified by:
getScheduled in interface SchedulableQueueElement<T>
Parameters:
scheduler -
Returns:
See Also:
SchedulableQueueElement.getScheduled(com.emarsys.ecommon.time.schedule.QueueScheduler)

getScheduledCount

public int getScheduledCount()
Will add the scheduledCountOffset to #schedulable#getScheduledCount() (or subtract if the prior is negative), but the value won't be < 0.

Specified by:
getScheduledCount in interface SchedulableQueueElement<T>
Returns:
an int >= 0 representing the number of times this SchedulableQueueElement has been (re-)scheduled.
See Also:
SchedulableQueueElement.getScheduledCount()

now

public java.util.Calendar now()
Description copied from interface: SchedulableQueueElement

Returns the schedulables notion of the current time.

Might be a clone of the queueing date.

Specified by:
now in interface SchedulableQueueElement<T>
Returns:
See Also:
SchedulableQueueElement.now()


Copyright © 2010 emarsys AG. All Rights Reserved.