All Packages Class Hierarchy This Package Previous Next Index
Class org.webmacro.resource.TemplateProvider
java.lang.Object
|
+----org.webmacro.resource.TemplateProvider
- public final class TemplateProvider
- extends Object
- implements ResourceProvider
This is the reference implementation for the "template" ResourceProvider.
Create a TemplateProvider with a directory name and it will search for
and return templates from that directory when requested to do so.
The "template" type will automatically be used by Handler when it
attempts to resolve a template name, via the ResourceBroker. You could
install a different TemplateHandler if you wanted to load your templates
from a different location (out of a database, over the network, etc.)
It supports only the requestResource method, and does not support the
creation or deletion of templates.
- See Also:
- ResourceProvider, Handler
-
_log
- Where we write our log messages
-
TYPE
- For use by other classes when referring to the single type served
by this provider.
-
TemplateProvider()
-
-
destroy()
- We don't really have anything to do on shutdown
-
get(String)
- Find the specified template in the directory managed by this
template store.
-
getPath()
- Get the search path used by this template provider
-
getTypes()
- Supports the "template" type
-
init(ResourceBroker)
- Create a new TemplateProvider that uses the specified directory
as the source for Template objects that it will return
-
resourceCreate(CreateResourceEvent)
- Unsupported.
-
resourceDelete(ResourceEvent)
- Unsupported.
-
resourceExpireTime()
- Let cache expire after 10 minutes
-
resourceRequest(RequestResourceEvent)
- Grab a template based on its name, setting the request event to
contain it if we found it.
-
resourceSave(ResourceEvent)
- Unsupported.
-
resourceThreads()
- Allow a worker thread to process this class concurrently
-
toString()
- Print out the name of this TemplateProvider, including its directory
TYPE
public static final String TYPE
- For use by other classes when referring to the single type served
by this provider.
_log
public static final Log _log
- Where we write our log messages
TemplateProvider
public TemplateProvider()
init
public void init(ResourceBroker broker) throws InitException
- Create a new TemplateProvider that uses the specified directory
as the source for Template objects that it will return
- Throws: InitException
- provider failed to initialize
getTypes
public final String[] getTypes()
- Supports the "template" type
resourceExpireTime
public final int resourceExpireTime()
- Let cache expire after 10 minutes
resourceThreads
public final int resourceThreads()
- Allow a worker thread to process this class concurrently
resourceRequest
public final void resourceRequest(RequestResourceEvent request) throws ResourceUnavailableException, InterruptedException
- Grab a template based on its name, setting the request event to
contain it if we found it.
- Parameters:
- request - has type "template" and name equal to the template sought
- Throws: ResourceUnavailableException
- resource not found (authoritative)
- Throws: InterruptedException
- work being done is no longer wanted
resourceCreate
public final void resourceCreate(CreateResourceEvent evt)
- Unsupported. Does nothing.
resourceSave
public final boolean resourceSave(ResourceEvent save)
- Unsupported. Does nothing.
resourceDelete
public final boolean resourceDelete(ResourceEvent evt)
- Unsupported. Does nothing.
- Returns:
- false
destroy
public final void destroy()
- We don't really have anything to do on shutdown
get
public final Template get(String fileName)
- Find the specified template in the directory managed by this
template store. Any path specified in the filename is relative
to the directory managed by the template store.
- Parameters:
- fileName - relative to the current directory fo the store
- Returns:
- s a template matching that name, or null if one cannot be found
toString
public final String toString()
- Print out the name of this TemplateProvider, including its directory
- Overrides:
- toString in class Object
getPath
public final String getPath()
- Get the search path used by this template provider
All Packages Class Hierarchy This Package Previous Next Index