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

Variable Index

 o _log
Where we write our log messages
 o TYPE
For use by other classes when referring to the single type served by this provider.

Constructor Index

 o TemplateProvider()

Method Index

 o destroy()
We don't really have anything to do on shutdown
 o get(String)
Find the specified template in the directory managed by this template store.
 o getPath()
Get the search path used by this template provider
 o getTypes()
Supports the "template" type
 o init(ResourceBroker)
Create a new TemplateProvider that uses the specified directory as the source for Template objects that it will return
 o resourceCreate(CreateResourceEvent)
Unsupported.
 o resourceDelete(ResourceEvent)
Unsupported.
 o resourceExpireTime()
Let cache expire after 10 minutes
 o resourceRequest(RequestResourceEvent)
Grab a template based on its name, setting the request event to contain it if we found it.
 o resourceSave(ResourceEvent)
Unsupported.
 o resourceThreads()
Allow a worker thread to process this class concurrently
 o toString()
Print out the name of this TemplateProvider, including its directory

Variables

 o TYPE
 public static final String TYPE
For use by other classes when referring to the single type served by this provider.

 o _log
 public static final Log _log
Where we write our log messages

Constructors

 o TemplateProvider
 public TemplateProvider()

Methods

 o 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
 o getTypes
 public final String[] getTypes()
Supports the "template" type

 o resourceExpireTime
 public final int resourceExpireTime()
Let cache expire after 10 minutes

 o resourceThreads
 public final int resourceThreads()
Allow a worker thread to process this class concurrently

 o 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
 o resourceCreate
 public final void resourceCreate(CreateResourceEvent evt)
Unsupported. Does nothing.

 o resourceSave
 public final boolean resourceSave(ResourceEvent save)
Unsupported. Does nothing.

 o resourceDelete
 public final boolean resourceDelete(ResourceEvent evt)
Unsupported. Does nothing.

Returns:
false
 o destroy
 public final void destroy()
We don't really have anything to do on shutdown

 o 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
 o toString
 public final String toString()
Print out the name of this TemplateProvider, including its directory

Overrides:
toString in class Object
 o getPath
 public final String getPath()
Get the search path used by this template provider


All Packages  Class Hierarchy  This Package  Previous  Next  Index