org.apache.excalibur.store.impl
Class AbstractReadWriteStore

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.store.impl.AbstractReadWriteStore
All Implemented Interfaces:
Component, LogEnabled, Store, ThreadSafe
Direct Known Subclasses:
AbstractFilesystemStore, AbstractJispFilesystemStore

public abstract class AbstractReadWriteStore
extends AbstractLogEnabled
implements Store, ThreadSafe

This is a base implementation for stores that are synchronized by using a read/write lock.

Version:
CVS $Id: AbstractReadWriteStore.java,v 1.6 2004/03/11 21:38:47 unico Exp $
Author:
Avalon Development Team

Field Summary
protected  EDU.oswego.cs.dl.util.concurrent.ReadWriteLock lock
          The lock
 
Fields inherited from interface org.apache.excalibur.store.Store
PERSISTENT_STORE, ROLE, TRANSIENT_STORE
 
Constructor Summary
AbstractReadWriteStore()
           
 
Method Summary
 void clear()
          Clear the Store of all elements
 boolean containsKey(java.lang.Object key)
          Test if the the index file contains the given key
protected abstract  void doClear()
          Clear the Store of all data it holds
protected abstract  boolean doContainsKey(java.lang.Object key)
          Indicates if the given key is associated to a contained object.
protected abstract  void doFree()
          Try to free some used memory.
protected abstract  java.lang.Object doGet(java.lang.Object key)
          Get the object associated to the given unique key.
protected abstract  java.util.Enumeration doGetKeys()
          Returns the list of used keys as an Enumeration of Objects.
protected abstract  int doGetSize()
          Returns count of the objects in the store, or -1 if could not be obtained.
protected abstract  void doRemove(java.lang.Object key)
          Remove the object associated to the given key.
protected abstract  void doStore(java.lang.Object key, java.lang.Object value)
          Store the given object.
 void free()
          Frees some values of the data file.
 java.lang.Object get(java.lang.Object key)
          Returns a Object from the store associated with the Key Object
 Instrumentable[] getChildInstrumentables()
           
 java.lang.String getInstrumentableName()
           
 Instrument[] getInstruments()
           
 java.util.Enumeration keys()
          Returns a Enumeration of all Keys in the indexed file.
 void remove(java.lang.Object key)
          Removes a value from the data file with the given key.
 void setInstrumentableName(java.lang.String name)
           
 int size()
          Returns count of the objects in the store, or -1 if could not be obtained.
 void store(java.lang.Object key, java.lang.Object value)
          Store the given object in the indexed data file.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lock

protected EDU.oswego.cs.dl.util.concurrent.ReadWriteLock lock
The lock

Constructor Detail

AbstractReadWriteStore

public AbstractReadWriteStore()
Method Detail

get

public java.lang.Object get(java.lang.Object key)
Returns a Object from the store associated with the Key Object

Specified by:
get in interface Store
Parameters:
key - the Key object
Returns:
the Object associated with Key Object

store

public void store(java.lang.Object key,
                  java.lang.Object value)
           throws java.io.IOException
Store the given object in the indexed data file.

Specified by:
store in interface Store
Parameters:
key - the key object
value - the value object
Throws:
java.io.IOException

free

public void free()
Frees some values of the data file.

Specified by:
free in interface Store

clear

public void clear()
Clear the Store of all elements

Specified by:
clear in interface Store

remove

public void remove(java.lang.Object key)
Removes a value from the data file with the given key.

Specified by:
remove in interface Store
Parameters:
key - the key object

containsKey

public boolean containsKey(java.lang.Object key)
Test if the the index file contains the given key

Specified by:
containsKey in interface Store
Parameters:
key - the key object
Returns:
true if Key exists and false if not

keys

public java.util.Enumeration keys()
Returns a Enumeration of all Keys in the indexed file.

Specified by:
keys in interface Store
Returns:
Enumeration Object with all existing keys

size

public int size()
Description copied from interface: Store
Returns count of the objects in the store, or -1 if could not be obtained.

Specified by:
size in interface Store

setInstrumentableName

public void setInstrumentableName(java.lang.String name)

getInstrumentableName

public java.lang.String getInstrumentableName()

getInstruments

public Instrument[] getInstruments()

getChildInstrumentables

public Instrumentable[] getChildInstrumentables()

doGet

protected abstract java.lang.Object doGet(java.lang.Object key)
Get the object associated to the given unique key.


doStore

protected abstract void doStore(java.lang.Object key,
                                java.lang.Object value)
                         throws java.io.IOException
Store the given object. It is up to the caller to ensure that the key has a persistent state across different JVM executions.

Throws:
java.io.IOException

doFree

protected abstract void doFree()
Try to free some used memory. The transient store can simply remove some hold data, the persistent store can free all memory by writing the data to a persistent store etc.


doRemove

protected abstract void doRemove(java.lang.Object key)
Remove the object associated to the given key.


doClear

protected abstract void doClear()
Clear the Store of all data it holds


doContainsKey

protected abstract boolean doContainsKey(java.lang.Object key)
Indicates if the given key is associated to a contained object.


doGetKeys

protected abstract java.util.Enumeration doGetKeys()
Returns the list of used keys as an Enumeration of Objects.


doGetSize

protected abstract int doGetSize()
Returns count of the objects in the store, or -1 if could not be obtained.



Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.