eu.larkc.plugin
Class Plugin

java.lang.Object
  extended by eu.larkc.plugin.Plugin
All Implemented Interfaces:
javax.jms.MessageListener

public abstract class Plugin
extends java.lang.Object
implements javax.jms.MessageListener

Plugin class. It have implemented the URI and identifier methods. All the plug-ins have to extend this. All the plug-ins should be instantiated using constructor with URI parameter, or using PluginRegistry. Otherwise getIdentifier will be null. The work of the plug-in is done by the invokeInternal() method. This class also provides caching functionality. The default behavior is to use caching based on the entire input. If only parts of the input need to be taken into consideration, the getKey() method should be overridden. If caching is to be disabled, the cacheInsert() and cacheLookup() methods are to be overridden.

Author:
Luka Bradesko

Constructor Summary
Plugin(org.openrdf.model.URI _pluginName)
          Constructs and gives the name to the plug-in.
 
Method Summary
 void createPubSubConnection()
          Creates the connection to the broker.
 java.lang.String getBrokerUrl()
          Returns the URL of the broker.
 org.openrdf.model.URI getIdentifier()
          Returns the URI of the plug-in.
 int getMergeBehavior()
          Getter.
 SetOfStatements getPluginParameters()
          Getter.
 java.lang.String[] getTopics()
          Returns the topics that the plugin is subscribed to.
 void initialise(SetOfStatements workflowDescription, java.lang.String brokerUrl, java.lang.String[] topics)
          Called by the platform so that the plug-in can do any extra one-time initialisation after construction, but before invocation.
 SetOfStatements invoke(SetOfStatements input)
          Called by the plug-in manager.
abstract  void onMessage(javax.jms.Message message)
          Called by the Plugin if it subscribed to some topic and received some messages.
 void setBrokerUrl(java.lang.String brokerUrl)
          Sets the URL of the broker.
 void setMergeBehavior(int mergeBehavior)
          Setter.
 void setTopics(java.lang.String[] topics)
          Sets the topics that this plugin subscribes or publishes to.
 void shutdown()
          Called by the plug-in manager.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plugin

public Plugin(org.openrdf.model.URI _pluginName)
Constructs and gives the name to the plug-in.

Parameters:
_pluginName -
Method Detail

getMergeBehavior

public int getMergeBehavior()
Getter. Retrieves the mergeBehavior.

Returns:
the mergeBehavior

setMergeBehavior

public void setMergeBehavior(int mergeBehavior)
Setter. Sets or updates the mergeBehavior to the passed value.

Parameters:
mergeBehavior - the mergeBehavior to set

initialise

public final void initialise(SetOfStatements workflowDescription,
                             java.lang.String brokerUrl,
                             java.lang.String[] topics)
Called by the platform so that the plug-in can do any extra one-time initialisation after construction, but before invocation.

Parameters:
workflowDescription - The workflow description
brokerUrl - the URL of the message broker
topics - topics of the message broker

setBrokerUrl

public void setBrokerUrl(java.lang.String brokerUrl)
Sets the URL of the broker.

Parameters:
brokerUrl - The URL of the broker.

getBrokerUrl

public java.lang.String getBrokerUrl()
Returns the URL of the broker.

Returns:
The URL of the broker.

setTopics

public void setTopics(java.lang.String[] topics)
Sets the topics that this plugin subscribes or publishes to.

Parameters:
topics -

getTopics

public java.lang.String[] getTopics()
Returns the topics that the plugin is subscribed to.

Returns:
topics

createPubSubConnection

public void createPubSubConnection()
                            throws javax.jms.JMSException
Creates the connection to the broker.

Throws:
javax.jms.JMSException

onMessage

public abstract void onMessage(javax.jms.Message message)
Called by the Plugin if it subscribed to some topic and received some messages.

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
message - The message received

shutdown

public void shutdown()
Called by the plug-in manager. Will take care of shut down the plugin and calls shutdownInternal.


getIdentifier

public org.openrdf.model.URI getIdentifier()
Returns the URI of the plug-in.

Returns:
plug-in name URI

invoke

public final SetOfStatements invoke(SetOfStatements input)
Called by the plug-in manager. Will take care of caching and delegate to invokeInternal

Parameters:
input -
Returns:
Returns the output

getPluginParameters

public SetOfStatements getPluginParameters()
Getter. Retrieves the pluginParameters.

Returns:
the pluginParameters