org.apache.turbine.services.webmacro
Class TurbineWebMacroService
java.lang.Object
|
+--org.apache.turbine.services.BaseInitable
|
+--org.apache.turbine.services.BaseService
|
+--org.apache.turbine.services.TurbineBaseService
|
+--org.apache.turbine.services.template.BaseTemplateEngineService
|
+--org.apache.turbine.services.webmacro.TurbineWebMacroService
- All Implemented Interfaces:
- Initable, Service, TemplateEngineService, WebMacroService
- public class TurbineWebMacroService
- extends BaseTemplateEngineService
- implements WebMacroService
This is a Service that can process WebMacro templates from within a
Turbine Screen. Here's an example of how you might use it from a
screen:
WebContext context = WebMacro.getContext(data);
context.put("message", "Hello from Turbine!");
String results = WebMacro.handleRequest(context,"helloWorld.wm");
data.getPage().getBody().addElement(results);
Multiple template paths are specified via the
services.TurbineWebMacroService.templates
property in the
TurbineResources.properties
file, specified as a single string
delimited by the value of the System property path.separator
(this is :
on UNIX and ;
on Windows).
Turbine does not use the default ResourceProvider
for WebMacro
ResourceEvents of type template
. Instead, Turbine uses its own
TurbineTemplateProvider
implementation.
- Version:
- $Id: TurbineWebMacroService.java,v 1.4 2002/07/11 16:53:23 mpoeschl Exp $
- Author:
- Dave Bryson, Rafal Krzewski, Daniel Rall, Jason van Zyl
Field Summary |
protected static java.lang.String |
DEFAULT_ENCODING
Deprecated. The default encoding used by the WebMacro FastWriter . |
Method Summary |
org.webmacro.servlet.WebContext |
getContext()
Deprecated. Create an empty WebContext object. |
org.webmacro.servlet.WebContext |
getContext(RunData data)
Deprecated. Create a WebContext from the RunData
object. |
org.webmacro.Template |
getTemplate(java.lang.String filename)
Deprecated. Return a template from WebMacro. |
java.lang.String |
handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename)
Deprecated. Process the request and fill in the template with the values
you set in the WebContext. |
void |
handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename,
org.webmacro.FastWriter writer)
Deprecated. Process the request and fill in the template with the values
you set in the WebContext. |
void |
handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename,
java.io.OutputStream out)
Deprecated. Process the request and fill in the template with the values
you set in the WebContext. |
void |
init(javax.servlet.ServletConfig unused)
Deprecated. Performs early initialization of this service. |
void |
shutdown()
Deprecated. Shuts down the service, including its
WebMacro engine. |
boolean |
templateExists(java.lang.String template)
Deprecated. Determine whether a given template exists. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_ENCODING
protected static final java.lang.String DEFAULT_ENCODING
- Deprecated.
- The default encoding used by the WebMacro
FastWriter
.
We should encode the ouput byte stream as UTF-16
to
achieve the fastest conversion back to Java characters, but for some
reason this does not work (bug in FastWriter?). UTF-8
seems to work and is used as a fallback option.
TurbineWebMacroService
public TurbineWebMacroService()
- Deprecated.
init
public void init(javax.servlet.ServletConfig unused)
throws InitializationException
- Deprecated.
- Performs early initialization of this service.
- Overrides:
init
in class TurbineBaseService
- Throws:
InitializationException
- Caused by any initialization error.
shutdown
public void shutdown()
- Deprecated.
- Shuts down the service, including its
WebMacro engine.
- Specified by:
shutdown
in interface Initable
- Overrides:
shutdown
in class TurbineBaseService
getContext
public org.webmacro.servlet.WebContext getContext()
- Deprecated.
- Create an empty WebContext object.
- Specified by:
getContext
in interface WebMacroService
- Returns:
- A new, empty context.
getContext
public org.webmacro.servlet.WebContext getContext(RunData data)
- Deprecated.
- Create a
WebContext
from the RunData
object. Adds a pointer to the RunData
object to
the WC so that RunData is available in the templates.
- Specified by:
getContext
in interface WebMacroService
- Parameters:
data
- The Turbine RunData object.- Returns:
- A clone of the WebContext needed by WebMacro.
handleRequest
public java.lang.String handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename)
throws TurbineException
- Deprecated.
- Process the request and fill in the template with the values
you set in the WebContext.
- Specified by:
handleRequest
in interface WebMacroService
- Parameters:
wc
- The populated context.filename
- The file name of the template.- Returns:
- The process template as a String.
- Throws:
TurbineException
- Any exception trown while processing will be
wrapped into a TurbineException and rethrown.
handleRequest
public void handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename,
java.io.OutputStream out)
throws java.lang.Exception
- Deprecated.
- Process the request and fill in the template with the values
you set in the WebContext.
- Specified by:
handleRequest
in interface WebMacroService
- Parameters:
wc
- The populated context.filename
- The file name of the template.out
- A stream to write the processed template to.- Throws:
TurbineException
- Any exception trown while processing will be
wrapped into a TurbineException and rethrown.
handleRequest
public void handleRequest(org.webmacro.servlet.WebContext wc,
java.lang.String filename,
org.webmacro.FastWriter writer)
throws java.lang.Exception
- Deprecated.
- Process the request and fill in the template with the values
you set in the WebContext.
- Specified by:
handleRequest
in interface WebMacroService
- Parameters:
wc
- The populated context.filename
- The file name of the template.writer
- A writer to write the processed template with.- Throws:
TurbineException
- Any exception trown while processing will be
wrapped into a TurbineException and rethrown.
getTemplate
public org.webmacro.Template getTemplate(java.lang.String filename)
throws org.webmacro.NotFoundException
- Deprecated.
- Return a template from WebMacro.
- Specified by:
getTemplate
in interface WebMacroService
- Parameters:
filename
- A String with the name of the template.- Returns:
- A Template.
- Throws:
org.webmacro.NotFoundException
- The template could not be found.
templateExists
public boolean templateExists(java.lang.String template)
- Deprecated.
- Determine whether a given template exists. This service
currently only supports file base template hierarchies
so we will use the utility methods provided by
the template service to do the searching.
- Overrides:
templateExists
in class BaseTemplateEngineService
- Parameters:
String
- template- Returns:
- boolean
Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.