|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gcube.common.core.state.GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>
org.gcube.common.core.state.GCUBEWSHome
public abstract class GCUBEWSHome
An abstract specialisation of GCUBEResourceHome to GCUBEWSResources.
It enforces scoping rules for resources and it manages their lifetime and publication in accordance with
configuration (cf. onInitialisation()). In particular:
-) resources creation must be scoped and the scope must be compatible with (that
of) the Running Instance. As a result, the resource acquires the scope and is published therein.
-) resources removal must be scoped and the scope must be compatible with (that of) the resource.
As a result, the resource loses the scope and is unpublished from it. If the resource is left unscoped,
it is physically removed (including its persistent serialisation, if any).
-) resource retrieval can be unscoped for legacy reasons. if scoped, however,
the scope must be compatible with (that of) the resource.
-) the removal of the Running Instance from a scope propagates to all the resources created in that scope.
-) persistent resources are republished in all their scopes at container startup.
-) resources lifetime is checked periodically for resources that are in memory, and at the point of
usage for those that exist only in storage. if found expired, the resource is removed from all its scopes and thus
physically removed (including its persistent serialisation, if any).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.gcube.common.core.state.GCUBEResourceHome |
|---|
GCUBEResourceHome.Mode |
| Field Summary | |
|---|---|
protected QName |
keyTypeName
The qualified name of the resource key. |
protected org.gcube.common.core.state.GCUBEWSHome.SweeperScheduler |
sweeperScheduler
The handler that controls the lifetime of WS-Resources. |
| Fields inherited from class org.gcube.common.core.state.GCUBEResourceHome |
|---|
cache, lockManager, logger, mode, persistenceDelegate, resourceClass, resourceLog |
| Constructor Summary | |
|---|---|
GCUBEWSHome()
|
|
| Method Summary | |
|---|---|
GCUBEWSResource |
create(GCUBEWSResourceKey id,
Object... params)
Returns a resource with a given identifier from a set of initialisation parameters, creating it if it does not exist. |
GCUBEWSResource |
create(Object... params)
Creates a resource from a set of initialisation parameters. |
GCUBEWSResource |
find()
Returns the resource bound to the current call. |
GCUBEWSResource |
find(org.globus.wsrf.ResourceKey id)
Returns a resource from its identifier. |
protected GCUBEWSResource |
get(org.globus.wsrf.ResourceKey id)
Returns a resource from its identifier, deserialising it from storage if it is in a persistent state. |
Class<String> |
getKeyTypeClass()
Satisfies the ResourceHome interface by returning the Class of the value wrapped by the resource identifier. |
QName |
getKeyTypeName()
Returns the qualified name of the key of the WS-Resources managed by the home. |
abstract GCUBEStatefulPortTypeContext |
getPortTypeContext()
Returns the associated GCUBEStatefulPortTypeContext. |
GCUBEServiceContext |
getServiceContext()
Returns the associated GCUBEServiceContext. |
long |
getSweeperDelay()
Returns the time between activations of the sweeper. |
protected void |
onFailure()
Invoked when the Running Instance fails. |
protected void |
onInitialisation()
Invoked during initialisation of the Running Instance to initialise the home. |
protected void |
onLoad(GCUBEWSResource resource,
boolean firstLoad)
Invoked after successfully loading a resource from storage. |
protected void |
onReady()
Invoked when the Running Instance is ready to operate. |
protected boolean |
onRemove(GCUBEWSResource resource)
Invoked as a precondition to the removal of a resource. |
protected void |
onReuse(GCUBEWSResource resource)
Invoked when a resource is reused across two or more calls to GCUBEResourceHome.create(Object, Object...) . |
protected void |
postInitialise(GCUBEWSResource resource)
Invoked during the creation of a resource and after its initialisation. |
protected void |
preInitialise(GCUBEWSResource resource)
Invoked during the creation of a resource and before its initialisation. |
void |
remove(org.globus.wsrf.ResourceKey id)
Removes a resource with a given identifier. |
protected GCUBEWSResource |
reuse(GCUBEWSResourceKey id,
Object... params)
Returns a resource with a given identifier. |
void |
setKeyName(String keyName)
Sets the qualified name of the key of the WS-Resource managed by the home. |
void |
setSweeperDelay(long delay)
Sets the time between activations of the sweeper. |
| Methods inherited from class org.gcube.common.core.state.GCUBEResourceHome |
|---|
add, createInternal, getIdentifiers, getResourceClass, getResources, initialize, newInstance, onStateChange, onUpdate, remove, setCacheTimeout, setPersistenceDelegateClass, setResourceClass |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected QName keyTypeName
protected org.gcube.common.core.state.GCUBEWSHome.SweeperScheduler sweeperScheduler
| Constructor Detail |
|---|
public GCUBEWSHome()
| Method Detail |
|---|
public void setKeyName(String keyName)
keyName - the name.public QName getKeyTypeName()
getKeyTypeName in interface org.globus.wsrf.ResourceHome{[port-type namespaces<]/em>}ResourceKey by default).public final Class<String> getKeyTypeClass()
ResourceHome interface by returning the Class of the value wrapped by the resource identifier.
getKeyTypeClass in interface org.globus.wsrf.ResourceHomepublic void setSweeperDelay(long delay)
delay - the time, in seconds.public long getSweeperDelay()
public abstract GCUBEStatefulPortTypeContext getPortTypeContext()
GCUBEStatefulPortTypeContext.
public GCUBEServiceContext getServiceContext()
GCUBEServiceContext.
getServiceContext in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>
protected void onInitialisation()
throws Exception
Most of the initialisation occurs from JNDI configuration, which must adhere to the following template (text in italics marks points of instantiations):
<resource name="[name]" type="[ the FQN of a subclass of GCUBEWSHome]">
<resourceParams>
<parameter>
<name>factory</name>
<value>org.globus.wsrf.jndi.BeanFactory</value>
</parameter>
<parameter>
<name>resourceClass</name>
<value>[FQN of a GCUBEWSResource extension]</value>
</parameter>
<parameter>
<name>persistenceDelegateClass</name>
<value>[FQN of a concrete subclass of GCUBEPersistenceDelegate]</value>
</parameter>
<parameter>
<name>keyName</name>
<value>[the serialisation of a QName]</value>
</parameter>
<parameter>
<name>sweeperDelay</name>
<value>[milliseconds]</value>
</parameter>
<parameter>
<name>cacheTimeout</name>
<value>[milliseconds, e.g. 120000]</value>
</parameter>
</resourceParams>
</resource>
where keyName, sweeperDelay and cacheTimeout are optional,
and the name of the JNDI resource and its context of occurrence are to be constrained by clients.
onInitialisation in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>Exception - if the callback did not complete successfully (causes service failure).
protected void onReady()
throws Exception
onReady in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>Exception - if the callback did not complete successfully and the service ought to fail as a result.
protected void onFailure()
throws Exception
onFailure in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>Exception - if the callback did not complete successfully and the service ought to fail as a result.
protected GCUBEWSResource get(org.globus.wsrf.ResourceKey id)
throws org.globus.wsrf.ResourceException,
org.globus.wsrf.NoSuchResourceException
It is invoked by find(id) and remove(id)
after they have acquired a reentrant lock on the resource identifier.
get in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>id - the identifier.
org.globus.wsrf.ResourceException - if the resource cannot be found.
org.globus.wsrf.NoSuchResourceExceptionGCUBEResourceHome.find(Object),
GCUBEResourceHome.remove(Object)
public GCUBEWSResource create(Object... params)
throws org.globus.wsrf.ResourceException
create in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>params - (optional) the initialisation parameters.
org.globus.wsrf.ResourceException - if the resource could neither be reused or created.GCUBEResourceHome.create(Object, Object...)
public GCUBEWSResource create(GCUBEWSResourceKey id,
Object... params)
throws org.globus.wsrf.ResourceException
create in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>id - the identifier, or null.params - (optional) the initialisation parameters.
org.globus.wsrf.ResourceException - if the resource could neither be reused or created.GCUBEResourceHome.onReuse(GCUBEStatefulResource),
GCUBEResourceHome.reuse(Object, Object...)
protected GCUBEWSResource reuse(GCUBEWSResourceKey id,
Object... params)
throws org.globus.wsrf.ResourceException
reuse in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>id - the identifier.params - (optional) the initialisation parameters.
org.globus.wsrf.ResourceException - if the resource could not be reused.
public GCUBEWSResource find()
throws org.globus.wsrf.ResourceException
org.globus.wsrf.ResourceException - if the resource could not be identified or returned.
public GCUBEWSResource find(org.globus.wsrf.ResourceKey id)
throws org.globus.wsrf.ResourceException,
org.globus.wsrf.NoSuchResourceException
find in interface org.globus.wsrf.ResourceHomefind in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>id - the identifier.
org.globus.wsrf.ResourceException - if no resource with the given identifier can be found.
org.globus.wsrf.NoSuchResourceException
public void remove(org.globus.wsrf.ResourceKey id)
throws org.globus.wsrf.ResourceException
remove in interface org.globus.wsrf.ResourceHomeremove in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>id - the identifier.
org.globus.wsrf.NoSuchResourceException - if no resource exists with the given identifier.
org.globus.wsrf.InvalidResourceKeyException - if the identifier is invalid.
org.globus.wsrf.ResourceException - if the resource exists but could not be removed.
protected void preInitialise(GCUBEWSResource resource)
throws org.globus.wsrf.ResourceException
If overriding this method, please note that the resource may not have been assigned an identifier yet.
preInitialise in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>resource - the resource.
org.globus.wsrf.ResourceException - if the resource could not be pre-initialised.
protected void postInitialise(GCUBEWSResource resource)
throws org.globus.wsrf.ResourceException
postInitialise in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>resource - the resource.
org.globus.wsrf.ResourceException - if the resource could not be post-initialised.
protected void onReuse(GCUBEWSResource resource)
throws org.globus.wsrf.ResourceException
GCUBEResourceHome.create(Object, Object...) .
onReuse in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>resource - the resource.
org.globus.wsrf.ResourceException - if the resource could not be reused.
protected void onLoad(GCUBEWSResource resource,
boolean firstLoad)
throws org.globus.wsrf.ResourceException
onLoad in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>resource - the resource.firstLoad - true if this is the first time the resource is loaded since the last container reboot.
org.globus.wsrf.ResourceException - if the resource could not loaded.
protected boolean onRemove(GCUBEWSResource resource)
throws org.globus.wsrf.ResourceException
onRemove in class GCUBEResourceHome<org.globus.wsrf.ResourceKey,GCUBEWSResourceKey,GCUBEWSResource>resource - the resource.
org.globus.wsrf.ResourceException - if the precondition could not be verified.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||