org.globus.wsrf.utils
Class XmlPersistenceHelper

java.lang.Object
  extended byorg.globus.wsrf.utils.FilePersistenceHelper
      extended byorg.globus.wsrf.utils.XmlPersistenceHelper

public class XmlPersistenceHelper
extends FilePersistenceHelper

This helper is used to persist a ReflectionResource by serializing the resource implementation JavaBean used in constructing the ReflectionResource. The result of storing the resource is an XML file that corresponds exactly to the XML Schema Resource document defined for this resource. Future versions will offer alternative modes of persistence.

Usage:

Use this helper on the model of PersistentReflectionResource

See Also:
ReflectionResource, PersistentReflectionResource, ResourceHomeImpl, PersistentResource, RemoveCallback

Nested Class Summary
 
Nested classes inherited from class org.globus.wsrf.utils.FilePersistenceHelper
 
Field Summary
private static java.lang.String FILE_SUFFIX
           
private static org.globus.util.I18n i18n
           
private static org.apache.commons.logging.Log logger
           
 
Fields inherited from class org.globus.wsrf.utils.FilePersistenceHelper
beanClass, fileSuffix, SERVER_ID, storageDir
 
Constructor Summary
XmlPersistenceHelper(java.lang.Class beanClass)
           
 
Method Summary
 java.lang.Object load(java.lang.Object key)
          Loads and returns the object of the given key from the persistent storage.
 void load(java.lang.Object key, ReflectionResource resource)
          Loads and initialize the resource.
 void remove(ReflectionResource resource)
          Removes the resource from persistent storage.
 void store(java.lang.Object key, java.lang.Object object, javax.xml.namespace.QName topElementQName)
          Stores the object of the given key to persistent storage.
 void store(ReflectionResource resource)
          Store the resource into an XML document (current implementation).
 
Methods inherited from class org.globus.wsrf.utils.FilePersistenceHelper
getBeanClass, getDefaultStorageDir, getFileSuffix, getKeyAsFile, getStorageDirectory, list, remove, removeAll, setStorageDirectory
 
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

logger

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

FILE_SUFFIX

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

XmlPersistenceHelper

public XmlPersistenceHelper(java.lang.Class beanClass)
                     throws java.io.IOException
Method Detail

load

public void load(java.lang.Object key,
                 ReflectionResource resource)
          throws ResourceException
Loads and initialize the resource.

Parameters:
key - the key of the potentially new resource
resource - the new resource to load. Its key and implementation bean are null. They will be set by a call from this method to resource.initialize().
Throws:
ResourceException
See Also:
PersistentResource

store

public void store(ReflectionResource resource)
           throws ResourceException
Store the resource into an XML document (current implementation). The name of the file is governed by getKeyAsFile(). This stores the state of the implementation JavaBean. If some resource properties have been implemented with something else (for instance getters and setters from another object) they will not be persisted with the current state. This is not a problem if their state is immutable after initial creation, as their values will be set by initialize, ReflectionResource.initialize()} which is called by this method. (TODO: persist based on each RP?)

Parameters:
resource - the resource to store the state of.
Throws:
ResourceException - if the resource could not be stored
See Also:
getKeyAsFile(), PersistentResource

remove

public void remove(ReflectionResource resource)
            throws ResourceException
Removes the resource from persistent storage.

Parameters:
resource - the resource to remove from storage.
Throws:
ResourceException - if the resource could not be removed.
See Also:
RemoveCallback

load

public java.lang.Object load(java.lang.Object key)
                      throws ResourceException
Loads and returns the object of the given key from the persistent storage.

Parameters:
key - key of object to load.
Returns:
loaded Object instance.
Throws:
ResourceException - If the object cannot be loaded from file.

store

public void store(java.lang.Object key,
                  java.lang.Object object,
                  javax.xml.namespace.QName topElementQName)
           throws ResourceException
Stores the object of the given key to persistent storage.
Note: Calls to this function must be synchronized on per key basis.

Parameters:
key - key of object.
object - object to persist.
topElementQName - the top element name of the XML object.
Throws:
ResourceException - If the object cannot be saved to a file.