public class TurbineVelocityService extends BaseTemplateEngineService implements VelocityService, org.apache.velocity.app.event.MethodExceptionEventHandler
Context context = TurbineVelocity.getContext(data);
context.put("message", "Hello from Turbine!");
String results = TurbineVelocity.handleRequest(context,"helloWorld.vm");
data.getPage().getBody().addElement(results);
name, serviceBrokerinitableBroker, isInitializedCATCH_ERRORS_DEFAULT, CATCH_ERRORS_KEY, CONTEXT, PIPELINEDATA_KEY, RUNDATA_KEY, SERVICE_NAME, VELOCITY_EXTENSIONDEFAULT_ERROR_SCREEN, DEFAULT_LAYOUT, DEFAULT_LAYOUT_TEMPLATE, DEFAULT_NAVIGATION, DEFAULT_NAVIGATION_TEMPLATE, DEFAULT_PAGE, DEFAULT_SCREEN, DEFAULT_SCREEN_TEMPLATE, DEFAULT_TEMPLATE_EXTENSION, TEMPLATE_EXTENSIONS| Constructor and Description |
|---|
TurbineVelocityService() |
| Modifier and Type | Method and Description |
|---|---|
org.apache.commons.collections.ExtendedProperties |
createVelocityProperties(org.apache.commons.configuration.Configuration conf)
This method generates the Extended Properties object necessary
for the initialization of Velocity.
|
org.apache.velocity.context.Context |
getContext()
Create a Context object that also contains the globalContext.
|
org.apache.velocity.context.Context |
getContext(PipelineData pipelineData)
Create a Context from the PipelineData object.
|
org.apache.velocity.context.Context |
getNewContext()
This method returns a new, empty Context object.
|
String |
handleRequest(org.apache.velocity.context.Context context,
String filename)
Process the request and fill in the template with the values
you set in the Context.
|
void |
handleRequest(org.apache.velocity.context.Context context,
String filename,
OutputStream output)
Process the request and fill in the template with the values
you set in the Context.
|
void |
handleRequest(org.apache.velocity.context.Context context,
String filename,
Writer writer)
Process the request and fill in the template with the values
you set in the Context.
|
void |
init()
Load all configured components and initialize them.
|
Object |
methodException(Class clazz,
String method,
Exception e)
MethodException Event Cartridge handler
for Velocity.
|
void |
requestFinished(org.apache.velocity.context.Context context)
Performs post-request actions (releases context
tools back to the object pool).
|
boolean |
templateExists(String template)
Find out if a given template exists.
|
getAssociatedFileExtensions, getTemplateEngineServiceConfiguration, initConfiguration, registerConfigurationinit, init, shutdowngetConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBrokergetInit, getInitableBroker, setInit, setInitableBrokerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConfiguration, getName, getProperties, setName, setServiceBrokergetInit, init, setInitableBroker, shutdownpublic TurbineVelocityService()
public void init() throws InitializationException
init in interface Initableinit in class TurbineBaseServiceInitializationException - Something went wrong in the init
stagepublic org.apache.velocity.context.Context getContext()
getContext in interface VelocityServicepublic org.apache.velocity.context.Context getNewContext()
getNewContext in interface VelocityServicepublic Object methodException(Class clazz, String method, Exception e) throws Exception
methodException in interface org.apache.velocity.app.event.MethodExceptionEventHandlerclazz - The class that threw the exceptionmethod - The Method name that threw the exceptione - The exception that would've been thrownException - We threw the exception further uppublic org.apache.velocity.context.Context getContext(PipelineData pipelineData)
getContext in interface VelocityServicepipelineData - The Turbine PipelineData object.public String handleRequest(org.apache.velocity.context.Context context, String filename) throws TurbineException
handleRequest in interface VelocityServicecontext - The populated context.filename - The file name of the template.TurbineException - Any exception thrown while processing will be
wrapped into a TurbineException and rethrown.public void handleRequest(org.apache.velocity.context.Context context, String filename, OutputStream output) throws TurbineException
handleRequest in interface VelocityServicecontext - A Context.filename - A String with the filename of the template.output - A OutputStream where we will write the process template as
a String.TurbineException - Any exception thrown while processing will be
wrapped into a TurbineException and rethrown.public void handleRequest(org.apache.velocity.context.Context context, String filename, Writer writer) throws TurbineException
handleRequest in interface VelocityServicecontext - A Context.filename - A String with the filename of the template.writer - A Writer where we will write the process template as
a String.TurbineException - Any exception thrown while processing will be
wrapped into a TurbineException and rethrown.public org.apache.commons.collections.ExtendedProperties createVelocityProperties(org.apache.commons.configuration.Configuration conf) throws Exception
conf - The Velocity Service configurationException - If a problem occurred while converting the properties.public boolean templateExists(String template)
templateExists in interface TemplateEngineServicetemplateExists in class BaseTemplateEngineServicetemplate - String template to search forTemplateEngineService.templateExists(java.lang.String)public void requestFinished(org.apache.velocity.context.Context context)
requestFinished in interface VelocityServicecontext - a Velocity ContextCopyright © 2000–2018 The Apache Software Foundation. All rights reserved.