|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.instrumentmiddleware.cima.plugin.impl.AbstractPlugin
public abstract class AbstractPlugin
AbstractPlugin has methods to deal with the more mundane aspects of a plugin, such as
the id and sequence number management and is intended to be subclassed by all plugins.
It also provides default methods that may be overridden by subclasses to provide more
functionality, such as
start()
stop()
processParcel(BodyType, Calendar, ISession, ResponseType)
This class is also the link between the internal logic for a plugin and the actual plugin
implementation. Currently the link is the internalProcessParcel(BodyType, Calendar, org.instrumentmiddleware.cima.parcel.ParcelTypeEnum.Enum, ISession, ResponseType)
method which routes an incoming parcel to an appropriate method on the plugin.
| Field Summary | |
|---|---|
protected boolean |
startOnLoad
|
protected boolean |
stopped
|
protected java.util.List<SubscribeInfo> |
subscriptions
|
| Constructor Summary | |
|---|---|
AbstractPlugin(java.lang.String id)
Instantiate the plugin The id is checked for non-null-ness and non-emptiness and an exception is thrown if either check fails |
|
| Method Summary | |
|---|---|
void |
doSubscribe()
|
org.instrumentmiddleware.cima.parcel.SubscriptionResponseType |
doSubscribe(SubscribeInfo info)
|
protected IParcelBodyHandler |
getBodyHandler(org.instrumentmiddleware.cima.parcel.BodyType body)
|
java.lang.String |
getId()
Get the plugins id. |
org.w3c.dom.Node |
getInformation()
Provide access to this plugins information. |
int |
getSequenceNumber()
Get the next sequence number for parcels created by this plugin. |
org.instrumentmiddleware.cima.parcel.ResponseType |
internalProcessParcel(org.instrumentmiddleware.cima.parcel.BodyType body,
java.util.Calendar creationTime,
org.instrumentmiddleware.cima.parcel.ParcelTypeEnum.Enum type,
ISession session,
org.instrumentmiddleware.cima.parcel.ResponseType response)
Process a parcel that was destined for this plugin. |
org.instrumentmiddleware.cima.parcel.ResponseType |
processParcel(org.instrumentmiddleware.cima.parcel.BodyType body,
java.util.Calendar creationTime,
ISession session,
org.instrumentmiddleware.cima.parcel.ResponseType response)
Process a parcel of type "plugin". |
protected void |
processSubscribeResponse(org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel response)
|
void |
setStartOnLoad(boolean startOnLoad)
This method is used to specify if this plugin will be started automatically after being loaded. |
void |
setSubscriptions(java.util.List<SubscribeInfo> subs)
|
void |
start()
Start this plugin. |
boolean |
startOnLoad()
Returns true if this plugin has been configured to start automatically after being loaded |
void |
stop()
Stop this plugin. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean startOnLoad
protected boolean stopped
protected java.util.List<SubscribeInfo> subscriptions
| Constructor Detail |
|---|
public AbstractPlugin(java.lang.String id)
throws java.lang.Exception
id - the plugin id
java.lang.Exception - if the id is null or the empty string| Method Detail |
|---|
public final java.lang.String getId()
IPlugin
getId in interface IPluginorg.instrumentmiddleware.cima.plugin.Plugin#getId()
public void start()
throws PluginException
IPlugin
start in interface IPluginPluginExceptionorg.instrumentmiddleware.cima.plugin.Plugin#start()
public void stop()
throws PluginException
IPlugin
stop in interface IPluginPluginExceptionorg.instrumentmiddleware.cima.plugin.Plugin#stop()public int getSequenceNumber()
IPlugin
getSequenceNumber in interface IPluginorg.instrumentmiddleware.cima.plugin.Plugin#getSequenceNumber()
public org.instrumentmiddleware.cima.parcel.ResponseType processParcel(org.instrumentmiddleware.cima.parcel.BodyType body,
java.util.Calendar creationTime,
ISession session,
org.instrumentmiddleware.cima.parcel.ResponseType response)
throws PluginException
processParcel in interface IPluginbody - the request bodysession - the session the parcel belongs toresponse - the partly formed response
PluginException - if there is a problem while processing the parcel
public org.instrumentmiddleware.cima.parcel.ResponseType internalProcessParcel(org.instrumentmiddleware.cima.parcel.BodyType body,
java.util.Calendar creationTime,
org.instrumentmiddleware.cima.parcel.ParcelTypeEnum.Enum type,
ISession session,
org.instrumentmiddleware.cima.parcel.ResponseType response)
throws PluginException
BodyType, a Calendar, an ISession and
a ResponseType.
All methods invoked from this method should return a ResponseType
which should be the same instance as passed via the third argument UNLESS
a type change has been performed on the response (see http://xmlbeans.apache.org/docs/2.2.0/reference/org/apache/xmlbeans/XmlObject.html#changeType(org.apache.xmlbeans.SchemaType)
for more information) in which case a reference to the new type should be returned.
NOTE:
This method currently uses reflection to accomplish this, and if the method
doesn't exist then there will be no method call. Some may think that
reflection is inappropriate for this (and they're welcome to their view)
so there's a couple of suggested alternatives below.
An alternative implementation might declare appropriate methods in the
ICIMAPlugin for each significant CIMA event (eg. subscription) then
implement those methods here to pass off to the appropriate method in
the plugin.
Another alternative might be to use a map and let the plugins populate
the map with the parcel types they're interested in and the methods
they'd like invoked for each type.
internalProcessParcel in interface ICIMAPluginbody - The requesttype - The type of the requestresponse - The forming response
PluginException - if there was a problem processing the parcelprotected IParcelBodyHandler getBodyHandler(org.instrumentmiddleware.cima.parcel.BodyType body)
public boolean startOnLoad()
IPlugin
startOnLoad in interface IPluginpublic void setStartOnLoad(boolean startOnLoad)
IPlugin
setStartOnLoad in interface IPluginstartOnLoad - If true, this plugin will start automatically after being loadedpublic void setSubscriptions(java.util.List<SubscribeInfo> subs)
public void doSubscribe()
public org.instrumentmiddleware.cima.parcel.SubscriptionResponseType doSubscribe(SubscribeInfo info)
doSubscribe in interface IPluginprotected void processSubscribeResponse(org.instrumentmiddleware.cima.parcel.ParcelDocument.Parcel response)
public org.w3c.dom.Node getInformation()
IPlugin
getInformation in interface IPlugin
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||