de.fzj.unicore.wsrflite.impl
Class DefaultHome

java.lang.Object
  extended by de.fzj.unicore.wsrflite.impl.DefaultHome
All Implemented Interfaces:
Home
Direct Known Subclasses:
WSResourceHomeImpl

public abstract class DefaultHome
extends Object
implements Home

This is a basic implementation of the Home interface. It is responsible for managing WS-Resources of a single service.
Furthermore it starts a thread that periodically checks for expired resources.
Note: the actual WS-Resource to be used is selected either
a) from the query part of the WS-Addressing To: field
b) from reference parameters given in the SOAP header.
To use the second method, make sure to override the getReferenceParameterQNames() method, and return the QNames of the XML element you want to use as reference parameter.

Author:
schuller

Field Summary
static String DEFAULT_LIFETIME
          property name for configuring the default lifetime (in seconds) set to an integer value (seconds)
static String EXPIRYCHECK_INITIAL
          property name for configuring the initial delay for ws-resource expiry checking set to an integer value (seconds)
static String EXPIRYCHECK_PERIOD
          property name for configuring the repeat period for ws-resource expiry checking set to an integer value (seconds)
protected  InstanceChecker expiryChecker
           
protected  InstanceChecking instanceChecking
          this takes care of removing expired WS-Resources etc.
protected static org.apache.log4j.Logger logger
           
static String MAXIMUM_LIFETIME
          property name for configuring the maximum lifetime (in seconds) set to an integer value (seconds)
protected  Store serviceInstances
           
protected  String serviceName
           
protected  boolean supportsNotification
           
protected static Map<String,Calendar> terminationTimes
           
 
Constructor Summary
DefaultHome()
           
 
Method Summary
 void activateHome(String serviceName)
          activate the service using the given name
Called when the container brings up the service
 String createWSRFServiceInstance(Map<String,Object> initObjs)
          create a new WS-Resource and persist it
 void destroyWSRFServiceInstance(String resourceId)
          delete and cleanup the administrative information about a WS-Resource (NOTE: this will not call WSRFInstance.destroy() (NOTE 2: locks will be cleaned as well}
protected abstract  WSRFInstance doCreateInstance()
          You must override this in subclasses to actually create the instance.
protected  WSRFInstance doCreateInstance(Map<String,Object> initObjs)
          You may override in subclasses to create the instance.
 String extractServiceReference(org.codehaus.xfire.MessageContext context)
          retrieve the unique service instance id from the message context This can be as a query parameter in the wsa:To, or as a ReferenceParameter, or (as fallback) as a query parameter in the HTTP transport URL
 WSRFInstance get(String id)
          Get a wsrf instance for read access (i.e. without aquiring a lock)
 WSRFInstance getForUpdate(String id)
          Get a wsrf instance for update (i.e. aquire a lock)
 long getNumberOfInstances()
          retrieve the current number of alive instances
protected  List<QName> getReferenceParameterQNames()
          if you want to use referenceParameters for selecting resources, return a list of accepted qnames here
 String getServiceName()
          get the service name controlled by this Home
 Store getStore()
          get the Store instance, if lower level access to the persistence layer is required
 Calendar getTerminationTime(String uniqueID)
          Get the termination time of an WS-Resource
protected  WSNProvider getWSNProvider()
          get a messaging provider for sending WS-N messages (only relevant if this service supports WS-N)
protected  void initExpiryCheck()
          setup the expiry check this implementation can be customised by setting two parameters:
 boolean isShuttingDown()
          check whether the service is currently shutting down
 void passivateHome()
          called when the container shuts down
 void persist(WSRFInstance instance)
          persist the given instance
 void runExpiryCheckNow()
           
 void setServiceName(String serviceName)
           
 void setStore(Store serviceInstances)
           
 void setTerminationTime(String uniqueID, Calendar c)
          Set the termination time of an WS-Resource
 void stopExpiryCheckNow()
          Stops expiry checks for undeployed Web Services.
protected  void storeNewInstance(WSRFInstance newInstance)
          store the new instance
 boolean supportsNotification()
          does this service support notification (i.e.
protected  void updateTT()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.fzj.unicore.wsrflite.Home
getFaultConverter
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

serviceInstances

protected Store serviceInstances

serviceName

protected String serviceName

terminationTimes

protected static Map<String,Calendar> terminationTimes

EXPIRYCHECK_INITIAL

public static final String EXPIRYCHECK_INITIAL
property name for configuring the initial delay for ws-resource expiry checking set to an integer value (seconds)

See Also:
Constant Field Values

EXPIRYCHECK_PERIOD

public static final String EXPIRYCHECK_PERIOD
property name for configuring the repeat period for ws-resource expiry checking set to an integer value (seconds)

See Also:
Constant Field Values

DEFAULT_LIFETIME

public static final String DEFAULT_LIFETIME
property name for configuring the default lifetime (in seconds) set to an integer value (seconds)

See Also:
Constant Field Values

MAXIMUM_LIFETIME

public static final String MAXIMUM_LIFETIME
property name for configuring the maximum lifetime (in seconds) set to an integer value (seconds)

See Also:
Constant Field Values

instanceChecking

protected InstanceChecking instanceChecking
this takes care of removing expired WS-Resources etc.


expiryChecker

protected InstanceChecker expiryChecker

supportsNotification

protected boolean supportsNotification
Constructor Detail

DefaultHome

public DefaultHome()
Method Detail

activateHome

public void activateHome(String serviceName)
                  throws Exception
Description copied from interface: Home
activate the service using the given name
Called when the container brings up the service

Specified by:
activateHome in interface Home
Throws:
Exception

getWSNProvider

protected WSNProvider getWSNProvider()
get a messaging provider for sending WS-N messages (only relevant if this service supports WS-N)


initExpiryCheck

protected void initExpiryCheck()
setup the expiry check this implementation can be customised by setting two parameters:

See Also:
EXPIRYCHECK_INITIAL, EXPIRYCHECK_PERIOD

runExpiryCheckNow

public void runExpiryCheckNow()

stopExpiryCheckNow

public void stopExpiryCheckNow()
Stops expiry checks for undeployed Web Services.

Specified by:
stopExpiryCheckNow in interface Home
See Also:
de.fzj.unicore.wsrflite.utils.deployment.DeploymentCenter.unregisterService(String serviceName)

passivateHome

public void passivateHome()
called when the container shuts down

Specified by:
passivateHome in interface Home

getServiceName

public String getServiceName()
Description copied from interface: Home
get the service name controlled by this Home

Specified by:
getServiceName in interface Home
Returns:

setServiceName

public void setServiceName(String serviceName)

get

public WSRFInstance get(String id)
                 throws ResourceUnknownException
Description copied from interface: Home
Get a wsrf instance for read access (i.e. without aquiring a lock)

Specified by:
get in interface Home
Parameters:
id - the ID of the resource
Throws:
ResourceUnknownException - if no such resource exists

getForUpdate

public WSRFInstance getForUpdate(String id)
                          throws ResourceUnknownException,
                                 ResourceUnavailableException
Description copied from interface: Home
Get a wsrf instance for update (i.e. aquire a lock)

Specified by:
getForUpdate in interface Home
Parameters:
id - the ID of the resource
Throws:
ResourceUnknownException - if no such resource exists
ResourceUnavailableException - if the resource cannot be locked within the timeout period

createWSRFServiceInstance

public String createWSRFServiceInstance(Map<String,Object> initObjs)
                                 throws ResourceNotCreatedException
Description copied from interface: Home
create a new WS-Resource and persist it

Specified by:
createWSRFServiceInstance in interface Home
Returns:
String the unique id of the new instance
Throws:
ResourceNotCreatedException

persist

public void persist(WSRFInstance instance)
Description copied from interface: Home
persist the given instance

Specified by:
persist in interface Home

getTerminationTime

public Calendar getTerminationTime(String uniqueID)
Description copied from interface: Home
Get the termination time of an WS-Resource

Specified by:
getTerminationTime in interface Home
Returns:
Calendar (null if instance does not expire)

updateTT

protected void updateTT()

setTerminationTime

public void setTerminationTime(String uniqueID,
                               Calendar c)
                        throws TerminationTimeChangeRejectedException,
                               UnableToSetTerminationTimeException
Description copied from interface: Home
Set the termination time of an WS-Resource

Specified by:
setTerminationTime in interface Home
Throws:
TerminationTimeChangeRejectedException
UnableToSetTerminationTimeException

doCreateInstance

protected abstract WSRFInstance doCreateInstance()
You must override this in subclasses to actually create the instance. In case you need to access the init parameters, override the doCreateInstance(Map) method


doCreateInstance

protected WSRFInstance doCreateInstance(Map<String,Object> initObjs)
You may override in subclasses to create the instance. The default implementation simply delegates to doCreateInstance()

Parameters:
initObjs - initialisation map passed to the createWSRFServiceInstance(Map) method

storeNewInstance

protected void storeNewInstance(WSRFInstance newInstance)
store the new instance

Parameters:
newInstance -

destroyWSRFServiceInstance

public void destroyWSRFServiceInstance(String resourceId)
                                throws Exception
Description copied from interface: Home
delete and cleanup the administrative information about a WS-Resource (NOTE: this will not call WSRFInstance.destroy() (NOTE 2: locks will be cleaned as well}

Specified by:
destroyWSRFServiceInstance in interface Home
Throws:
Exception

getNumberOfInstances

public long getNumberOfInstances()
Description copied from interface: Home
retrieve the current number of alive instances

Specified by:
getNumberOfInstances in interface Home
Returns:
long

extractServiceReference

public String extractServiceReference(org.codehaus.xfire.MessageContext context)
                               throws ResourceUnknownException
retrieve the unique service instance id from the message context This can be as a query parameter in the wsa:To, or as a ReferenceParameter, or (as fallback) as a query parameter in the HTTP transport URL

Specified by:
extractServiceReference in interface Home
Parameters:
context -
Returns:
unique id
Throws:
ResourceUnknownException

getReferenceParameterQNames

protected List<QName> getReferenceParameterQNames()
if you want to use referenceParameters for selecting resources, return a list of accepted qnames here

Returns:

getStore

public Store getStore()
Description copied from interface: Home
get the Store instance, if lower level access to the persistence layer is required

Specified by:
getStore in interface Home
Returns:
Store for this service

setStore

public void setStore(Store serviceInstances)

isShuttingDown

public boolean isShuttingDown()
Description copied from interface: Home
check whether the service is currently shutting down

Specified by:
isShuttingDown in interface Home
Returns:
true if the service is currently shutting down

supportsNotification

public boolean supportsNotification()
Description copied from interface: Home
does this service support notification (i.e. WS-Notification)? If this returns true, WSRFlite will periodically wake up each service instance if necessary to check for new events

Specified by:
supportsNotification in interface Home


Copyright © 2010. All Rights Reserved.