RESOURCE - the resource type.RESOURCEID - the type of the resource identifier.public abstract class GCUBEPersistenceDelegate<RESOURCEID,RESOURCE extends GCUBEStatefulResource<RESOURCEID>> extends Object
GCUBStatefulResources.
A persistence delegate is responsible for the deserialisation and serialisation of resources
of a given type from and to some form of long-term storage, as well as for the removal of resource
serialisations. It is intended to work in strict collaboration with the
associated GCUBEStatefulResources and their GCUBEResourceHome, and clients
should not interface it directly. In particular:
-) the initialisation of the delegate is triggered by resource homes as part of their own initialisation;
-) the deserialisation of resource serialisations is triggered by resource homes at the point of resource access, transparently to their clients;
-) the removal of resource serialisations is triggered by resource homes, in response to explicit requests from their clients (cf. GCUBEResourceHome.remove(Object));
-) the serialisation of resources is triggered by resources themselves, in response to explicit requests from their clients (cf. GCUBEStatefulResource.store());
| Modifier and Type | Field and Description |
|---|---|
protected GCUBELog |
logger
Instance logger.
|
| Constructor and Description |
|---|
GCUBEPersistenceDelegate() |
| Modifier and Type | Method and Description |
|---|---|
abstract Collection<RESOURCEID> |
getResourceIdentifiers()
Returns the identifiers of all the resources serialised by the delegate.
|
void |
initialise(GCUBEResourceHome<? super RESOURCEID,RESOURCEID,RESOURCE> home)
Initialises the delegate from the
GCUBEResourceHome of the associated resources. |
void |
load(RESOURCE resource,
boolean firstLoad)
Deserialises the state of an uninitialised resource.
|
protected abstract void |
onLoad(RESOURCE resource,
boolean firstLoad)
Invoked by
load(GCUBEStatefulResource, boolean) to deserialise a resource. |
protected abstract void |
onRemove(RESOURCE resource)
Invoked by
remove(GCUBEStatefulResource) to remove the serialisation of a resource. |
protected abstract void |
onStore(RESOURCE resource)
Invoked by
store(GCUBEStatefulResource) to serialise a resource. |
void |
remove(RESOURCE resource)
Removes the serialisation of a resource.
|
void |
store(RESOURCE resource)
Serialises the state of a resource.
|
protected final GCUBELog logger
public void initialise(GCUBEResourceHome<? super RESOURCEID,RESOURCEID,RESOURCE> home) throws Exception
GCUBEResourceHome of the associated resources.home - the home.Exception - if the delegate could not be initialised.public void load(RESOURCE resource, boolean firstLoad) throws Exception
firstLoad - true if the resource has not been previously loaded since the container last booted, false otherwise.resource - the resource.Exception - if the resource could not be deserialised.public void store(RESOURCE resource)
resource - the resource.public void remove(RESOURCE resource)
resource - the resource.protected abstract void onLoad(RESOURCE resource, boolean firstLoad) throws Exception
load(GCUBEStatefulResource, boolean) to deserialise a resource.
Implement in accordance with resource and serialisation semantics.firstLoad - true if the resource has not been previously loaded since the container last booted, false otherwise.Exception - if the resource could not be deserialised.load(GCUBEStatefulResource, boolean)protected abstract void onStore(RESOURCE resource) throws Exception
store(GCUBEStatefulResource) to serialise a resource.
Implement in accordance with serialisation and resource semantics.Exception - if the resource could not be serialised.store(GCUBEStatefulResource)protected abstract void onRemove(RESOURCE resource) throws Exception
remove(GCUBEStatefulResource) to remove the serialisation of a resource.
Implement in accordance with serialisation and resource semantics.Exception - if the resource serialisation could not be removed.remove(GCUBEStatefulResource)public abstract Collection<RESOURCEID> getResourceIdentifiers()
Copyright © 2015. All Rights Reserved.