Class ConfigurableResourceManager
- java.lang.Object
-
- com.atlassian.confluence.util.velocity.ConfigurableResourceManager
-
- All Implemented Interfaces:
org.apache.velocity.runtime.resource.ResourceManager
@Deprecated(forRemoval=true) public class ConfigurableResourceManager extends Object implements org.apache.velocity.runtime.resource.ResourceManager
Deprecated, for removal: This API element is subject to removal in a future version.since 8.4 replaced byConfigurableResourceManager
Class to manage the text resource for the Velocity Runtime.
This is a copy of the Velocity 1.5
ResourceManagerImpl
with the following changes for Confluence:- added post processing template method for more flexible loader configuration
- a non-synchronized
getResource(java.lang.String, int, java.lang.String)
method -
getLoaderNameForResource(String)
is more useful. It returns the ID of the loader rather than the class name
Ideally we would replace the entire implementation, making use of a richer resource loader interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
ConfigurableResourceManager.ResourceFactory
Deprecated, for removal: This API element is subject to removal in a future version.Factory methods for Velocity resource objects
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.velocity.runtime.resource.ResourceCache
globalCache
Deprecated, for removal: This API element is subject to removal in a future version.Object implementing ResourceCache to be our resource manager's Resource cache.protected org.apache.velocity.runtime.log.Log
log
Deprecated, for removal: This API element is subject to removal in a future version.Logging.static int
RESOURCE_CONTENT
Deprecated, for removal: This API element is subject to removal in a future version.A static content resource.static int
RESOURCE_TEMPLATE
Deprecated, for removal: This API element is subject to removal in a future version.A template resources.protected List<org.apache.velocity.runtime.resource.loader.ResourceLoader>
resourceLoaders
Deprecated, for removal: This API element is subject to removal in a future version.The List of templateLoaders that the Runtime will use to locate the InputStream source of a template.protected org.apache.velocity.runtime.RuntimeServices
rsvc
Deprecated, for removal: This API element is subject to removal in a future version.The internal RuntimeServices object.
-
Constructor Summary
Constructors Constructor Description ConfigurableResourceManager()
Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getLoaderNameForResource(String resourceName)
Deprecated, for removal: This API element is subject to removal in a future version.Determines if a template exists, and returns name of the loader that provides it.org.apache.velocity.runtime.resource.Resource
getResource(String resourceName, int resourceType, String encoding)
Deprecated, for removal: This API element is subject to removal in a future version.Gets the named resource.protected ConfigurableResourceManager.ResourceFactory
getResourceFactory()
Deprecated, for removal: This API element is subject to removal in a future version.Template method for provisioning aConfigurableResourceManager.ResourceFactory
.void
initialize(org.apache.velocity.runtime.RuntimeServices rsvc)
Deprecated, for removal: This API element is subject to removal in a future version.Initialize the ResourceManager.protected org.apache.velocity.runtime.resource.Resource
loadResource(String resourceName, int resourceType, String encoding)
Deprecated, for removal: This API element is subject to removal in a future version.Loads a resource from the current set of resource loaders.protected org.apache.velocity.runtime.resource.loader.ResourceLoader
postProcessLoader(org.apache.velocity.runtime.resource.loader.ResourceLoader loader, org.apache.commons.collections.ExtendedProperties properties)
Deprecated, for removal: This API element is subject to removal in a future version.Template method to allow subclasses to post process and possibly wrap a resource loader before it is added to the loader list.protected void
refreshResource(org.apache.velocity.runtime.resource.Resource resource, String encoding)
Deprecated, for removal: This API element is subject to removal in a future version.Takes an existing resource, and 'refreshes' it.
-
-
-
Field Detail
-
RESOURCE_TEMPLATE
public static final int RESOURCE_TEMPLATE
Deprecated, for removal: This API element is subject to removal in a future version.A template resources.- See Also:
- Constant Field Values
-
RESOURCE_CONTENT
public static final int RESOURCE_CONTENT
Deprecated, for removal: This API element is subject to removal in a future version.A static content resource.- See Also:
- Constant Field Values
-
globalCache
protected org.apache.velocity.runtime.resource.ResourceCache globalCache
Deprecated, for removal: This API element is subject to removal in a future version.Object implementing ResourceCache to be our resource manager's Resource cache.
-
resourceLoaders
protected final List<org.apache.velocity.runtime.resource.loader.ResourceLoader> resourceLoaders
Deprecated, for removal: This API element is subject to removal in a future version.The List of templateLoaders that the Runtime will use to locate the InputStream source of a template.
-
rsvc
protected org.apache.velocity.runtime.RuntimeServices rsvc
Deprecated, for removal: This API element is subject to removal in a future version.The internal RuntimeServices object.
-
log
protected org.apache.velocity.runtime.log.Log log
Deprecated, for removal: This API element is subject to removal in a future version.Logging.
-
-
Method Detail
-
initialize
public void initialize(org.apache.velocity.runtime.RuntimeServices rsvc) throws Exception
Deprecated, for removal: This API element is subject to removal in a future version.Initialize the ResourceManager.- Specified by:
initialize
in interfaceorg.apache.velocity.runtime.resource.ResourceManager
- Parameters:
rsvc
- The Runtime Services object which is associated with this Resource Manager.- Throws:
Exception
-
getResource
public org.apache.velocity.runtime.resource.Resource getResource(String resourceName, int resourceType, String encoding) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, Exception
Deprecated, for removal: This API element is subject to removal in a future version.Gets the named resource. Returned class type corresponds to specified type (i.e.Template
toRESOURCE_TEMPLATE
).The original version of this class logs and rethrows virtually any exception thrown. This logging has been removed since these exceptions are often expected.
- Specified by:
getResource
in interfaceorg.apache.velocity.runtime.resource.ResourceManager
- Parameters:
resourceName
- The name of the resource to retrieve.resourceType
- The type of resource (RESOURCE_TEMPLATE
,RESOURCE_CONTENT
, etc.).encoding
- The character encoding to use.- Returns:
- Resource with the template parsed and ready.
- Throws:
org.apache.velocity.exception.ResourceNotFoundException
- if template not found from any available source.org.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.Exception
- if a problem in parse
-
loadResource
protected org.apache.velocity.runtime.resource.Resource loadResource(String resourceName, int resourceType, String encoding) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, Exception
Deprecated, for removal: This API element is subject to removal in a future version.Loads a resource from the current set of resource loaders.- Parameters:
resourceName
- The name of the resource to retrieve.resourceType
- The type of resource (RESOURCE_TEMPLATE
,RESOURCE_CONTENT
, etc.).encoding
- The character encoding to use.- Returns:
- Resource with the template parsed and ready.
- Throws:
org.apache.velocity.exception.ResourceNotFoundException
- if template not found from any available source.org.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.Exception
- if a problem in parse
-
refreshResource
protected void refreshResource(org.apache.velocity.runtime.resource.Resource resource, String encoding) throws org.apache.velocity.exception.ResourceNotFoundException, org.apache.velocity.exception.ParseErrorException, Exception
Deprecated, for removal: This API element is subject to removal in a future version.Takes an existing resource, and 'refreshes' it. This generally means that the source of the resource is checked for changes according to some cache/check algorithm and if the resource changed, then the resource data is reloaded and re-parsed.- Parameters:
resource
- resource to refreshencoding
- character encoding of the resource to refresh.- Throws:
org.apache.velocity.exception.ResourceNotFoundException
- if template not found from current source for this Resourceorg.apache.velocity.exception.ParseErrorException
- if template cannot be parsed due to syntax (or other) error.Exception
- if a problem in parse
-
getLoaderNameForResource
public String getLoaderNameForResource(String resourceName)
Deprecated, for removal: This API element is subject to removal in a future version.Determines if a template exists, and returns name of the loader that provides it. This is a slightly less hokey way to support the Velocity.templateExists() utility method, which was broken when per-template encoding was introduced. We can revisit this.- Specified by:
getLoaderNameForResource
in interfaceorg.apache.velocity.runtime.resource.ResourceManager
- Parameters:
resourceName
- Name of template or content resource- Returns:
- name of loader than can provide it
-
postProcessLoader
protected org.apache.velocity.runtime.resource.loader.ResourceLoader postProcessLoader(org.apache.velocity.runtime.resource.loader.ResourceLoader loader, org.apache.commons.collections.ExtendedProperties properties)
Deprecated, for removal: This API element is subject to removal in a future version.Template method to allow subclasses to post process and possibly wrap a resource loader before it is added to the loader list. This implementation does nothing.- Parameters:
loader
- Resource loader to processproperties
- Configured properties for the resource loader- Returns:
- final resource loader instance to be used at runtime. Must not be null.
-
getResourceFactory
protected ConfigurableResourceManager.ResourceFactory getResourceFactory()
Deprecated, for removal: This API element is subject to removal in a future version.Template method for provisioning a
ConfigurableResourceManager.ResourceFactory
. Subclasses may customise this factory where necessary.This implementation returns a strategy that delegates to the default Velocity resource factory methods.
- Returns:
- resource factory to use for this resource manager
- See Also:
ConfigurableResourceManager.DefaultResourceFactory
-
-