|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.globus.wsrf.impl.ReflectionResource
org.globus.wsrf.impl.PersistentReflectionResource
A persistent specialization of
ReflectionResource. It persists itself by
serializing the resource implementation JavaBean used in constructing an
object as a 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.
This class can be very useful for rapid prototyping of persistent resources.
In addition, it is possible to refine the persistence model by overriding
the load() and store() methods.
Usage:
getResourceBeanClass.ReflectionResource:
ResourceHomeImpl
and follow its set of usage rules.initialize.
ResourceHomeImpl), and then whenever
adequate (for instance when a resource property value, or a set thereof,
is modified). Remember to set the dirty flag to true first.
(see setDirty)
Refining the persistence model:
The default persistence model implemented by this class may be sufficient in most simple cases, but refining it may sometimes make sense, for instance in cases where:
performance.
Dirty flag:
A dirty flag is set to true every time a resource property of the Schema-defined resource property set is set to a new value. This enables to optimize storing so the resource is not actually persisted each time it is passivated by ResourceHomeImpl. (note: maybe this is overkill and not necessary?)
ReflectionResource,
ResourceHomeImpl,
PersistenceCallback,
RemoveCallback| Field Summary | |
private boolean |
dirty
The dirty flag is set to true at instanciation time, so that the initial creator of the resource just needs to call store
in order to actually persist the new resource for the first time. |
private static org.globus.util.I18n |
i18n
|
private static org.apache.commons.logging.Log |
logger
|
private XmlPersistenceHelper |
persistenceHelper
|
| Fields inherited from class org.globus.wsrf.impl.ReflectionResource |
|
| Constructor Summary | |
PersistentReflectionResource()
|
|
| Method Summary | |
protected ResourceProperty |
createNewResourceProperty(javax.xml.namespace.QName rpQName,
java.lang.Object resourceBean)
Warning: this is not a callback (but maybe it should be). |
boolean |
getDirty()
|
protected java.io.File |
getKeyAsFile(java.lang.Object key)
Create a file object based on the key supplied in parameter. |
protected XmlPersistenceHelper |
getPersistenceHelper()
|
protected abstract java.lang.Class |
getResourceBeanClass()
|
protected java.io.File |
getStorageDirectory()
|
java.util.List |
getStoredResourceKeyValues()
This function returns the keys of the resources that have been stored. |
void |
load(ResourceKey key)
Called by ResourceHomeImpl when activating a resource. |
void |
remove()
Notifies that the resource was removed. |
void |
setDirty(boolean changed)
Sets the dirty flag on this persistent object. |
void |
store()
Store the resource into an XML document (current implementation). |
| Methods inherited from class org.globus.wsrf.impl.ReflectionResource |
createNewResourceProperty, getCurrentTime, getID, getResourceBean, getResourcePropertySet, getTerminationTime, initialize, setTerminationTime |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static org.globus.util.I18n i18n
private static org.apache.commons.logging.Log logger
private boolean dirty
store
in order to actually persist the new resource for the first time.
private XmlPersistenceHelper persistenceHelper
| Constructor Detail |
public PersistentReflectionResource()
| Method Detail |
protected XmlPersistenceHelper getPersistenceHelper()
protected abstract java.lang.Class getResourceBeanClass()
ReflectionResource
public void load(ResourceKey key)
throws ResourceException
If the resource was successfully loaded, its dirty flag is set to false.
Postcondition getDirty() == false
load in interface PersistenceCallbackResourceException - if the load operation fails for any other
reason.setDirty(),
PersistenceCallback
public void store()
throws ResourceException
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?)
If the resource was successfully stored, its dirty flag is set to false.
Postcondition getDirty() == false
store in interface PersistenceCallbackResourceException - if the resource could not be storedsetDirty(),
getKeyAsFile(),
PersistenceCallbackprotected java.io.File getKeyAsFile(java.lang.Object key)
file name :== (class name)_(key scalar value).xml
where:
key - Object the key of the resource
protected java.io.File getStorageDirectory()
public void remove()
throws ResourceException
RemoveCallbackResourceHome.remove() is
allowed to call that method during the remove operation.
remove in interface RemoveCallbackResourceException - if the remove operation fails.RemoveCallback
protected ResourceProperty createNewResourceProperty(javax.xml.namespace.QName rpQName,
java.lang.Object resourceBean)
throws java.lang.Exception
ReflectionResource
createNewResourceProperty in class ReflectionResourcerpQName - QNameresourceBean - Object
java.lang.Exceptionpublic void setDirty(boolean changed)
setDirty in interface DirtyFlagHolderchanged - boolean To flag the resource as changed i.e. "dirty" and
have it persisted by the next invocation of storepublic boolean getDirty()
getDirty in interface DirtyFlagHolder
public java.util.List getStoredResourceKeyValues()
throws java.io.IOException
java.io.IOException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||