org.instrumentmiddleware.cima.plugin.producer.impl
Class AbstractProducer

java.lang.Object
  extended by org.instrumentmiddleware.cima.plugin.impl.AbstractPlugin
      extended by org.instrumentmiddleware.cima.plugin.producer.impl.AbstractProducer
All Implemented Interfaces:
ICIMAOperationExtension, ICIMAPlugin, IPlugin, IProducer
Direct Known Subclasses:
AbstractMultiPollerParcelProducer, AbstractSinglePollerParcelProducer

public abstract class AbstractProducer
extends AbstractPlugin
implements IProducer, ICIMAOperationExtension

It is recommended that all producer plugins subclass this plugin to maintain semantic consistency for CIMA operation. Methods of interest to subclasses are the #run() method and the #releaseParcel(Parcel) method.

Author:
andrew
See Also:
org.instrumentmiddleware.cima.plugin.IProducer

Field Summary
protected  java.lang.Class<?> deliveryStrategy
          The delivery strategy to use to deliver the parcels TODO: seems a bit clunky to have the director and the delivery strategy in here
protected  ICIMADirector director
          The director to release parcels to TODO: seems a bit clunky to have the director and the delivery strategy in here
protected static org.apache.log4j.Logger log
           
protected  IParcelCreator parcelCreator
          The creator of the parcels
 
Fields inherited from class org.instrumentmiddleware.cima.plugin.impl.AbstractPlugin
startOnLoad, stopped, subscriptions
 
Constructor Summary
AbstractProducer(java.lang.String id, IParcelCreator creator, ICIMADirector director)
          Instantiate the producer The id, creator and director are checked for non-null-ness, and the id is checked for non-emptiness.
 
Method Summary
 java.lang.Class<?> getDeliveryStrategy()
          Returns the delivery strategy
 org.instrumentmiddleware.cima.parcel.CimaOperationResponseType processGetOperation(org.instrumentmiddleware.cima.parcel.CimaVariable[] variables, java.util.Calendar creationTime, ISession session, org.instrumentmiddleware.cima.parcel.CimaOperationResponseType response)
          Gets the given variables value.
 org.instrumentmiddleware.cima.parcel.CimaOperationResponseType processSetOperation(org.instrumentmiddleware.cima.parcel.CimaVariable[] variables, java.util.Calendar creationTime, ISession session, org.instrumentmiddleware.cima.parcel.CimaOperationResponseType response)
          Sets the given variables value.
 org.instrumentmiddleware.cima.parcel.ResponseType processSubscribeParcel(org.instrumentmiddleware.cima.parcel.BodyType body, java.util.Calendar creationTime, ISession session, org.instrumentmiddleware.cima.parcel.ResponseType response)
          Process a subscribe parcel.
 void releaseParcel(org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel parcel)
          Release the parcel to CIMA for delivery.
 void setDeliveryStrategy(java.lang.Class<?> strategy)
          Sets the delivery strategy.
 void start()
          Start this plugin.
 void stop()
          Stop this plugin.
 
Methods inherited from class org.instrumentmiddleware.cima.plugin.impl.AbstractPlugin
doSubscribe, doSubscribe, getBodyHandler, getId, getInformation, getSequenceNumber, internalProcessParcel, processParcel, processSubscribeResponse, setStartOnLoad, setSubscriptions, startOnLoad
 
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.plugin.IPlugin
doSubscribe, getId, getInformation, getSequenceNumber, processParcel, setStartOnLoad, startOnLoad
 
Methods inherited from interface org.instrumentmiddleware.cima.plugin.IPlugin
doSubscribe, getId, getInformation, getSequenceNumber, processParcel, setStartOnLoad, startOnLoad
 

Field Detail

log

protected static org.apache.log4j.Logger log

parcelCreator

protected IParcelCreator parcelCreator
The creator of the parcels


director

protected ICIMADirector director
The director to release parcels to TODO: seems a bit clunky to have the director and the delivery strategy in here


deliveryStrategy

protected java.lang.Class<?> deliveryStrategy
The delivery strategy to use to deliver the parcels TODO: seems a bit clunky to have the director and the delivery strategy in here

Constructor Detail

AbstractProducer

public AbstractProducer(java.lang.String id,
                        IParcelCreator creator,
                        ICIMADirector director)
                 throws java.lang.Exception
Instantiate the producer The id, creator and director are checked for non-null-ness, and the id is checked for non-emptiness. If any of these tests fail an exception is thrown.

Parameters:
id - the plugin id
creator - the parcel creator
director - the director to release parcels to
Throws:
java.lang.Exception - if any arguments are null or empty
Method Detail

setDeliveryStrategy

public void setDeliveryStrategy(java.lang.Class<?> strategy)
Sets the delivery strategy.

Specified by:
setDeliveryStrategy in interface IProducer
Parameters:
strategy - the strategy

getDeliveryStrategy

public java.lang.Class<?> getDeliveryStrategy()
Returns the delivery strategy

Specified by:
getDeliveryStrategy in interface IProducer
Returns:
the strategy

processSubscribeParcel

public org.instrumentmiddleware.cima.parcel.ResponseType processSubscribeParcel(org.instrumentmiddleware.cima.parcel.BodyType body,
                                                                                java.util.Calendar creationTime,
                                                                                ISession session,
                                                                                org.instrumentmiddleware.cima.parcel.ResponseType response)
                                                                         throws PluginException
Process a subscribe parcel. This method appends the endpoint of the remote entity to the session to allow delivery of parcels produced by this producer. The IDeliveryStrategy needs this information to deliver the parcel.

Throws:
PluginException
See Also:
org.instrumentmiddleware.cima.plugin.impl.AbstractPlugin.internalProcessParcel(BodyType, ISession, ResponseType)

releaseParcel

public final void releaseParcel(org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel parcel)
Release the parcel to CIMA for delivery. Subclasses should use this method to release created parcels for delivery.

Specified by:
releaseParcel in interface IProducer
Parameters:
parcel - the parcel to send
See Also:
org.instrumentmiddleware.cima.plugin.IProducer.releaseParcel(Parcel)

start

public void start()
           throws PluginException
Description copied from interface: IPlugin
Start this plugin. This allows a plugin to perform some initialisation and is called when CIMA expects some interaction with this plugin

Specified by:
start in interface IPlugin
Overrides:
start in class AbstractPlugin
Throws:
PluginException
See Also:
org.instrumentmiddleware.cima.plugin.Plugin#start()

stop

public void stop()
          throws PluginException
Description copied from interface: IPlugin
Stop this plugin. This allows a plugin to perform some cleanup and is called when CIMA expects no further interaction with this plugin

Specified by:
stop in interface IPlugin
Overrides:
stop in class AbstractPlugin
Throws:
PluginException
See Also:
org.instrumentmiddleware.cima.plugin.Plugin#stop()

processGetOperation

public org.instrumentmiddleware.cima.parcel.CimaOperationResponseType processGetOperation(org.instrumentmiddleware.cima.parcel.CimaVariable[] variables,
                                                                                          java.util.Calendar creationTime,
                                                                                          ISession session,
                                                                                          org.instrumentmiddleware.cima.parcel.CimaOperationResponseType response)
                                                                                   throws PluginException
Description copied from interface: ICIMAOperationExtension
Gets the given variables value. The result is a parcel containing the value of given variables

Specified by:
processGetOperation in interface ICIMAOperationExtension
Parameters:
variables - The variables to get the value from
session - The session this communication belongs to
response - response the partly built response
Returns:
a parcel containing the value of given variables
Throws:
PluginException - if something goes wrong while retrieving variables values

processSetOperation

public org.instrumentmiddleware.cima.parcel.CimaOperationResponseType processSetOperation(org.instrumentmiddleware.cima.parcel.CimaVariable[] variables,
                                                                                          java.util.Calendar creationTime,
                                                                                          ISession session,
                                                                                          org.instrumentmiddleware.cima.parcel.CimaOperationResponseType response)
                                                                                   throws PluginException
Description copied from interface: ICIMAOperationExtension
Sets the given variables value.

Specified by:
processSetOperation in interface ICIMAOperationExtension
Parameters:
variables - The variables to be set
session - The session this communication belongs to
response - The partly built response
Returns:
a parcel containing the result of set execution
Throws:
PluginException - if something goes wrong while setting variables values


Copyright © 2008. All Rights Reserved.