|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.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:
PersistentResourceHome
and follow its set of usage rules.initialize.
PersistentResourceHome), 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 PersistentResourceHome. (note: maybe this is overkill and not necessary?)
ReflectionResource,
PersistentResourceHome,
PersistentResource,
RemoveCallback| Constructor Summary | |
PersistentReflectionResource()
|
|
| Method Summary | |
protected ResourceProperty |
createNewResourceProperty(QName rpQName,
Object resourceBean)
Override this callback method to specialize the implementation of the resource property value accessors on a per resource property basis. |
boolean |
getDirty()
|
protected File |
getKeyAsFile(Object key)
Create a file object based on the key supplied in parameter. |
protected abstract Class |
getResourceBeanClass()
|
protected File |
getStorageDirectory()
|
List |
getStoredResourceKeyValues()
This function returns the keys of the resources that have been stored. |
void |
load(ResourceKey key)
Called by PersistentResourceHome 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 |
getCurrentTime, getID, getResourceBean, getResourcePropertySet, initialize |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.globus.wsrf.ResourceIdentifier |
getID |
| Constructor Detail |
public PersistentReflectionResource()
| Method Detail |
protected abstract Class getResourceBeanClass()
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 PersistentResourcesetDirty(),
PersistentResource
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 PersistentResourceResourceException - if the resource could not be storedsetDirty(),
getKeyAsFile(),
PersistentResourceprotected File getKeyAsFile(Object key)
file name :== (class name)_(key scalar value).xml
where:
key - Object the key of the resourceprotected File getStorageDirectory()
public void remove()
throws ResourceException
RemoveCallbackResourceHome.remove() is
allowed to call that method during the remove operation.remove in interface RemoveCallbackRemoveCallback
protected ResourceProperty createNewResourceProperty(QName rpQName,
Object resourceBean)
throws Exception
ReflectionResource
The default behavior is to create a new
ReflectionResourceProperty
constructed with the QName of the resource property and the
resource implementation Bean used to construct this ReflectionResource
object.
This function handles a few special cases:
createNewResourceProperty in class ReflectionResourcerpQName - QNameresourceBean - ObjectException - public void setDirty(boolean changed)
changed - boolean To flag the resource as changed i.e. "dirty" and
have it persisted by the next invocation of storepublic boolean getDirty()
public List getStoredResourceKeyValues()
throws Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||