jrunx.persistence
Class AbstractFilePersistenceStore

java.lang.Object
  |
  +--jrunx.persistence.AbstractFilePersistenceStore
All Implemented Interfaces:
PersistenceStore
Direct Known Subclasses:
CachedFilePersistenceStore, FilePersistenceStore

public abstract class AbstractFilePersistenceStore
extends java.lang.Object
implements PersistenceStore

Abstract implementation of a file-based persistent store. It provides subclasses with common functionality used to manipulate the file store resource.

Author:
Enrique Duvos

Field Summary
protected  boolean cleanOnExit
           
static java.util.Map keySelectors
           
protected  FileStoreManager storeManager
           
 
Constructor Summary
AbstractFilePersistenceStore()
           
 
Method Summary
 void clean()
          Removes all objects from the persistence store.
static void cleanDirectory(java.io.File dir)
           
 java.lang.Object create(java.lang.Object key, PersistentObject object)
          Inserts a new instance into the persistence store.
static void deleteFile(java.io.File file)
           
 void destroy()
          Called by the PersistenceStore owner to let the PersistenceStore know that it should clean itself up.
 java.util.Collection findBy(java.lang.String method, java.lang.Object args)
          Finds wether the specified key is stored.
protected  java.util.Collection findBy(java.lang.String method, java.lang.Object args, java.util.Collection keys)
          Finds wether the specified key is stored.
 java.lang.Object findByPrimaryKey(java.lang.Object key)
          Finds wether the specified key is stored.
protected  KeySelector getKeySelector(java.lang.String name, java.lang.Object[] args)
           
 java.util.Map getKeySelectors()
           
 void init()
          Called by the PersistenceStore owner to let the PersistenceStore know that it should initialize itself.
 void load(java.lang.Object key, PersistentObject object)
          Retrieves the instance from the persistence store.
 void remove(java.lang.Object key)
          Remove the instance from the persistence store.
 void setCleanOnExit(boolean cleanOnExit)
          Marks wether the FileStore should be cleaned or not upon VM termination
 void setKeySelectors(java.util.Map keySelectors)
           
 void setResource(java.lang.Object resource)
          Sets the internal resource used by the store to persist objects
 void setStoreManager(StoreManager manager)
          Sets the internal StoreManager used by the store to persist objects
 void store(java.lang.Object key, PersistentObject object)
          Inserts the instance into the persistence store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cleanOnExit

protected boolean cleanOnExit

storeManager

protected FileStoreManager storeManager

keySelectors

public static java.util.Map keySelectors
Constructor Detail

AbstractFilePersistenceStore

public AbstractFilePersistenceStore()
Method Detail

init

public void init()
          throws java.lang.Exception
Description copied from interface: PersistenceStore
Called by the PersistenceStore owner to let the PersistenceStore know that it should initialize itself.
Specified by:
init in interface PersistenceStore

destroy

public void destroy()
             throws java.lang.Exception
Description copied from interface: PersistenceStore
Called by the PersistenceStore owner to let the PersistenceStore know that it should clean itself up.
Specified by:
destroy in interface PersistenceStore

create

public java.lang.Object create(java.lang.Object key,
                               PersistentObject object)
                        throws java.lang.Exception
Inserts a new instance into the persistence store. On File-based persistence stores, this is method has the same effect as the method store( key , object ).
Specified by:
create in interface PersistenceStore
Parameters:
key - the key associated with the bean.
object - the object to be stored.
Returns:
The key if created by the persistence store

store

public void store(java.lang.Object key,
                  PersistentObject object)
           throws java.lang.Exception
Inserts the instance into the persistence store.
Specified by:
store in interface PersistenceStore
Parameters:
key - the key associated with the bean.
object - the object to be stored.

load

public void load(java.lang.Object key,
                 PersistentObject object)
          throws java.lang.Exception
Retrieves the instance from the persistence store.
Specified by:
load in interface PersistenceStore
Parameters:
key - the key associated with the bean.
object - the PersistentObject used to load the object.

remove

public void remove(java.lang.Object key)
            throws java.lang.Exception
Remove the instance from the persistence store.
Specified by:
remove in interface PersistenceStore
Parameters:
key - the key associated with object.

findByPrimaryKey

public java.lang.Object findByPrimaryKey(java.lang.Object key)
                                  throws java.lang.Exception
Finds wether the specified key is stored.
Specified by:
findByPrimaryKey in interface PersistenceStore
Parameters:
key - the key associated with the bean. Returns null if not found

findBy

public java.util.Collection findBy(java.lang.String method,
                                   java.lang.Object args)
                            throws java.lang.Exception
Finds wether the specified key is stored.
Specified by:
findBy in interface PersistenceStore
Parameters:
args - the set of arguments used to find the objects.
Returns:
The enumeration of keys

findBy

protected java.util.Collection findBy(java.lang.String method,
                                      java.lang.Object args,
                                      java.util.Collection keys)
                               throws java.lang.Exception
Finds wether the specified key is stored.
Parameters:
args - the set of arguments used to find the objects.
keys - the set of keys to add to the list of keys to be searched.
Returns:
The enumeration of keys

setResource

public void setResource(java.lang.Object resource)
Sets the internal resource used by the store to persist objects
Specified by:
setResource in interface PersistenceStore
Parameters:
resource - the resource to be utilized by the store

setStoreManager

public void setStoreManager(StoreManager manager)
Sets the internal StoreManager used by the store to persist objects
Specified by:
setStoreManager in interface PersistenceStore
Parameters:
manager - the manager to be utilized by the store

setCleanOnExit

public void setCleanOnExit(boolean cleanOnExit)
Marks wether the FileStore should be cleaned or not upon VM termination

clean

public void clean()
           throws java.lang.Exception
Removes all objects from the persistence store. This will likely be a JMX API
Specified by:
clean in interface PersistenceStore

cleanDirectory

public static void cleanDirectory(java.io.File dir)

deleteFile

public static void deleteFile(java.io.File file)

getKeySelectors

public java.util.Map getKeySelectors()

setKeySelectors

public void setKeySelectors(java.util.Map keySelectors)

getKeySelector

protected KeySelector getKeySelector(java.lang.String name,
                                     java.lang.Object[] args)


Copyright © 2002 Macromedia Corporation. All Rights Reserved.