org.apache.turbine.services.webmacro
Class TurbineTemplateProvider

java.lang.Object
  |
  +--org.apache.turbine.services.webmacro.TurbineTemplateProvider
All Implemented Interfaces:
org.webmacro.broker.ResourceProvider

public class TurbineTemplateProvider
extends java.lang.Object
implements org.webmacro.broker.ResourceProvider

This class provides the WebMacro engine with Temlate instances.

This class was created as a replacement of org.webmacro.resource.TemplateProvider that relies on the properties of WebMacroService for locating the templates.

Version:
$Id$
Author:
Rafal Krzewski, Daniel Rall

Field Summary
private  org.webmacro.Broker broker
          Resource broker that manages this provider.
private  int cacheTime
          Expiration time of the provided resources.
private  java.lang.String[] paths
          Stored paths that are searched by this provider.
static java.lang.String TYPE
          The single resource type we provide.
private static java.lang.String[] types
          An array of supported resource types.
 
Fields inherited from interface org.webmacro.broker.ResourceProvider
INFINITE_CACHE, NEVER_CACHE
 
Constructor Summary
TurbineTemplateProvider()
           
 
Method Summary
 void destroy()
          Shuts down the provider.
private  org.webmacro.Template findTemplate(java.lang.String name)
          Locates a template file, and instantiates Template object.
 java.lang.String[] getTypes()
          Returns an array of supported resource types.
 void init(org.webmacro.broker.ResourceBroker broker)
          Initializes the provider.
 void resourceCreate(org.webmacro.broker.CreateResourceEvent create)
          Creates a new resource (not implemented).
 boolean resourceDelete(org.webmacro.broker.ResourceEvent delete)
          Deletes a resource (not implemented).
 int resourceExpireTime()
          Returns expiration time of the provided resources.
 void resourceRequest(org.webmacro.broker.RequestResourceEvent request)
          Retrieves a resource.
 boolean resourceSave(org.webmacro.broker.ResourceEvent save)
          Saves a resource to permanet storage (not implemented).
 int resourceThreads()
          Returns the number of additional worker threads to be used by the provider
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

TYPE

public static java.lang.String TYPE
The single resource type we provide.

types

private static java.lang.String[] types
An array of supported resource types.

cacheTime

private int cacheTime
Expiration time of the provided resources.

paths

private java.lang.String[] paths
Stored paths that are searched by this provider.

broker

private org.webmacro.Broker broker
Resource broker that manages this provider.
Constructor Detail

TurbineTemplateProvider

public TurbineTemplateProvider()
Method Detail

getTypes

public java.lang.String[] getTypes()
Returns an array of supported resource types.
Specified by:
getTypes in interface org.webmacro.broker.ResourceProvider
Returns:
A String[] with the supported resource types.

resourceExpireTime

public int resourceExpireTime()
Returns expiration time of the provided resources.
Specified by:
resourceExpireTime in interface org.webmacro.broker.ResourceProvider
Returns:
An int with the expiration time of the provided resources.

resourceThreads

public int resourceThreads()
Returns the number of additional worker threads to be used by the provider
Specified by:
resourceThreads in interface org.webmacro.broker.ResourceProvider
Returns:
The number of additional worker threads to be used by the provider.

init

public void init(org.webmacro.broker.ResourceBroker broker)
          throws org.webmacro.broker.ResourceInitException
Initializes the provider.
Specified by:
init in interface org.webmacro.broker.ResourceProvider
Parameters:
broker - The ResourceBroker that manages this provider.
Throws:
org.webmacro.broker.ResourceInitException - The resource couldn't be initialized.

destroy

public void destroy()
Shuts down the provider.
Specified by:
destroy in interface org.webmacro.broker.ResourceProvider

resourceRequest

public void resourceRequest(org.webmacro.broker.RequestResourceEvent request)
                     throws org.webmacro.NotFoundException,
                            java.lang.InterruptedException
Retrieves a resource.
Specified by:
resourceRequest in interface org.webmacro.broker.ResourceProvider
Parameters:
request - A RequestResourceEvent.
Throws:
NotFoundException. -  
InterruptedException. -  

resourceCreate

public void resourceCreate(org.webmacro.broker.CreateResourceEvent create)
                    throws org.webmacro.NotFoundException,
                           java.lang.InterruptedException
Creates a new resource (not implemented).
Specified by:
resourceCreate in interface org.webmacro.broker.ResourceProvider
Parameters:
create - A CreateResourceEvent.
Throws:
NotFoundException. -  
InterruptedException. -  

resourceDelete

public boolean resourceDelete(org.webmacro.broker.ResourceEvent delete)
Deletes a resource (not implemented).
Specified by:
resourceDelete in interface org.webmacro.broker.ResourceProvider
Parameters:
delete - A ResourceEvent.
Returns:
Always false.

resourceSave

public boolean resourceSave(org.webmacro.broker.ResourceEvent save)
Saves a resource to permanet storage (not implemented).
Specified by:
resourceSave in interface org.webmacro.broker.ResourceProvider
Parameters:
save - A ResourceEvent.
Returns:
Always false.

findTemplate

private org.webmacro.Template findTemplate(java.lang.String name)
Locates a template file, and instantiates Template object.
Parameters:
name - the name of the template to be located
Returns:
Instantiated Template object.


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.