Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.makumba.commons
Class NamedResourceFactory

    java.lang.Object
      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:

- the `NamedResources` keeps objects in a hashtable. If the key for that hashtable corresponding to a certain name is not the name itself, the `getHashObject(name)` method should be redefined.
- if the process of constructing the resource needs the hash key, the `makeResource(name, hashName)` method should be redefined, instead of `makeResource(name)`
- if the process of constructing the resource needs other resources, that in turn might need the resource which is just built, these resources should not be retreived in the makeResource() methods, since that would cause infinite loops. makeResource() should just build the resource, and `configureResource(name, hashName, resource)` should be redefined to do further resource adjustments.

Version:
  $Id: NamedResourceFactory.java 3499 2008-12-30 22:44:41Z 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Docs generated on 2009-02-25 14:20