org.gcube.common.core.state
Class GCUBEWSResource

java.lang.Object
  extended by org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl
      extended by org.gcube.common.core.state.GCUBEStatefulResource<GCUBEWSResourceKey>
          extended by org.gcube.common.core.state.GCUBEWSResource
All Implemented Interfaces:
GCUBEServiceClient, org.globus.wsrf.PersistenceCallback, org.globus.wsrf.Resource, org.globus.wsrf.ResourceLifetime, org.globus.wsrf.ResourceProperties, org.globus.wsrf.TopicListAccessor
Direct Known Subclasses:
GCUBEWSFieldsSerializableResource, GCUBEWSLiteResource

public abstract class GCUBEWSResource
extends GCUBEStatefulResource<GCUBEWSResourceKey>
implements org.globus.wsrf.PersistenceCallback, org.globus.wsrf.ResourceLifetime, org.globus.wsrf.ResourceProperties, org.globus.wsrf.TopicListAccessor

An abstract specialisation of GCUBEStatefulResource for stateful entities that are accessible to remote clients through the interface of a service port-type.

In particular, a WS-Resource:

-) has a public identifier comprised of its local identifier and the endpoint of the associated port-type.
-) exposes (part of) its state to remote client as multi-valued Resource Properties (RPs). These public properties are collected in a GCUBEWSResourcePropertySet and documented in the interface definition of the associated port-type.
-) notifies clients of events about one or more topics, particularly the change of RP values.
-) may have a finite lifetime though its lifetime may be dynamically extended.

Author:
Fabio Simeoni (University of Strathclyde)

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.common.core.state.GCUBEStatefulResource
GCUBEStatefulResource.LOCK, GCUBEStatefulResource.TaskContext
 
Field Summary
 
Fields inherited from class org.gcube.common.core.state.GCUBEStatefulResource
logger, uuidGen
 
Constructor Summary
GCUBEWSResource()
           
 
Method Summary
 Calendar getCurrentTime()
          Returns the current time.
 org.apache.axis.message.addressing.EndpointReferenceType getEPR()
          Returns the endpoint of the resource.
 GCUBEStatefulPortTypeContext getPorttypeContext()
          Returns the context of the port-type associated with the resource.
protected  org.globus.wsrf.ResourceProperty getProperty(String name)
          Returns a new RP with a given local name.
protected  String[] getPropertyNames()
          Returns the names of the RPs of the resource (none by default).
protected  ISPublisher getPublisher()
          Returns the ISPublisher used for resource publication.
 GCUBEWSResourcePropertySet getResourcePropertySet()
          Returns the RP set of the resource.
 GCUBEServiceContext getServiceContext()
          Returns the context of the service associated with the resource.
 Calendar getTerminationTime()
          Returns the termination time of the resource.
 GCUBETopicList getTopicList()
          Returns the topic list of the resource.
protected  String[] getTopicNames()
          Returns the names of the topics of the resource (none by default).
protected  void initialise(GCUBEWSResourceKey id, Object... params)
          Used internally to initialise the resource with a given identifier and from given parameters.
protected abstract  void initialise(Object... params)
          Initialises the resource.
protected  void initialiseContainers()
          Initialises the internal data structures of the resource.
 boolean inScope(GCUBEScope... scopes)
          Indicates whether the resource is in one or more given scopes.
 void load(org.globus.wsrf.ResourceKey key)
          Deprecated.  
 void publish(GCUBEScope... scopes)
          Publishes the resource in one or more scopes.
 void setPortTypeContext(GCUBEStatefulPortTypeContext context)
          Invoked by the GCUBEResourceHome of the resource to set the associated port-type.
 void setTerminationTime(Calendar calendar)
          Sets the termination time of resource.
 void unpublish(GCUBEScope... scopes)
          Unpublish the resource from one o more scopes.
 
Methods inherited from class org.gcube.common.core.state.GCUBEStatefulResource
getID, getLock, getScheduledTasks, getScope, launchTask, onRemove, setID, setPersistenceDelegate, stopTask, store
 
Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEServiceClientImpl
getPortTypeMap, setPortTypeMap
 
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.PersistenceCallback
store
 

Constructor Detail

GCUBEWSResource

public GCUBEWSResource()
Method Detail

initialiseContainers

protected void initialiseContainers()
                             throws Exception
Initialises the internal data structures of the resource.

If overridden, it should be invoked to add RPs and topics.

Throws:
org.globus.wsrf.ResourceException - if the structures could not be initialised.
Exception

initialise

protected void initialise(GCUBEWSResourceKey id,
                          Object... params)
                   throws Exception
Used internally to initialise the resource with a given identifier and from given parameters.

Specified by:
initialise in class GCUBEStatefulResource<GCUBEWSResourceKey>
Parameters:
id - the identifier, or null if a new one should be generated.
params - (optional) the initialisation parameters.
Throws:
Exception - if the resource could not be initialised.

initialise

protected abstract void initialise(Object... params)
                            throws Exception
Initialises the resource.

Implement by casting to specific parameter types (if any are expected) and performing initialisation in accordance with resource semantics.

Parameters:
params - (optional) the initialisation parameters.
Throws:
Exception - if the resource could not be initialised.

getResourcePropertySet

public GCUBEWSResourcePropertySet getResourcePropertySet()
Returns the RP set of the resource.

Specified by:
getResourcePropertySet in interface org.globus.wsrf.ResourceProperties
Returns:
the property set.

getTopicList

public GCUBETopicList getTopicList()
Returns the topic list of the resource.

Specified by:
getTopicList in interface org.globus.wsrf.TopicListAccessor
Returns:
the topic list.

getEPR

public org.apache.axis.message.addressing.EndpointReferenceType getEPR()
                                                                throws Exception
Returns the endpoint of the resource.

Returns:
the endpoint.
Throws:
Exception - if the endpoint could not be derived.

getCurrentTime

public Calendar getCurrentTime()
Returns the current time.

Specified by:
getCurrentTime in interface org.globus.wsrf.ResourceLifetime
Returns:
the time.

getTerminationTime

public Calendar getTerminationTime()
Returns the termination time of the resource.

Specified by:
getTerminationTime in interface org.globus.wsrf.ResourceLifetime
Returns:
the termination time.

setTerminationTime

public void setTerminationTime(Calendar calendar)
Sets the termination time of resource.

Specified by:
setTerminationTime in interface org.globus.wsrf.ResourceLifetime
Parameters:
calendar - the termination time.

publish

public void publish(GCUBEScope... scopes)
             throws org.globus.wsrf.ResourceException
Publishes the resource in one or more scopes.

Parameters:
scopes - the scopes.
Throws:
org.globus.wsrf.ResourceException

unpublish

public void unpublish(GCUBEScope... scopes)
               throws org.globus.wsrf.ResourceException
Unpublish the resource from one o more scopes.

Parameters:
scopes - the scopes.
Throws:
org.globus.wsrf.ResourceException

getPorttypeContext

public GCUBEStatefulPortTypeContext getPorttypeContext()
Returns the context of the port-type associated with the resource.

Returns:
the context

setPortTypeContext

public void setPortTypeContext(GCUBEStatefulPortTypeContext context)
Invoked by the GCUBEResourceHome of the resource to set the associated port-type.

Parameters:
context - the context.

getServiceContext

public GCUBEServiceContext getServiceContext()
Returns the context of the service associated with the resource.

Specified by:
getServiceContext in class GCUBEStatefulResource<GCUBEWSResourceKey>
Returns:
the context.

getPropertyNames

protected String[] getPropertyNames()
Returns the names of the RPs of the resource (none by default).

Returns:
the names.

getTopicNames

protected String[] getTopicNames()
Returns the names of the topics of the resource (none by default).

Returns:
the topic names.

getProperty

protected org.globus.wsrf.ResourceProperty getProperty(String name)
                                                throws Exception
Returns a new RP with a given local name. By default it creates SimpleResourceProperty. Override to use different ResourceProperty implementation.

Parameters:
name - the local name.
Returns:
the property.
Throws:
Exception - if the property could not be created.

load

public void load(org.globus.wsrf.ResourceKey key)
          throws org.globus.wsrf.ResourceException,
                 org.globus.wsrf.NoSuchResourceException,
                 org.globus.wsrf.InvalidResourceKeyException
Deprecated. 

Legacy operation.

Specified by:
load in interface org.globus.wsrf.PersistenceCallback
Throws:
org.globus.wsrf.ResourceException
org.globus.wsrf.NoSuchResourceException
org.globus.wsrf.InvalidResourceKeyException

inScope

public boolean inScope(GCUBEScope... scopes)
Indicates whether the resource is in one or more given scopes.

Parameters:
scopes - the scopes.
Returns:
true if the resource is in all the input scopes, false otherwise.

getPublisher

protected ISPublisher getPublisher()
                            throws Exception
Returns the ISPublisher used for resource publication.

Returns:
the publisher, which is an implementation of ISAsyncPublisher by default.
Throws:
Exception - if the publisher could not be returned.


Copyright © 2013. All Rights Reserved.