edu.uci.isr.yancees.plugin
Class AbstractPlugin

java.lang.Object
  extended byedu.uci.isr.yancees.plugin.AbstractPlugin
All Implemented Interfaces:
PluginInterface, PluginListenerInterface
Direct Known Subclasses:
AbstractCorrelationPlugin, AbstractOrderedPlugin, AbstractProtocolPlugin, AbstractSharedPlugin, ElvinPlugin, FilterPlugin, GenericPlugin, NotificationPlugin, PullPlugin, PushPlugin, RequirePlugin, RulePlugin, SequencePlugin, SienaPlugin, SubscriptionPlugin

public abstract class AbstractPlugin
extends java.lang.Object
implements PluginInterface

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
AbstractPlugin(org.w3c.dom.Node subTree)
           
 
Method Summary
 void addListener(PluginListenerInterface plugin)
          Makes this plug-in notify another provided plugin whenever it computers its output
 void addRequiredPlugin(PluginInterface 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()
           
 PluginInterface[] getRequiredPluginsList()
           
 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 the event dispatcher.
protected  void publishOutput(EventInterface[] evtPat)
          Publishes the provided event pattern to the event dispatcher
abstract  void receivePluginNotification(EventInterface[] evtList, PluginInterface source)
          Receives a list of events as notifications from another plug-in
abstract  void receivePluginNotification(EventInterface evt, PluginInterface source)
          Receives a notification from another plug-in
 void removeListener(PluginListenerInterface 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

AbstractPlugin

public AbstractPlugin(org.w3c.dom.Node subTree)
Parameters:
subTree - is the DOM tree this plugin is responsible for executing
Method Detail

addRequiredPlugin

public void addRequiredPlugin(PluginInterface 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 PluginInterface

getRequiredPluginsList

public PluginInterface[] getRequiredPluginsList()
Specified by:
getRequiredPluginsList in interface PluginInterface
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 PluginInterface
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 PluginInterface
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 subscripton 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 PluginInterface
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 PluginInterface
Returns:
the DOM subtree that is handled (and headed) by this plug-in

publishOutput

protected void publishOutput(EventInterface evt)
Publishes the provided output to the event dispatcher.

Parameters:
evt - is the event to be published to the dispather to whoever may be interested 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,
                                               PluginInterface source)
Receives a notification from another plug-in

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

receivePluginNotification

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

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

addListener

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

Specified by:
addListener in interface PluginInterface

removeListener

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

Specified by:
removeListener in interface PluginInterface

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 PluginInterface

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable