org.apache.commons.resources.impl
Class ResourcesFactoryBase

java.lang.Object
  extended by org.apache.commons.resources.impl.ResourcesFactoryBase
All Implemented Interfaces:
Serializable, ResourcesFactory
Direct Known Subclasses:
JDBCResourcesFactory, PropertyResourcesFactory, ResourceBundleResourcesFactory, WebappResourcesFactoryBase, XMLResourcesFactory

public abstract class ResourcesFactoryBase
extends Object
implements ResourcesFactory

Convenience base class for ResourcesFactory implementations. This implementation caches the Resources instances returned by a protected createResources() method, which must be implemented by concrete subclasses.

See Also:
JDBCResourcesFactory, PropertyResourcesFactory, ResourceBundleResourcesFactory, WebappResourcesFactoryBase, WebappPropertyResourcesFactory, WebappXMLResourcesFactory, XMLResourcesFactory, Serialized Form

Constructor Summary
ResourcesFactoryBase()
           
 
Method Summary
protected abstract  Resources createResources(String name, String config)
          Create and return a new Resources instance with the specified logical name, after calling its init() method and delegating the relevant properties.
 Resources getResources(String name)
          Create (if necessary) and return a Resources instance for the specified logical name, with a default configuration.
 Resources getResources(String name, String config)
          Create (if necessary) and return a Resources instance for the specified logical name, with a configuration based on the specified configuration String.
 boolean isReturnNull()
          Return the returnNull property value that will be configured on Resources instances created by this factory.
 void release()
          Release any internal references to Resources instances that have been returned previously, after calling the destroy() method on each such instance.
 void setReturnNull(boolean returnNull)
          Set the returnNull property value that will be configured on Resources instances created by this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourcesFactoryBase

public ResourcesFactoryBase()
Method Detail

isReturnNull

public boolean isReturnNull()

Return the returnNull property value that will be configured on Resources instances created by this factory.

Specified by:
isReturnNull in interface ResourcesFactory
Returns:
'true' if null is returned for invalid key values.

setReturnNull

public void setReturnNull(boolean returnNull)

Set the returnNull property value that will be configured on Resources instances created by this factory.

Specified by:
setReturnNull in interface ResourcesFactory
Parameters:
returnNull - The new value to delegate

getResources

public Resources getResources(String name)

Create (if necessary) and return a Resources instance for the specified logical name, with a default configuration. The default implementation of this method treats the name as the configuration String as well, and calls the getResources(String,String) method.

Specified by:
getResources in interface ResourcesFactory
Parameters:
name - Logical name of the Resources instance to be returned
Returns:
The resources instance.
Throws:
ResourcesException - if a Resources instance of the specified logical name cannot be returned.

getResources

public Resources getResources(String name,
                              String config)

Create (if necessary) and return a Resources instance for the specified logical name, with a configuration based on the specified configuration String.

Specified by:
getResources in interface ResourcesFactory
Parameters:
name - Logical name of the Resources instance to be returned
config - Configuration string for this resource (meaning is dependent upon the ResourcesFactory implementation being utilized), or null for the default configuration
Returns:
The resources instance.
Throws:
ResourcesException - if a Resources instance of the specified logical name cannot be returned.

release

public void release()

Release any internal references to Resources instances that have been returned previously, after calling the destroy() method on each such instance.

Specified by:
release in interface ResourcesFactory
Throws:
ResourcesException - if a problem occurred while releasing

createResources

protected abstract Resources createResources(String name,
                                             String config)

Create and return a new Resources instance with the specified logical name, after calling its init() method and delegating the relevant properties. Concrete subclasses MUST implement this method.

Parameters:
name - Logical name of the Resources instance to create
config - Configuration string for this resource (if any)
Returns:
The new Resources instance.
Throws:
ResourcesException - if a Resources instance of the specified logical name cannot be created.


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.