Package org.apache.commons.jelly.impl
Class Embedded
java.lang.Object
org.apache.commons.jelly.impl.Embedded
- Author:
- Vinay Chandran
Embeddedprovides easy means to embed JellyEngine and use Jelly scripts within an applicationA typical usage:
, Vinay ChandranEmbedded embedded = new Embedded(); embedded.setOutputStream(new ByteArrayOutputStream()); embedded.setVariable("some-var","some-object"); ..... embedded.setScript(scriptAsString); //or one can do. //embedded.setScript(scriptAsInputStream); boolean bStatus=embedded.execute(); if(!bStatus) //if error { String errorMsg=embedded.getErrorMsg(); }
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute()Execute the jelly script and capture the errors (ifany)within.Method getContext.Returns the errorMsg.voidregisterTagLibrary(String namespaceURI, String className) Registers the given tag library class name against the given namespace URI.voidregisterTagLibrary(String namespaceURI, TagLibrary taglib) Registers the given tag library against the given namespace URI.voidsetContext(JellyContext context) Method setContext.voidsetOutputStream(OutputStream outputStream) Method setOutputStream.voidsetScript(InputStream scriptAsInputStream) Set the input streamvoidSet the input scriptvoidsetVariable(String name, Object value) Set a new variable within the context for the script to use.
-
Constructor Details
-
Embedded
public Embedded()Default Constructor
-
-
Method Details
-
setContext
Method setContext.- Parameters:
context-
-
getContext
Method getContext.- Returns:
- JellyContext
-
setVariable
Set a new variable within the context for the script to use.- Parameters:
name-value-
-
setScript
Set the input script- Parameters:
scriptAsString-
-
setScript
Set the input stream- Parameters:
scriptAsInputStream-
-
setOutputStream
Method setOutputStream.- Parameters:
outputStream-
-
registerTagLibrary
Registers the given tag library class name against the given namespace URI. The class will be loaded via the given ClassLoader This should be called before the parser is used. -
registerTagLibrary
Registers the given tag library against the given namespace URI. This should be called before the parser is used. -
getErrorMsg
Returns the errorMsg.- Returns:
- String
-
execute
public boolean execute()Execute the jelly script and capture the errors (ifany)within.
-