|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.runtime.resource.loader.ResourceLoader org.apache.velocity.runtime.resource.loader.StringResourceLoader
public class StringResourceLoader
Resource loader that works with Strings. Users should manually add
resources to the repository that is know by the factory of this package.
Below is an example configuration for this loader.
Note that 'repositoryimpl' is not mandatory;
if not provided, the factory will fall back on using the default
implementation of this package.
string.resource.loader.description = Velocity StringResource loader
string.resource.loader.class = org.apache.velocity.runtime.resource.loader..StringResourceLoader
string.resource.loader.repository.class = org.apache.velocity.runtime.resource.loader.StringResourceRepositoryImpl
Resources can be added to the repository like this:
StringResourceRepository = StringResourceLoader.getRepository();
String myTemplateName = "/somewhere/intherepo/name";
String myTemplateBody = "Hi, ${username}... this is a some template!";
vsRepository.putStringResource(myTemplateName, myTemplateBody);
After this, the templates can be retrieved as usual.
Field Summary | |
---|---|
static String |
REPOSITORY_CLASS
Key to look up the repository implementation class. |
static String |
REPOSITORY_CLASS_DEFAULT
The default implementation class. |
static String |
REPOSITORY_ENCODING
Key to look up the repository char encoding. |
static String |
REPOSITORY_ENCODING_DEFAULT
The default repository encoding. |
Fields inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
---|
className, isCachingOn, log, modificationCheckInterval, rsvc |
Constructor Summary | |
---|---|
StringResourceLoader()
|
Method Summary | |
---|---|
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source that was used to create the template. |
static StringResourceRepository |
getRepository()
Returns a reference to the Repository. |
InputStream |
getResourceStream(String name)
Get an InputStream so that the Runtime can build a template with it. |
void |
init(ExtendedProperties configuration)
Initialize the template loader with a a resources class. |
boolean |
isSourceModified(Resource resource)
Given a template, check to see if the source of InputStream has been modified. |
Methods inherited from class org.apache.velocity.runtime.resource.loader.ResourceLoader |
---|
commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REPOSITORY_CLASS
public static final String REPOSITORY_CLASS_DEFAULT
public static final String REPOSITORY_ENCODING
public static final String REPOSITORY_ENCODING_DEFAULT
Constructor Detail |
---|
public StringResourceLoader()
Method Detail |
---|
public static StringResourceRepository getRepository()
public void init(ExtendedProperties configuration)
ResourceLoader
init
in class ResourceLoader
ResourceLoader.init(org.apache.commons.collections.ExtendedProperties)
public InputStream getResourceStream(String name) throws ResourceNotFoundException
getResourceStream
in class ResourceLoader
name
- name of template to get.
ResourceNotFoundException
- Ff template not found
in the RepositoryFactory.public boolean isSourceModified(Resource resource)
ResourceLoader
isSourceModified
in class ResourceLoader
ResourceLoader.isSourceModified(org.apache.velocity.runtime.resource.Resource)
public long getLastModified(Resource resource)
ResourceLoader
getLastModified
in class ResourceLoader
ResourceLoader.getLastModified(org.apache.velocity.runtime.resource.Resource)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |