org.globus.wsrf.impl
Class SingletonResourceHome

java.lang.Object
  extended byorg.globus.wsrf.impl.SingletonResourceHome
All Implemented Interfaces:
ResourceHome
Direct Known Subclasses:
ServiceResourceHome

public abstract class SingletonResourceHome
extends java.lang.Object
implements ResourceHome

A ResourceHome that always returns a single resource object.


Field Summary
private  Resource singleResource
          The resource object that we will return.
 
Constructor Summary
SingletonResourceHome()
           
 
Method Summary
 Resource find(ResourceKey key)
          Retrives a resource.
protected abstract  Resource findSingleton()
          Finds the single resource to be associated with this resource home.
 java.lang.Class getKeyTypeClass()
          The resource key type.
 javax.xml.namespace.QName getKeyTypeName()
          The name of the resource key.
 void remove(ResourceKey key)
          Always throws as an exception - not permitted to remove any key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleResource

private Resource singleResource
The resource object that we will return. Starts off null and is populated when the first find() call is made.

Constructor Detail

SingletonResourceHome

public SingletonResourceHome()
Method Detail

getKeyTypeClass

public java.lang.Class getKeyTypeClass()
Description copied from interface: ResourceHome
The resource key type. The ResourceKey used or passed to this ResourceHome must have match this type (corresponds to ResourceKey.getValue()).

Specified by:
getKeyTypeClass in interface ResourceHome
Returns:
the type of the key.

getKeyTypeName

public javax.xml.namespace.QName getKeyTypeName()
Description copied from interface: ResourceHome
The name of the resource key. The ResourceKey used or passed to this ResourceHome must have match this name (corresponds to ResourceKey.getName()).

Specified by:
getKeyTypeName in interface ResourceHome
Returns:
the name of the key.

find

public Resource find(ResourceKey key)
              throws ResourceException
Description copied from interface: ResourceHome
Retrives a resource. Note: This function must not return null. It must return the resource object or throw an exception if there is no resource with the specified key.

Specified by:
find in interface ResourceHome
Returns:
non-null resource object.
Throws:
ResourceException - if any other error occurs.

remove

public void remove(ResourceKey key)
            throws ResourceException
Always throws as an exception - not permitted to remove any key.

Specified by:
remove in interface ResourceHome
Throws:
ResourceException - if any other error occurs.

findSingleton

protected abstract Resource findSingleton()
                                   throws ResourceException
Finds the single resource to be associated with this resource home. If this operation returns null a NoSuchResourceException will be raised.
If this method returns a non-null reference, then the reference will be cached, and findSingleton will not be called again. This allows, for example, findSingleton to create a new resource object without needing to track whether it has been called previously.

Throws:
ResourceException