public class ResourceManagerImpl extends java.lang.Object implements ResourceManager
Modifier and Type | Field and Description |
---|---|
protected ResourceCache |
globalCache
Object implementing ResourceCache to be our resource manager's Resource cache.
|
private boolean |
isInit
Has this Manager been initialized?
|
protected org.slf4j.Logger |
log
Logging.
|
private boolean |
logWhenFound
switch to turn off log notice when a resource is found for the first time.
|
static int |
RESOURCE_CONTENT
A static content resource.
|
static int |
RESOURCE_TEMPLATE
A template resources.
|
protected java.util.List<ResourceLoader> |
resourceLoaders
The List of templateLoaders that the Runtime will use to locate the InputStream source of a template.
|
protected RuntimeServices |
rsvc
The internal RuntimeServices object.
|
private java.util.List<ExtProperties> |
sourceInitializerList
This is a list of the template input stream source initializers, basically properties for a particular template stream
source.
|
Constructor and Description |
---|
ResourceManagerImpl() |
Modifier and Type | Method and Description |
---|---|
private void |
assembleResourceLoaderInitializers()
This will produce a List of Hashtables, each hashtable contains the initialization info for a particular resource loader.
|
protected Resource |
createResource(java.lang.String resourceName,
int resourceType)
Create a new Resource of the specified type.
|
private ResourceLoader |
getLoaderForResource(java.lang.String resourceName)
Returns the first
ResourceLoader in which the specified
resource exists. |
java.lang.String |
getLoaderNameForResource(java.lang.String resourceName)
Determines if a template exists, and returns name of the loader that provides it.
|
Resource |
getResource(java.lang.String resourceName,
int resourceType,
java.lang.String encoding)
Gets the named resource.
|
void |
initialize(RuntimeServices rs)
Initialize the ResourceManager.
|
protected Resource |
loadResource(java.lang.String resourceName,
int resourceType,
java.lang.String encoding)
Loads a resource from the current set of resource loaders.
|
protected Resource |
refreshResource(Resource resource,
java.lang.String encoding)
Takes an existing resource, and 'refreshes' it.
|
public static final int RESOURCE_TEMPLATE
public static final int RESOURCE_CONTENT
protected ResourceCache globalCache
protected final java.util.List<ResourceLoader> resourceLoaders
private final java.util.List<ExtProperties> sourceInitializerList
resource.loader.<loader-id>.<property> = <value>
private boolean isInit
private boolean logWhenFound
protected RuntimeServices rsvc
protected org.slf4j.Logger log
public void initialize(RuntimeServices rs)
initialize
in interface ResourceManager
rs
- The Runtime Services object which is associated with this Resource Manager.private void assembleResourceLoaderInitializers()
public Resource getResource(java.lang.String resourceName, int resourceType, java.lang.String encoding) throws ResourceNotFoundException, ParseErrorException
Template
to
RESOURCE_TEMPLATE
).
This method is now unsynchronized which requires that ResourceCache
implementations be thread safe (as the default is).getResource
in interface ResourceManager
resourceName
- The name of the resource to retrieve.resourceType
- The type of resource (RESOURCE_TEMPLATE
, RESOURCE_CONTENT
, etc.).encoding
- The character encoding to use.ResourceNotFoundException
- if template not found from any available source.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.protected Resource createResource(java.lang.String resourceName, int resourceType)
resourceName
- The name of the resource to retrieve.resourceType
- The type of resource (RESOURCE_TEMPLATE
, RESOURCE_CONTENT
, etc.).protected Resource loadResource(java.lang.String resourceName, int resourceType, java.lang.String encoding) throws ResourceNotFoundException, ParseErrorException
resourceName
- The name of the resource to retrieve.resourceType
- The type of resource (RESOURCE_TEMPLATE
, RESOURCE_CONTENT
, etc.).encoding
- The character encoding to use.ResourceNotFoundException
- if template not found from any available source.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.protected Resource refreshResource(Resource resource, java.lang.String encoding) throws ResourceNotFoundException, ParseErrorException
resource
- resource to refreshencoding
- character encoding of the resource to refresh.ResourceNotFoundException
- if template not found from current source for this ResourceParseErrorException
- if template cannot be parsed due to syntax (or other) error.public java.lang.String getLoaderNameForResource(java.lang.String resourceName)
getLoaderNameForResource
in interface ResourceManager
resourceName
- Name of template or content resourceprivate ResourceLoader getLoaderForResource(java.lang.String resourceName)
ResourceLoader
in which the specified
resource exists.