org.makumba.commons
Class NamedResourceFactory

java.lang.Object
  extended by org.makumba.commons.NamedResourceFactory
All Implemented Interfaces:
Serializable

public abstract class NamedResourceFactory
extends Object
implements Serializable

This models a factory for named resources. Normally a subclass should just implement makeResource(name), which is called whenever the NamedResources is requested an object that it doesn't hold. Still, there are some special cases:

Version:
$Id: NamedResourceFactory.java 5125 2010-05-18 17:57:27Z rosso_nero $
Author:
Cristian Bogdan
See Also:
Serialized Form

Field Summary
protected  Object supplementary
           
 
Constructor Summary
NamedResourceFactory()
           
 
Method Summary
protected  void configureResource(Object name, Object hashName, Object resource)
          This method is called immediately after the resource is built, but before making it accessible to other threads, and before the resource being returned to the client that requested it.
protected  Object getHashObject(Object name)
          This method builds the hash object from the name of the object.
protected  Object makeResource(Object name)
          This method should make the resource with the given name.
protected  Object makeResource(Object name, Object hashName)
          If the hash object for the resource is different from the name, this is the method used to build the named resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supplementary

protected Object supplementary
Constructor Detail

NamedResourceFactory

public NamedResourceFactory()
Method Detail

makeResource

protected Object makeResource(Object name)
                       throws Throwable
This method should make the resource with the given name. All exceptions thrown here will be caught and thrown further as RuntimeWrappedExceptions. This method should not lead to the request of the same resource from the NamedResources (by for example requesting another resource that needs to refer this resource). Such actions should be performed in configureResource()

Parameters:
name - the name of the resource to be made
Returns:
the newly created resource
Throws:
Throwable

makeResource

protected Object makeResource(Object name,
                              Object hashName)
                       throws Throwable
If the hash object for the resource is different from the name, this is the method used to build the named resource. All exceptions throws here will be caught and thrown further as RuntimeWrappedExceptions. This method should not lead to the request of the same resource from the NamedResources (by e.g. requesting another resource that needs to refer this resource). Such actions should be performed in configureResource()

Parameters:
name - name of the resource to be made
hashName - name of the hash for the object
Returns:
the newly created resource
Throws:
Throwable

getHashObject

protected Object getHashObject(Object name)
                        throws Throwable
This method builds the hash object from the name of the object. By default, it returns the name

Parameters:
name - the name of the object
Returns:
The hash object
Throws:
Throwable

configureResource

protected void configureResource(Object name,
                                 Object hashName,
                                 Object resource)
                          throws Throwable
This method is called immediately after the resource is built, but before making it accessible to other threads, and before the resource being returned to the client that requested it.

Parameters:
name - the name of the object
hashName - the hash name of the object
resource - the resource
Throws:
Throwable