com.googlecode.fascinator.common.transaction
Class GenericTransactionManager

java.lang.Object
  extended by com.googlecode.fascinator.common.transaction.GenericTransactionManager
All Implemented Interfaces:
Plugin, TransactionManager

public abstract class GenericTransactionManager
extends java.lang.Object
implements TransactionManager

A transaction manager will parse incoming JSON messages and inform the TransactionManagerQueueConsumer which Transformers, Subscribers, Indexing and Messaging sould occur in response.

Implementations of this Plugin are expected to execute inside the TransactionManagerQueueConsumer and should confirm to the expected message formats, as per documentation.

Author:
Greg Pendlebury

Constructor Summary
GenericTransactionManager(java.lang.String id, java.lang.String name)
          Constructor, standard for plugins
 
Method Summary
 java.lang.String getId()
          Gets an identifier for Harvester plugin
 JsonSimpleConfig getJsonConfig()
          Get config file
 java.lang.String getName()
          Get a name for Harvester plugin
 PluginDescription getPluginDetails()
          Gets a PluginDescription object relating to this plugin.
abstract  void init()
          Abstract method for Harvester plugin
 void init(java.io.File jsonFile)
          Initialises the plugin using the specified JSON configuration
 void init(java.lang.String jsonString)
          Initialises the plugin using the specified JSON String
abstract  JsonSimple parseMessage(JsonSimple message)
          This method is expected to be overwritten by implementations.
 java.lang.Object parseMessage(java.lang.Object message)
          This wrapper implements the API and enforces the practical requirement that the I/O Objects are appropriate JSON classes.
 void shutdown()
          Shuts down the plugin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericTransactionManager

public GenericTransactionManager(java.lang.String id,
                                 java.lang.String name)
Constructor, standard for plugins

Parameters:
id - Plugin Id
name - Plugin Name
Method Detail

getId

public java.lang.String getId()
Gets an identifier for Harvester plugin

Specified by:
getId in interface Plugin
Returns:
the plugin type id

getName

public java.lang.String getName()
Get a name for Harvester plugin

Specified by:
getName in interface Plugin
Returns:
the plugin name

getPluginDetails

public PluginDescription getPluginDetails()
Gets a PluginDescription object relating to this plugin.

Specified by:
getPluginDetails in interface Plugin
Returns:
a PluginDescription

init

public void init(java.io.File jsonFile)
          throws PluginException
Initialises the plugin using the specified JSON configuration

Specified by:
init in interface Plugin
Parameters:
jsonFile - JSON configuration file
Throws:
PluginException - if there was an error during initialisation

init

public void init(java.lang.String jsonString)
          throws PluginException
Initialises the plugin using the specified JSON String

Specified by:
init in interface Plugin
Parameters:
jsonFile - JSON configuration file
Throws:
PluginException - if there was an error during initialisation

init

public abstract void init()
                   throws TransactionException
Abstract method for Harvester plugin

Throws:
HarvesterException - if there was an error during initialisation
TransactionException

shutdown

public void shutdown()
              throws PluginException
Shuts down the plugin

Specified by:
shutdown in interface Plugin
Throws:
PluginException - if there was an error during shutdown

getJsonConfig

public JsonSimpleConfig getJsonConfig()
                               throws TransactionException
Get config file

Returns:
config file
Throws:
HarvesterException - if there was an error during retrieval
TransactionException

parseMessage

public final java.lang.Object parseMessage(java.lang.Object message)
                                    throws TransactionException

This wrapper implements the API and enforces the practical requirement that the I/O Objects are appropriate JSON classes.

Implementations should overwrite the correctly typed method.

Specified by:
parseMessage in interface TransactionManager
Parameters:
message - The message to parse, in JSON
Returns:
Object The actions to take in response, in JSON
Throws:
TransactionException - If an error occurred or the the message is in a bad format or otherwise unsuitable.

parseMessage

public abstract JsonSimple parseMessage(JsonSimple message)
                                 throws TransactionException

This method is expected to be overwritten by implementations. This is where the real processing should occur.

Parameters:
message - The JsonSimple message to process
Returns:
JsonSimple The actions to take in response
Throws:
TransactionException - If an error occurred


Copyright © 2009-2013. All Rights Reserved.