xmlBlaster 2.2.0 API

org.xmlBlaster.engine.persistence.filestore
Class FileDriver

java.lang.Object
  extended by org.xmlBlaster.engine.persistence.filestore.FileDriver
All Implemented Interfaces:
I_PersistenceDriver, I_Plugin

public class FileDriver
extends java.lang.Object
implements I_PersistenceDriver

A very simple, file based, persistence manager.
This driver stores messages on the hard disk, one message to one file (plus a key and a qos file).
All methods are marked final, in hope to have some performance gain (could be changed to allow a customized driver)
CAUTION: This driver is not suitable for production purposes. If you want to use this driver for more than some hundred different messages we recommend to use it with the ReiserFS.
Reiserfs is a file system using a plug-in based object oriented variant on classical balanced tree algorithms.
See ftp://ftp.suse.com:/pub/suse/i386/update/6.3/reiserfs/
and http://devlinux.com/projects/reiserfs/content_table.html for further informations.
TODO: Extend interface to support caching!
TODO: Is the File stuff thread save or do we need to add some synchronize?
Invoke (for testing only):
jaco org.xmlBlaster.engine.persistence.FileDriver


Nested Class Summary
private  class FileDriver.XmlKeyFilter
          Filter only the xy-XmlKey.xml files.
 
Field Summary
private  Global glob
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  java.lang.String path
           
private  java.lang.String XMLKEY_TOKEN
           
private  java.lang.String XMLQOS_TOKEN
           
 
Constructor Summary
FileDriver()
          Constructs the FileDriver object (reflection constructor).
 
Method Summary
 void erase(XmlKey xmlKey)
          Allows a stored message to be deleted.
 MsgUnit fetch(java.lang.String oid)
          Allows to fetch one message by oid from the persistence.
 java.util.Enumeration fetchAllOids()
          Fetches all oid's of the messages from the persistence.
 java.lang.String getName()
          gives the name of the driver

 java.lang.String getType()
          gives the type of the driver

 java.lang.String getVersion()
          gives the version of the driver

 void init(Global glob, PluginInfo pluginInfo)
          This method is called by the PluginManager (enforced by I_Plugin).
static void main(java.lang.String[] args)
          Invoke: jaco org.xmlBlaster.engine.persistence.FileDriver
 void shutdown()
          Closes the instance of the filedriver plugin

 void store(MsgUnitWrapper messageWrapper)
          Allows a message to be stored.
 void update(MsgUnitWrapper messageWrapper)
          Allows a stored message content to be updated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

glob

private Global glob

log

private static java.util.logging.Logger log

path

private java.lang.String path

XMLKEY_TOKEN

private final java.lang.String XMLKEY_TOKEN
See Also:
Constant Field Values

XMLQOS_TOKEN

private final java.lang.String XMLQOS_TOKEN
See Also:
Constant Field Values
Constructor Detail

FileDriver

public FileDriver()
           throws XmlBlasterException
Constructs the FileDriver object (reflection constructor).

Throws:
XmlBlasterException
Method Detail

init

public final void init(Global glob,
                       PluginInfo pluginInfo)
                throws XmlBlasterException
This method is called by the PluginManager (enforced by I_Plugin).

Specified by:
init in interface I_Plugin
Throws:
XmlBlasterException
See Also:
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)

shutdown

public final void shutdown()
                    throws XmlBlasterException
Closes the instance of the filedriver plugin

Specified by:
shutdown in interface I_PersistenceDriver
Specified by:
shutdown in interface I_Plugin
Throws:
XmlBlasterException - if an exception occurs. The exception is handled by the RunLevelManager depending on how the plugin has been configured with the action:

<action do='STOP' onShutdownRunlevel='2' sequence='5' onFail='resource.configuration.pluginFailed'> If onFail is defined to something, the RunLevelManager will stop.


store

public final void store(MsgUnitWrapper messageWrapper)
                 throws XmlBlasterException
Allows a message to be stored.

It only stores the xmlKey, content and qos. The other store() method is called for following messages, to store only message-content.

Specified by:
store in interface I_PersistenceDriver
Parameters:
messageWrapper - The container with all necessary message info.
Throws:
XmlBlasterException

update

public final void update(MsgUnitWrapper messageWrapper)
                  throws XmlBlasterException
Allows a stored message content to be updated.

It only stores the content, so the other store() method needs to be called first if this message is new.

Specified by:
update in interface I_PersistenceDriver
Parameters:
xmlKey - To identify the message
content - The data to store
qos - The quality of service, may contain another publisher name
Throws:
XmlBlasterException

fetch

public MsgUnit fetch(java.lang.String oid)
              throws XmlBlasterException
Allows to fetch one message by oid from the persistence.

Specified by:
fetch in interface I_PersistenceDriver
Parameters:
oid - The message oid (key oid="...")
Returns:
the MsgUnit, which is persistent.
Throws:
XmlBlasterException

fetchAllOids

public java.util.Enumeration fetchAllOids()
                                   throws XmlBlasterException
Fetches all oid's of the messages from the persistence.

It is a helper method to invoke 'fetch(String oid)'.

Specified by:
fetchAllOids in interface I_PersistenceDriver
Returns:
a Enumeration of oids of all persistent MsgUnits. The oid is a String-Type.
Throws:
XmlBlasterException

erase

public void erase(XmlKey xmlKey)
           throws XmlBlasterException
Allows a stored message to be deleted.

Specified by:
erase in interface I_PersistenceDriver
Parameters:
xmlKey - To identify the message
Throws:
XmlBlasterException

getType

public java.lang.String getType()
gives the type of the driver

Specified by:
getType in interface I_Plugin
Returns:
the type of the driver

getVersion

public java.lang.String getVersion()
gives the version of the driver

Specified by:
getVersion in interface I_Plugin
Returns:
the version of the driver

getName

public java.lang.String getName()
gives the name of the driver

Specified by:
getName in interface I_PersistenceDriver
Returns:
the name of the driver

main

public static void main(java.lang.String[] args)
Invoke: jaco org.xmlBlaster.engine.persistence.FileDriver


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.