org.planx.xmlstore.stores
Class LocalXMLStore

java.lang.Object
  extended by org.planx.xmlstore.stores.LocalXMLStore
All Implemented Interfaces:
XMLStore<LocalLocator>

public class LocalXMLStore
extends Object
implements XMLStore<LocalLocator>

A local XMLStore that only operates on location dependent References, that is, LocalLocators. Thus, it is fast but unable to resolve ValueReferences. In order to do this, wrap the LocalXMLStore in a TranslatorXMLStore.

A LocalXMLStore will run a Sharer in the background that compacts redundant on-disk data and performs garbage collection.

Author:
Thomas Ambus

Constructor Summary
LocalXMLStore(String name)
          Creates a new LocalXMLStore with the specified on-disk name.
LocalXMLStore(String name, StorageConfiguration conf)
          Creates a new LocalXMLStore with the specified on-disk name.
 
Method Summary
 void addReferenceListener(LocatorListener listener)
          Adds the specified LocatorListener for receiving Reference events.
 void close()
          The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth.
 StorageManager getManager()
           
 NameServer<LocalLocator> getNameServer()
          Returns a NameServer for this store.
 SystemNode load(LocalLocator ref)
          Only accepts LocalLocators.
 void release(LocalLocator ref)
          Informs the XMLStore that the data referenced by the specified Reference is no longer needed.
 void removeReferenceListener(LocatorListener listener)
          Removes the specified LocatorListener previously added with addReferenceListener.
 void retain(LocalLocator ref)
          Informs the XMLStore that the data referenced by the specified Reference should be kept permanently.
 LocalLocator save(Node node)
          Saves the specified Node and returns a LocalLocator to it.
 long size()
          Returns the disk size of this LocalXMLStore.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalXMLStore

public LocalXMLStore(String name)
              throws IOException
Creates a new LocalXMLStore with the specified on-disk name.

Parameters:
name - the on-disk file name to use as base for persistent data
Throws:
IOException - if an error occurred initializing the XMLStore using the specified name

LocalXMLStore

public LocalXMLStore(String name,
                     StorageConfiguration conf)
              throws IOException
Creates a new LocalXMLStore with the specified on-disk name.

Parameters:
name - the on-disk file name to use as base for persistent data
Throws:
IOException - if an error occurred initializing the XMLStore using the specified name
Method Detail

save

public LocalLocator save(Node node)
                  throws IOException
Saves the specified Node and returns a LocalLocator to it.

Specified by:
save in interface XMLStore<LocalLocator>
Parameters:
node - representing XML data in the form of semi-structured tree data
Returns:
a reference to the saved node/tree
Throws:
IOException - if an error occurs during disk, network, etc access

load

public SystemNode load(LocalLocator ref)
                throws IOException
Only accepts LocalLocators.

Specified by:
load in interface XMLStore<LocalLocator>
Parameters:
ref - the Reference to the data
Returns:
node representing the loaded XML data
Throws:
IOException - if an error occurs during disk, network, etc access
UnknownReferenceException - if the data referenced is not stored in the XMLStore or the Reference is of a type not supported by the XMLStore

getNameServer

public NameServer<LocalLocator> getNameServer()
Returns a NameServer for this store.

Specified by:
getNameServer in interface XMLStore<LocalLocator>

getManager

public StorageManager getManager()

retain

public void retain(LocalLocator ref)
            throws UnknownReferenceException
Informs the XMLStore that the data referenced by the specified Reference should be kept permanently. Implementations may assume that the Reference is one previously obtained from this XMLStore. When the data referenced is no longer needed the XMLStore should be informed of this be calling release(LocalLocator).

Parameters:
ref - the Reference to retain
Throws:
UnknownReferenceException

release

public void release(LocalLocator ref)
             throws UnknownReferenceException
Informs the XMLStore that the data referenced by the specified Reference is no longer needed. The XMLStore should previously have been informed to retain the data using the retain(LocalLocator) method. More specifically, implementations may assume that the argument of this method, or one equal to it, has previously been an argument to retain.

Parameters:
ref - the Reference to release
Throws:
UnknownReferenceException

addReferenceListener

public void addReferenceListener(LocatorListener listener)
Adds the specified LocatorListener for receiving Reference events.

Parameters:
listener - the listener to add

removeReferenceListener

public void removeReferenceListener(LocatorListener listener)
Removes the specified LocatorListener previously added with addReferenceListener.

Parameters:
listener - the listener to remove

size

public long size()
          throws IOException
Returns the disk size of this LocalXMLStore.

Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: XMLStore
The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth. Once close has been issued on an XMLStore, the store is no longer available for handling requests. Any subsequent request to the store will result in an exception being thrown. An XMLStore implementation has to ensure that this happens.

Specified by:
close in interface XMLStore<LocalLocator>
Throws:
IOException - if it is not possible to properly close the store

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2005 Plan-X. All Rights Reserved.