org.globus.wsrf.utils
Class FilePersistenceHelper

java.lang.Object
  extended byorg.globus.wsrf.utils.FilePersistenceHelper
Direct Known Subclasses:
XmlPersistenceHelper

public class FilePersistenceHelper
extends java.lang.Object

This helper contains common functions for managing persistent information stored as files.


Nested Class Summary
private static class FilePersistenceHelper.Filter
           
 
Field Summary
protected  java.lang.Class beanClass
           
private static java.lang.String FILE_PERSISTENCE_DIR
           
protected  java.lang.String fileSuffix
           
private static org.globus.util.I18n i18n
           
private static org.apache.commons.logging.Log logger
           
private static java.lang.String PERSISTENCE_DIR_PROPERTY
           
static java.lang.String SERVER_ID
           
protected  java.io.File storageDir
           
 
Constructor Summary
FilePersistenceHelper(java.lang.Class beanClass, java.lang.String suffix)
          Creates FilePersistenceHelper with default storage directory based on the beanClass name and specified suffix.
FilePersistenceHelper(java.lang.Class beanClass, java.lang.String storageDir, java.lang.String suffix)
          Creates FilePersistenceHelper with specific storage directory and file suffix.
 
Method Summary
 java.lang.Class getBeanClass()
           
static java.lang.String getDefaultStorageDir(java.lang.Class beanClass)
           
 java.lang.String getFileSuffix()
           
 java.io.File getKeyAsFile(java.lang.Object key)
          Create a file object based on the key supplied in parameter.
private static java.lang.String getPersistenceDirectory()
           
private static java.lang.String getServerID()
           
 java.io.File getStorageDirectory()
           
 java.util.List list()
          This function returns the keys of the objects that have been stored.
 void remove(java.lang.Object key)
           
 void removeAll()
          Removes all stored objects from file system.
protected  void setStorageDirectory(java.lang.String strDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

i18n

private static org.globus.util.I18n i18n

SERVER_ID

public static final java.lang.String SERVER_ID
See Also:
Constant Field Values

FILE_PERSISTENCE_DIR

private static final java.lang.String FILE_PERSISTENCE_DIR

PERSISTENCE_DIR_PROPERTY

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

logger

private static org.apache.commons.logging.Log logger

beanClass

protected java.lang.Class beanClass

storageDir

protected java.io.File storageDir

fileSuffix

protected java.lang.String fileSuffix
Constructor Detail

FilePersistenceHelper

public FilePersistenceHelper(java.lang.Class beanClass,
                             java.lang.String suffix)
                      throws java.io.IOException
Creates FilePersistenceHelper with default storage directory based on the beanClass name and specified suffix.


FilePersistenceHelper

public FilePersistenceHelper(java.lang.Class beanClass,
                             java.lang.String storageDir,
                             java.lang.String suffix)
                      throws java.io.IOException
Creates FilePersistenceHelper with specific storage directory and file suffix.

Method Detail

getServerID

private static java.lang.String getServerID()

getPersistenceDirectory

private static java.lang.String getPersistenceDirectory()

getDefaultStorageDir

public static java.lang.String getDefaultStorageDir(java.lang.Class beanClass)
                                             throws java.io.IOException
Throws:
java.io.IOException

setStorageDirectory

protected void setStorageDirectory(java.lang.String strDir)
                            throws java.io.IOException
Throws:
java.io.IOException

getStorageDirectory

public java.io.File getStorageDirectory()

getFileSuffix

public java.lang.String getFileSuffix()

getBeanClass

public java.lang.Class getBeanClass()

getKeyAsFile

public java.io.File getKeyAsFile(java.lang.Object key)
Create a file object based on the key supplied in parameter. The file name will follow the format:

file name :== (class name)_(key scalar value).xml

where:


remove

public void remove(java.lang.Object key)
            throws ResourceException
Throws:
ResourceException

list

public java.util.List list()
                    throws java.io.IOException
This function returns the keys of the objects that have been stored. This should be used by the home in order to recover state, by listing all the stored object keys and adding them to the map of resources. The consumer code must test for null.

Returns:
List the list of key values
Throws:
java.io.IOException

removeAll

public void removeAll()
               throws java.io.IOException
Removes all stored objects from file system.

Throws:
java.io.IOException