|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.jelly.JellyContext
JellyContext
represents the Jelly context.
Field Summary | |
protected ClassLoader |
classLoader
The class loader to use for instantiating application objects. |
protected boolean |
useContextClassLoader
Do we want to use the Context ClassLoader when loading classes for instantiating new objects? Default is false . |
Constructor Summary | |
JellyContext()
|
|
JellyContext(JellyContext parent)
|
|
JellyContext(JellyContext parentJellyContext,
URL currentURL)
|
|
JellyContext(JellyContext parentJellyContext,
URL rootURL,
URL currentURL)
|
|
JellyContext(URL rootURL)
|
|
JellyContext(URL rootURL,
URL currentURL)
|
Method Summary | |
Script |
compileScript(String uri)
Attempts to parse the script from the given uri using the getResource(java.lang.String) method then returns the compiled script. |
Script |
compileScript(URL url)
Attempts to parse the script from the given URL using the getResource(java.lang.String) method then returns the compiled script. |
protected JellyContext |
createChildContext()
Factory method to create a new child of this context |
protected URL |
createRelativeURL(URL rootURL,
String relativeURI)
|
protected XMLParser |
createXMLParser()
Factory method to allow JellyContext implementations to overload how an XMLParser is created - such as to overload what the default ExpressionFactory should be. |
Object |
findVariable(String name)
Finds the variable value of the given name in this context or in any other parent context. |
ClassLoader |
getClassLoader()
Return the class loader to be used for instantiating application objects when required. |
URL |
getCurrentURL()
|
protected URL |
getJellyContextURL(URL url)
Strips off the name of a script to create a new context URL |
JellyContext |
getParent()
|
URL |
getResource(String uri)
Returns a URL for the given resource from the specified path. |
InputStream |
getResourceAsStream(String uri)
Attempts to open an InputStream to the given resource at the specified path. |
URL |
getRootURL()
|
JellyContext |
getScope(String name)
|
TagLibrary |
getTagLibrary(String namespaceURI)
|
boolean |
getUseContextClassLoader()
Return the boolean as to whether the context classloader should be used. |
Object |
getVariable(String name)
|
Object |
getVariable(String name,
String scopeName)
|
Iterator |
getVariableNames()
|
Map |
getVariables()
|
protected XMLParser |
getXMLParser()
|
boolean |
isCacheTags()
Returns whether caching of Tag instances, per thread, is enabled. |
boolean |
isExport()
|
boolean |
isExportLibraries()
Returns whether we export tag libraries to our parents context |
boolean |
isInherit()
|
boolean |
isTagLibraryRegistered(String namespaceURI)
|
JellyContext |
newJellyContext()
A factory method to create a new child context of the current context. |
JellyContext |
newJellyContext(Map newVariables)
A factory method to create a new child context of the current context. |
void |
registerTagLibrary(String namespaceURI,
String className)
Registers the given tag library class name against the given namespace URI. |
void |
registerTagLibrary(String namespaceURI,
TagLibrary taglib)
Registers the given tag library against the given namespace URI. |
void |
removeVariable(String name)
Removes the given variable |
void |
removeVariable(String name,
String scopeName)
Removes the given variable in the specified scope. |
JellyContext |
runScript(File file,
XMLOutput output)
Parses the script from the given File then compiles it and runs it. |
JellyContext |
runScript(File file,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given file then compiles it and runs it. |
JellyContext |
runScript(String uri,
XMLOutput output)
Parses the script from the given uri using the JellyContext.getResource() API then compiles it and runs it. |
JellyContext |
runScript(String uri,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given uri using the JellyContext.getResource() API then compiles it and runs it. |
JellyContext |
runScript(URL url,
XMLOutput output)
Parses the script from the given URL then compiles it and runs it. |
JellyContext |
runScript(URL url,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given URL then compiles it and runs it. |
void |
setCacheTags(boolean cacheTags)
Sets whether caching of Tag instances, per thread, is enabled. |
void |
setClassLoader(ClassLoader classLoader)
Set the class loader to be used for instantiating application objects when required. |
void |
setCurrentURL(URL currentURL)
Sets the current URL context of the current script that is executing. |
void |
setExport(boolean export)
Sets whether we should export variable definitions to our parent context |
void |
setExportLibraries(boolean exportLibraries)
Sets whether we export tag libraries to our parents context |
void |
setInherit(boolean inherit)
Sets whether we should inherit variables from our parent context |
protected void |
setParent(JellyContext context)
Change the parent context to the one provided |
void |
setRootURL(URL rootURL)
Sets the current root context URL from which all absolute resource URIs will be relative to. |
void |
setUseContextClassLoader(boolean use)
Determine whether to use the Context ClassLoader (the one found by calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes. |
void |
setVariable(String name,
Object value)
Sets the value of the given variable name |
void |
setVariable(String name,
String scopeName,
Object value)
Sets the value of the given variable name in the given variable scope |
void |
setVariables(Map variables)
Sets the Map of variables to use |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ClassLoader classLoader
useContextClassLoader
variable.
protected boolean useContextClassLoader
false
.
Constructor Detail |
public JellyContext()
public JellyContext(URL rootURL)
public JellyContext(URL rootURL, URL currentURL)
public JellyContext(JellyContext parent)
public JellyContext(JellyContext parentJellyContext, URL currentURL)
public JellyContext(JellyContext parentJellyContext, URL rootURL, URL currentURL)
Method Detail |
public JellyContext getParent()
public JellyContext getScope(String name)
public Object findVariable(String name)
public Object getVariable(String name)
public Object getVariable(String name, String scopeName)
name
- is the name of the variablescopeName
- is the optional scope name such as 'parent'. For servlet environments
this could be 'application', 'session' or 'request'.
public void setVariable(String name, Object value)
public void setVariable(String name, String scopeName, Object value)
name
- is the name of the variablescopeName
- is the optional scope name such as 'parent'. For servlet environments
this could be 'application', 'session' or 'request'.value
- is the value of the attributepublic void removeVariable(String name)
public void removeVariable(String name, String scopeName)
name
- is the name of the variablescopeName
- is the optional scope name such as 'parent'. For servlet environments
this could be 'application', 'session' or 'request'.public Iterator getVariableNames()
public Map getVariables()
public void setVariables(Map variables)
public JellyContext newJellyContext(Map newVariables)
public JellyContext newJellyContext()
public void registerTagLibrary(String namespaceURI, TagLibrary taglib)
public void registerTagLibrary(String namespaceURI, String className)
public boolean isTagLibraryRegistered(String namespaceURI)
public TagLibrary getTagLibrary(String namespaceURI)
public Script compileScript(String uri) throws JellyException
getResource(java.lang.String)
method then returns the compiled script.
JellyException
public Script compileScript(URL url) throws JellyException
getResource(java.lang.String)
method then returns the compiled script.
JellyException
protected XMLParser getXMLParser()
protected XMLParser createXMLParser()
public JellyContext runScript(File file, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(URL url, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(String uri, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(String uri, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public JellyContext runScript(File file, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public JellyContext runScript(URL url, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public URL getResource(String uri) throws MalformedURLException
MalformedURLException
public InputStream getResourceAsStream(String uri)
public URL getRootURL()
public void setRootURL(URL rootURL)
public URL getCurrentURL()
getResource(java.lang.String)
to process relative scripts.public void setCurrentURL(URL currentURL)
getResource(java.lang.String)
to process relative scripts.
public boolean isCacheTags()
public void setCacheTags(boolean cacheTags)
cacheTags
- Whether caching should be enabled or disabled.public boolean isExportLibraries()
public void setExportLibraries(boolean exportLibraries)
exportLibraries
- The exportLibraries to setpublic void setExport(boolean export)
public boolean isExport()
public void setInherit(boolean inherit)
public boolean isInherit()
public ClassLoader getClassLoader()
setClassLoader()
, if anyuseContextClassLoader
property is set to true
public void setClassLoader(ClassLoader classLoader)
classLoader
- The new class loader to use, or null
to revert to the standard rulespublic boolean getUseContextClassLoader()
public void setUseContextClassLoader(boolean use)
Thread.currentThread().getContextClassLoader()
)
to resolve/load classes. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader.
use
- determines whether to use JellyContext ClassLoader.protected URL createRelativeURL(URL rootURL, String relativeURI) throws MalformedURLException
rootURL
- is the root context from which the relative URI will be appliedrelativeURI
- is the relative URI (without a leading "/")
MalformedURLException
- if the URL is invalid.protected URL getJellyContextURL(URL url) throws MalformedURLException
MalformedURLException
protected JellyContext createChildContext()
protected void setParent(JellyContext context)
context
- the new parent context
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |