de.fzj.unicore.wsrflite.impl
Class WSRFInstanceImpl

java.lang.Object
  extended by de.fzj.unicore.wsrflite.impl.WSRFInstanceImpl
All Implemented Interfaces:
WSRFInstance
Direct Known Subclasses:
WSResourceImpl

public abstract class WSRFInstanceImpl
extends Object
implements WSRFInstance

Base implementation of the WSRFInstance lifecycle interface
Persistence is handled using annotations: persistent fields are marked with the Persist annotation.

Author:
schuller

Field Summary
protected  Home home
           
static String INIT_INITIAL_TERMINATION_TIME
          an initialisation parameter that may be used to set the initial termination time on a resource, expected to be a java.util.Calendar
static String INIT_UNIQUE_ID
          an initialisation parameter that may be used to set the unique id on a resource, expected to be a String
protected  boolean isDirty
           
 
Constructor Summary
WSRFInstanceImpl()
          default constructor
further initialisation is done through initialise() or activate()
 
Method Summary
 void activate(Map<String,Serializable> state)
          Called when the instance is reloaded into memory from persistent storage
This nay occur quite often, so users of this class should try not to perform expensive operations in this method.
 void clearChangeFlag()
          clear the "dirty" flag, called by the container after the resource has been persisted
 void clearSecurityContext()
           
 void destroy()
          perform resource-specific cleanup.
protected  int getDefaultLifetime()
          return the default lifetime of a ws-resource in seconds
 Map<String,Object> getSecurityContext()
           
 String getServiceName()
          return the service name
 Calendar getTerminationTime()
          get the termination time (expiry date) for the instance.
 String getUniqueID()
          get the unique ID of this WSRF instance
 boolean hasChanged()
          return true if the wsresource has changed
 void initialise(String serviceName, Map<String,Object> initobjs)
          called when the resource is first created and initialised by the hosting environment
 boolean isDestroyed()
          has the resource been destroyed?
 boolean isExpired()
          check expiry.
 Map<String,Serializable> passivate()
          called when the instance is persisted
 void postActivate()
          post-activation hook
this is called when the instance is reloaded into memory, after activate() has been called and the access control check has been passed
 void processMessages(PullPoint messageIterator)
          Called when messages are available for this WSRF instance which should be processed.
 void setDirty()
          set the "dirty" flag, so the state of this instance will be written to permanent storage
 void setHome(Home home)
          set the home
 void setSecurityContext(Map<String,Object> ctx)
           
 void setServiceName(String serviceName)
          set the service name
 void setTerminationTime(Calendar newTT)
           
 void setUniqueID(String uniqueID)
          set the unique ID of this WSRF instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

home

protected transient Home home

isDirty

protected boolean isDirty

INIT_UNIQUE_ID

public static final String INIT_UNIQUE_ID
an initialisation parameter that may be used to set the unique id on a resource, expected to be a String

See Also:
Constant Field Values

INIT_INITIAL_TERMINATION_TIME

public static final String INIT_INITIAL_TERMINATION_TIME
an initialisation parameter that may be used to set the initial termination time on a resource, expected to be a java.util.Calendar

See Also:
Constant Field Values
Constructor Detail

WSRFInstanceImpl

public WSRFInstanceImpl()
default constructor
further initialisation is done through initialise() or activate()

Method Detail

setDirty

public void setDirty()
set the "dirty" flag, so the state of this instance will be written to permanent storage


clearChangeFlag

public void clearChangeFlag()
Description copied from interface: WSRFInstance
clear the "dirty" flag, called by the container after the resource has been persisted

Specified by:
clearChangeFlag in interface WSRFInstance

postActivate

public void postActivate()
Description copied from interface: WSRFInstance
post-activation hook
this is called when the instance is reloaded into memory, after activate() has been called and the access control check has been passed

Specified by:
postActivate in interface WSRFInstance

getSecurityContext

public Map<String,Object> getSecurityContext()
Specified by:
getSecurityContext in interface WSRFInstance

setSecurityContext

public void setSecurityContext(Map<String,Object> ctx)
Specified by:
setSecurityContext in interface WSRFInstance

clearSecurityContext

public void clearSecurityContext()
Specified by:
clearSecurityContext in interface WSRFInstance

getUniqueID

public String getUniqueID()
Description copied from interface: WSRFInstance
get the unique ID of this WSRF instance

Specified by:
getUniqueID in interface WSRFInstance
Returns:
the unique id

getServiceName

public String getServiceName()
Description copied from interface: WSRFInstance
return the service name

Specified by:
getServiceName in interface WSRFInstance
Returns:

setServiceName

public void setServiceName(String serviceName)
Description copied from interface: WSRFInstance
set the service name

Specified by:
setServiceName in interface WSRFInstance

isExpired

public boolean isExpired()
check expiry. If a LifetimeProperty is present, check that, otherwise return false.

Specified by:
isExpired in interface WSRFInstance
Returns:
boolean true if the resource is expired

getTerminationTime

public Calendar getTerminationTime()
Description copied from interface: WSRFInstance
get the termination time (expiry date) for the instance.
if null, the instance never expires

Specified by:
getTerminationTime in interface WSRFInstance
Returns:
Calendar

setTerminationTime

public void setTerminationTime(Calendar newTT)
                        throws UnableToSetTerminationTimeException
Throws:
UnableToSetTerminationTimeException

hasChanged

public boolean hasChanged()
return true if the wsresource has changed

Specified by:
hasChanged in interface WSRFInstance
Returns:
boolean true if the resource has changed and should be persisted

destroy

public void destroy()
perform resource-specific cleanup.

Specified by:
destroy in interface WSRFInstance

isDestroyed

public final boolean isDestroyed()
Description copied from interface: WSRFInstance
has the resource been destroyed?

Specified by:
isDestroyed in interface WSRFInstance
Returns:

setHome

public void setHome(Home home)
Description copied from interface: WSRFInstance
set the home

Specified by:
setHome in interface WSRFInstance

initialise

public void initialise(String serviceName,
                       Map<String,Object> initobjs)
                throws Exception
Description copied from interface: WSRFInstance
called when the resource is first created and initialised by the hosting environment

Specified by:
initialise in interface WSRFInstance
Parameters:
serviceName - the service name this instance belongs to
initobjs - Service specific array with initialisation objects
Throws:
Exception

getDefaultLifetime

protected int getDefaultLifetime()
return the default lifetime of a ws-resource in seconds

Returns:
lifetime (24 hours if not otherwise set in properties)
See Also:
DefaultHome.DEFAULT_LIFETIME

passivate

public Map<String,Serializable> passivate()
Description copied from interface: WSRFInstance
called when the instance is persisted

Specified by:
passivate in interface WSRFInstance
Returns:
context a map containing the state of the WS-Resource

activate

public void activate(Map<String,Serializable> state)
Description copied from interface: WSRFInstance
Called when the instance is reloaded into memory from persistent storage
This nay occur quite often, so users of this class should try not to perform expensive operations in this method.

Specified by:
activate in interface WSRFInstance
Parameters:
state - a map containing the state of the WS-Resource

setUniqueID

public void setUniqueID(String uniqueID)
Description copied from interface: WSRFInstance
set the unique ID of this WSRF instance

Specified by:
setUniqueID in interface WSRFInstance
Parameters:
uniqueID - The uniqueID to set.

processMessages

public void processMessages(PullPoint messageIterator)
Description copied from interface: WSRFInstance
Called when messages are available for this WSRF instance which should be processed.
This method will be called by the container typically at the beginning of a web service call, after the WSRF instance is properly activated and before the actual ws method is invoked.

Specified by:
processMessages in interface WSRFInstance


Copyright © 2010. All Rights Reserved.