org.instrumentmiddleware.cima.transport.delivery.impl
Class AbstractDeliveryStrategy

java.lang.Object
  extended by org.instrumentmiddleware.cima.transport.delivery.impl.AbstractDeliveryStrategy
All Implemented Interfaces:
java.util.concurrent.Callable<org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel>, IDeliveryStrategy
Direct Known Subclasses:
InfiniteTryDeliveryStrategy, TooBadDeliveryStrategy

public abstract class AbstractDeliveryStrategy
extends java.lang.Object
implements IDeliveryStrategy

The AbstractDeliveryStrategy provides convenience methods to deal with obtaining the requirements to implement delivery, namely the transport manager and parcel. There is also a method to do pre-run checks to test if this class has enough information to attempt delivery. Note that the transport manager is required to instantiate this class so no check is made for it during the canRun method

Author:
andrew

Field Summary
protected  java.util.concurrent.ExecutorService executor
          the executor by which we will attempt delivery
protected static org.apache.log4j.Logger log
           
protected  IRegisteredParcel parcel
          The parcel to deliver TODO: make this a ThreadLocal to remove the synchronization on run() see http://www.ibm.com/developerworks/java/library/j-threads3.html
protected  ITransportManager transportManager
          The transport manager which will provide our transport options
 
Constructor Summary
AbstractDeliveryStrategy(ITransportManager transportManager, java.util.concurrent.ExecutorService executor)
          Initialise this delivery strategy.
 
Method Summary
 org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel call()
           
 boolean canRun()
          Indication of runnable state of this strategy.
 void setRegisteredParcel(IRegisteredParcel parcel)
          Sets the parcel to be delivered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.instrumentmiddleware.cima.transport.delivery.IDeliveryStrategy
deliver
 

Field Detail

log

protected static org.apache.log4j.Logger log

executor

protected java.util.concurrent.ExecutorService executor
the executor by which we will attempt delivery


parcel

protected IRegisteredParcel parcel
The parcel to deliver TODO: make this a ThreadLocal to remove the synchronization on run() see http://www.ibm.com/developerworks/java/library/j-threads3.html


transportManager

protected ITransportManager transportManager
The transport manager which will provide our transport options

Constructor Detail

AbstractDeliveryStrategy

public AbstractDeliveryStrategy(ITransportManager transportManager,
                                java.util.concurrent.ExecutorService executor)
                         throws java.lang.Exception
Initialise this delivery strategy. A valid transport manager is required to correctly construct this object.

Parameters:
transportManager -
Throws:
java.lang.Exception - if the required transport manager is not valid
Method Detail

setRegisteredParcel

public void setRegisteredParcel(IRegisteredParcel parcel)
Sets the parcel to be delivered. This method should only be called once for each delivery strategy

Specified by:
setRegisteredParcel in interface IDeliveryStrategy
Parameters:
parcel - the parcel to send

canRun

public boolean canRun()
Indication of runnable state of this strategy. This method only checks for requirements this class knows about. Subclasses should override this method and call it before doing local checks.


call

public org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel call()
Specified by:
call in interface java.util.concurrent.Callable<org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel>


Copyright © 2008. All Rights Reserved.