edu.uci.isr.yancees.plugin
Class AbstractMOPlugin

java.lang.Object
  extended by edu.uci.isr.yancees.plugin.AbstractMOPlugin
All Implemented Interfaces:
MOPluginInterface, MOPluginListenerInterface, PluginInterface
Direct Known Subclasses:
AbstractMOSharedPlugin, GenericPlugin, NotificationPlugin, SubscriptionPlugin

public abstract class AbstractMOPlugin
extends java.lang.Object
implements MOPluginInterface

This abstract class defines the basic functionality of the plug-in as well as its main attributes.


Field Summary
protected  java.util.Vector myListeners
           
protected  java.util.Vector myRequiredPlugins
           
 
Constructor Summary
AbstractMOPlugin(SubscriberInterface si, SubscriptionInterface sub, org.w3c.dom.Node subTree)
           
 
Method Summary
 void addListener(MOPluginListenerInterface plugin)
          Makes this plug-in notify another provided plugin whenever it computers its output
 void addRequiredPlugin(MOPluginInterface plugin)
          This method is used by the subscription parser to inform the plugin of all the plug-ins that are supposed to notify this plugin when they are finished with their processing.
 void dispose()
          This method is part of the plug-in memory and resources management.
protected  void finalize()
           
 long[] getExpectedPluginIDs()
           
 java.lang.String getFullContext()
           
 java.lang.String getFullPath()
           
 long getId()
           
 MOPluginInterface[] getRequiredPluginsList()
           
 SubscriberInterface getSubscriber()
           
 SubscriptionInterface getSubscription()
           
 org.w3c.dom.Node getSubtree()
           
 java.lang.String getTag()
           
 boolean hasChildren()
          Determines whether this plug-in requires other plug-ins or not.
protected  void publishOutput(EventInterface evt)
          Publishes the provided output to this plug-in listeners.
protected  void publishOutput(EventInterface[] evtPat)
          Publishes the provided event pattern to the event dispatcher
abstract  void receivePluginNotification(EventInterface[] evtList, MOPluginInterface source)
          Receives a list of events as notifications from another plug-in
abstract  void receivePluginNotification(EventInterface evt, MOPluginInterface source)
          Receives a notification from another plug-in
 void removeListener(MOPluginListenerInterface plugin)
          Removes a plug-in registered as listener of this plug-in
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myListeners

protected java.util.Vector myListeners

myRequiredPlugins

protected java.util.Vector myRequiredPlugins
Constructor Detail

AbstractMOPlugin

public AbstractMOPlugin(SubscriberInterface si,
                        SubscriptionInterface sub,
                        org.w3c.dom.Node subTree)
Parameters:
si - TODO
sub - TODO
subTree - is the DOM tree this plugin is responsible for executing
Method Detail

getSubscriber

public SubscriberInterface getSubscriber()
Specified by:
getSubscriber in interface MOPluginInterface
Returns:
a reference of the subscriber that triggered the creation of the plug-in

getSubscription

public SubscriptionInterface getSubscription()
Specified by:
getSubscription in interface MOPluginInterface
Returns:
a reference to the subscription this plug-in participates

addRequiredPlugin

public void addRequiredPlugin(MOPluginInterface plugin)
This method is used by the subscription parser to inform the plugin of all the plug-ins that are supposed to notify this plugin when they are finished with their processing. This method is invoked in the BFS order in which the tags each plugin processes are parsed in the DOM tree. This information is necessary for plug-ins as the sequence detection in which the order of notifications may be important. This also prevents that plug-ins get garbage colleted, keeping required plug-ins in memory while necessary.

Specified by:
addRequiredPlugin in interface MOPluginInterface
Parameters:
id - is an id of a plug-in that will notify this instance

getRequiredPluginsList

public MOPluginInterface[] getRequiredPluginsList()
Specified by:
getRequiredPluginsList in interface MOPluginInterface
Returns:
the list of plug-ins this plug-in depends on

hasChildren

public boolean hasChildren()
Determines whether this plug-in requires other plug-ins or not.

Specified by:
hasChildren in interface MOPluginInterface
Returns:
true if this plug-in requires other plug-ins or false if not

getExpectedPluginIDs

public long[] getExpectedPluginIDs()
Returns:
a list of plug-in IDs, which notifications are expected by this plugin. The result is provided in a BFS order.

getId

public long getId()
Specified by:
getId in interface PluginInterface
Returns:
the unique Id of this plugin

getTag

public java.lang.String getTag()
Specified by:
getTag in interface PluginInterface
Returns:
the tag name that this plugin is representing. It corresponds to the type of this plugin instance. For example, if this is a plug-in that handles a subtree headed by the tag, its type will be "followed-by"

getFullContext

public java.lang.String getFullContext()
Specified by:
getFullContext in interface MOPluginInterface
Returns:
a string separated by '/' that expresses the context, or sequence of tags from the root of a subscription DOM subtree to the subtree that this plug-in represents. For example, if this plug-in will handle the subtree headed by the tag in a subscription like: ... ... ... its full context will be 'subscription/rule' because followed-by is inside this path. The context is the path without the tag name. This information will be part of all events produced by this component. This information helps the subscription node to identify the events coming from this component, knowing that that specific branch of his was evaluated and the answer comes in that event.

getFullPath

public java.lang.String getFullPath()
Specified by:
getFullPath in interface MOPluginInterface
Returns:
a string separated by '/' that expresses the path, or sequence of tags from the root of a subscription DOM subtree to the subtree that this plug-in represents. For example, if this plug-in will handle the subtree headed by the tag in a subscripton like: ... ... ... its full path will be 'subscription/rule/followed-by' This information will be part of all events produced by this component. This information helps the subscription node to identify the events coming from this component, knowing that that specific branch of his was evaluated and the answer comes in that event.

getSubtree

public org.w3c.dom.Node getSubtree()
Specified by:
getSubtree in interface MOPluginInterface
Returns:
the DOM subtree that is handled (and headed) by this plug-in

publishOutput

protected void publishOutput(EventInterface evt)
Publishes the provided output to this plug-in listeners.

Parameters:
evt - is the event to be published to the listeners of this plug-in

publishOutput

protected void publishOutput(EventInterface[] evtPat)
Publishes the provided event pattern to the event dispatcher

Parameters:
evtPat - is the event pattern to be published to the dispather to whoever may be interested in

receivePluginNotification

public abstract void receivePluginNotification(EventInterface evt,
                                               MOPluginInterface source)
Receives a notification from another plug-in

Specified by:
receivePluginNotification in interface MOPluginListenerInterface
Parameters:
evt - is the event received
source - is the plug-in sending the notification.

receivePluginNotification

public abstract void receivePluginNotification(EventInterface[] evtList,
                                               MOPluginInterface source)
Receives a list of events as notifications from another plug-in

Specified by:
receivePluginNotification in interface MOPluginListenerInterface
Parameters:
evtList - is the list of events received
source - is the plug-in sending the notification.

addListener

public void addListener(MOPluginListenerInterface plugin)
Makes this plug-in notify another provided plugin whenever it computers its output

Specified by:
addListener in interface MOPluginInterface

removeListener

public void removeListener(MOPluginListenerInterface plugin)
Removes a plug-in registered as listener of this plug-in

Specified by:
removeListener in interface MOPluginInterface

dispose

public void dispose()
This method is part of the plug-in memory and resources management. Clear all the resources allocated by this plug-in i.e. the plug-in references this plug-in depends on, as well as the listeners. This makes this object be eligible for garbage collection.

Specified by:
dispose in interface MOPluginInterface

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable