| java.lang.Object org.apache.commons.jelly.JellyContext
All known Subclasses: org.apache.commons.jelly.servlet.JellyServletContext,
JellyContext | public class JellyContext (Code) | | JellyContext represents the Jelly context.
author: James Strachan version: $Revision: 165507 $ |
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 | |
public | JellyContext() | public | JellyContext(URL rootURL) Create a new context with the given rootURL
Parameters: rootURL - the root URL used in resolving absolute resources i.e. | public | JellyContext(URL rootURL, URL currentURL) Create a new context with the given rootURL and currentURL
Parameters: rootURL - the root URL used in resolving absolute resources i.e. | public | JellyContext(JellyContext parent) Create a new context with the given parent context. | public | JellyContext(JellyContext parentJellyContext, URL currentURL) Create a new context with the given parent context. | public | JellyContext(JellyContext parentJellyContext, URL rootURL, URL currentURL) Create a new context with the given parent context.
The parent's variables are available in the child context under the name parentScope .
Parameters: parentJellyContext - the parent context for the newly created context. Parameters: rootURL - the root URL used in resolving absolute resources i.e. |
Method Summary | |
public void | clear() Clears variables set by Tags. | protected void | clearVariables() | public Script | compileScript(String uri) Attempts to parse the script from the given uri using the
JellyContext.getResource method then returns the compiled script. | public Script | compileScript(URL url) Attempts to parse the script from the given URL using the
JellyContext.getResource method then returns the compiled script. | public Script | compileScript(InputSource source) Attempts to parse the script from the given InputSource using the
JellyContext.getResource method then returns the compiled script. | protected JellyContext | createChildContext() | 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. | public Object | findVariable(String name) Finds the variable value of the given name in this context or in any other parent context. | public ClassLoader | getClassLoader() Return the class loader to be used for instantiating application objects
when required. | public URL | getCurrentURL() | protected URL | getJellyContextURL(URL url) | protected URL | getJellyContextURL(InputSource source) | public JellyContext | getParent() | public URL | getResource(String uri) Returns a URL for the given resource from the specified path. | public InputStream | getResourceAsStream(String uri) Attempts to open an InputStream to the given resource at the specified path.
If the uri starts with "/" then the path is taken as relative to
the current context root. | public URL | getRootURL() the current root context URL from which all absolute resource URIswill be relative to. | public JellyContext | getScope(String name) | public TagLibrary | getTagLibrary(String namespaceURI) | public boolean | getUseContextClassLoader() Return the boolean as to whether the context classloader should be used. | public Object | getVariable(String name) | public Object | getVariable(String name, String scopeName) the value of the given variable name in the given variable scope Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. | public Iterator | getVariableNames() | public Map | getVariables() | protected XMLParser | getXMLParser() | public boolean | isExport() | public boolean | isExportLibraries() | public boolean | isInherit() | public boolean | isTagLibraryRegistered(String namespaceURI) | public JellyContext | newJellyContext(Map newVariables) A factory method to create a new child context of the
current context. | public JellyContext | newJellyContext() A factory method to create a new child context of the
current context. | public void | registerTagLibrary(String namespaceURI, TagLibrary taglib) Registers the given tag library against the given namespace URI. | public void | registerTagLibrary(String namespaceURI, String className) Registers the given tag library class name against the given namespace URI. | public void | removeVariable(String name) | public void | removeVariable(String name, String scopeName) Removes the given variable in the specified scope.
Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. | public JellyContext | runScript(File file, XMLOutput output) Parses the script from the given File then compiles it and runs it. | public JellyContext | runScript(URL url, XMLOutput output) Parses the script from the given URL then compiles it and runs it. | public JellyContext | runScript(InputSource source, XMLOutput output) Parses the script from the given InputSource then compiles it and runs it. | public JellyContext | runScript(String uri, XMLOutput output) Parses the script from the given uri using the
JellyContext.getResource() API then compiles it and runs it. | public 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. | public JellyContext | runScript(File file, XMLOutput output, boolean export, boolean inherit) Parses the script from the given file then compiles it and runs it. | public JellyContext | runScript(URL url, XMLOutput output, boolean export, boolean inherit) Parses the script from the given URL then compiles it and runs it. | public JellyContext | runScript(InputSource source, XMLOutput output, boolean export, boolean inherit) Parses the script from the given InputSource then compiles it and runs it. | public void | setClassLoader(ClassLoader classLoader) Set the class loader to be used for instantiating application objects
when required. | public void | setCurrentURL(URL currentURL) Sets the current URL context of the current script that is executing. | public void | setExport(boolean export) | public void | setExportLibraries(boolean exportLibraries) | public void | setInherit(boolean inherit) | protected void | setParent(JellyContext context) | public void | setRootURL(URL rootURL) Sets the current root context URL from which all absolute resource URIs
will be relative to. | public void | setUseContextClassLoader(boolean use) Determine whether to use the Context ClassLoader (the one found by
calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes. | public void | setVariable(String name, Object value) | public void | setVariable(String name, String scopeName, Object value) Sets the value of the given variable name in the given variable scope
Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. | public void | setVariables(Map variables) |
classLoader | protected ClassLoader classLoader(Code) | | The class loader to use for instantiating application objects.
If not specified, the context class loader, or the class loader
used to load this class itself, is used, based on the value of the
useContextClassLoader variable.
|
useContextClassLoader | protected boolean useContextClassLoader(Code) | | Do we want to use the Context ClassLoader when loading classes
for instantiating new objects? Default is false .
|
JellyContext | public JellyContext()(Code) | | Create a new context with the currentURL set to the rootURL
|
JellyContext | public JellyContext(URL rootURL)(Code) | | Create a new context with the given rootURL
Parameters: rootURL - the root URL used in resolving absolute resources i.e. those starting with '/' |
JellyContext | public JellyContext(URL rootURL, URL currentURL)(Code) | | Create a new context with the given rootURL and currentURL
Parameters: rootURL - the root URL used in resolving absolute resources i.e. those starting with '/' Parameters: currentURL - the root URL used in resolving relative resources |
JellyContext | public JellyContext(JellyContext parent)(Code) | | Create a new context with the given parent context.
The parent's rootURL and currentURL are set on the child, and the parent's variables are
available in the child context under the name parentScope .
Parameters: parent - the parent context for the newly created context. |
JellyContext | public JellyContext(JellyContext parentJellyContext, URL currentURL)(Code) | | Create a new context with the given parent context.
The parent's rootURL are set on the child, and the parent's variables are
available in the child context under the name parentScope .
Parameters: parentJellyContext - the parent context for the newly created context. Parameters: currentURL - the root URL used in resolving relative resources |
JellyContext | public JellyContext(JellyContext parentJellyContext, URL rootURL, URL currentURL)(Code) | | Create a new context with the given parent context.
The parent's variables are available in the child context under the name parentScope .
Parameters: parentJellyContext - the parent context for the newly created context. Parameters: rootURL - the root URL used in resolving absolute resources i.e. those starting with '/' Parameters: currentURL - the root URL used in resolving relative resources |
clearVariables | protected void clearVariables()(Code) | | Clears variables set by Tags (variables set while running a Jelly script)
See Also: JellyContext.clear() |
createChildContext | protected JellyContext createChildContext()(Code) | | Factory method to create a new child of this context
|
createRelativeURL | protected URL createRelativeURL(URL rootURL, String relativeURI) throws MalformedURLException(Code) | | a new relative URL from the given root and with the addition of theextra relative URI Parameters: rootURL - is the root context from which the relative URI will be applied Parameters: relativeURI - is the relative URI (without a leading "/") throws: MalformedURLException - if the URL is invalid. |
createXMLParser | protected XMLParser createXMLParser()(Code) | | Factory method to allow JellyContext implementations to overload how an XMLParser
is created - such as to overload what the default ExpressionFactory should be.
|
findVariable | public Object findVariable(String name)(Code) | | Finds the variable value of the given name in this context or in any other parent context.
If this context does not contain the variable, then its parent is used and then its parent
and so forth until the context with no parent is found.
the value of the variable in this or one of its descendant contexts or nullif the variable could not be found. |
getClassLoader | public ClassLoader getClassLoader()(Code) | | Return the class loader to be used for instantiating application objects
when required. This is determined based upon the following rules:
- The class loader set by
setClassLoader() , if any
- The thread context class loader, if it exists and the
useContextClassLoader property is set to true
- The class loader used to load the XMLParser class itself.
|
getCurrentURL | public URL getCurrentURL()(Code) | | the current URL context of the current script that is executing.This URL context is used to deduce relative scripts when relative URIs areused in calls to JellyContext.getResource to process relative scripts. |
getResource | public URL getResource(String uri) throws MalformedURLException(Code) | | Returns a URL for the given resource from the specified path.
If the uri starts with "/" then the path is taken as relative to
the current context root.
If the uri is a well formed URL then it is used.
If the uri is a file that exists and can be read then it is used.
Otherwise the uri is interpreted as relative to the current context (the
location of the current script).
|
getResourceAsStream | public InputStream getResourceAsStream(String uri)(Code) | | Attempts to open an InputStream to the given resource at the specified path.
If the uri starts with "/" then the path is taken as relative to
the current context root. If the uri is a well formed URL then it
is used. Otherwise the uri is interpreted as relative to the current
context (the location of the current script).
null if this resource could not be loaded, otherwise the resourcesinput stream is returned. |
getRootURL | public URL getRootURL()(Code) | | the current root context URL from which all absolute resource URIswill be relative to. For example in a web application the root URL willmap to the web directory which contains the WEB-INF directory. |
getScope | public JellyContext getScope(String name)(Code) | | the scope of the given name, such as the 'parent' scope.If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other namesfor scopes |
getTagLibrary | public TagLibrary getTagLibrary(String namespaceURI)(Code) | | the TagLibrary for the given namespace URI or null if one could not be found |
getUseContextClassLoader | public boolean getUseContextClassLoader()(Code) | | Return the boolean as to whether the context classloader should be used.
|
getVariable | public Object getVariable(String name)(Code) | | the value of the given variable name |
getVariable | public Object getVariable(String name, String scopeName)(Code) | | the value of the given variable name in the given variable scope Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. For servlet environmentsthis could be 'application', 'session' or 'request'. |
getVariableNames | public Iterator getVariableNames()(Code) | | an Iterator over the current variable names in thiscontext |
getVariables | public Map getVariables()(Code) | | the Map of variables in this scope |
getXMLParser | protected XMLParser getXMLParser()(Code) | | a thread pooled XMLParser to avoid the startup overheadof the XMLParser |
isExport | public boolean isExport()(Code) | | whether we should export variable definitions to our parent context |
isExportLibraries | public boolean isExportLibraries()(Code) | | Returns whether we export tag libraries to our parents context
boolean |
isInherit | public boolean isInherit()(Code) | | whether we should inherit variables from our parent context |
isTagLibraryRegistered | public boolean isTagLibraryRegistered(String namespaceURI)(Code) | | |
newJellyContext | public JellyContext newJellyContext(Map newVariables)(Code) | | A factory method to create a new child context of the
current context.
|
newJellyContext | public JellyContext newJellyContext()(Code) | | A factory method to create a new child context of the
current context.
|
registerTagLibrary | public void registerTagLibrary(String namespaceURI, TagLibrary taglib)(Code) | | Registers the given tag library against the given namespace URI.
This should be called before the parser is used.
|
registerTagLibrary | public void registerTagLibrary(String namespaceURI, String className)(Code) | | 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.
|
removeVariable | public void removeVariable(String name)(Code) | | Removes the given variable
|
removeVariable | public void removeVariable(String name, String scopeName)(Code) | | Removes the given variable in the specified scope.
Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. For servlet environmentsthis could be 'application', 'session' or 'request'. |
runScript | public JellyContext runScript(String uri, XMLOutput output) throws JellyException(Code) | | Parses the script from the given uri using the
JellyContext.getResource() API then compiles it and runs it.
the new child context that was used to run the script |
runScript | public JellyContext runScript(String uri, XMLOutput output, boolean export, boolean inherit) throws JellyException(Code) | | Parses the script from the given uri using the
JellyContext.getResource() API then compiles it and runs it.
the new child context that was used to run the script |
runScript | public JellyContext runScript(File file, XMLOutput output, boolean export, boolean inherit) throws JellyException(Code) | | Parses the script from the given file then compiles it and runs it.
the new child context that was used to run the script |
runScript | public JellyContext runScript(URL url, XMLOutput output, boolean export, boolean inherit) throws JellyException(Code) | | Parses the script from the given URL then compiles it and runs it.
the new child context that was used to run the script |
runScript | public JellyContext runScript(InputSource source, XMLOutput output, boolean export, boolean inherit) throws JellyException(Code) | | Parses the script from the given InputSource then compiles it and runs it.
the new child context that was used to run the script |
setClassLoader | public void setClassLoader(ClassLoader classLoader)(Code) | | Set the class loader to be used for instantiating application objects
when required.
Parameters: classLoader - The new class loader to use, or null to revert to the standard rules |
setCurrentURL | public void setCurrentURL(URL currentURL)(Code) | | Sets the current URL context of the current script that is executing.
This URL context is used to deduce relative scripts when relative URIs are
used in calls to
JellyContext.getResource to process relative scripts.
|
setExport | public void setExport(boolean export)(Code) | | Sets whether we should export variable definitions to our parent context
|
setExportLibraries | public void setExportLibraries(boolean exportLibraries)(Code) | | Sets whether we export tag libraries to our parents context
Parameters: exportLibraries - The exportLibraries to set |
setInherit | public void setInherit(boolean inherit)(Code) | | Sets whether we should inherit variables from our parent context
|
setParent | protected void setParent(JellyContext context)(Code) | | Change the parent context to the one provided
Parameters: context - the new parent context |
setRootURL | public void setRootURL(URL rootURL)(Code) | | Sets the current root context URL from which all absolute resource URIs
will be relative to. For example in a web application the root URL will
map to the web directory which contains the WEB-INF directory.
|
setUseContextClassLoader | public void setUseContextClassLoader(boolean use)(Code) | | Determine whether to use the Context ClassLoader (the one found by
calling Thread.currentThread().getContextClassLoader() )
to resolve/load classes. If not
using Context ClassLoader, then the class-loading defaults to
using the calling-class' ClassLoader.
Parameters: use - determines whether to use JellyContext ClassLoader. |
setVariable | public void setVariable(String name, Object value)(Code) | | Sets the value of the named variable
|
setVariable | public void setVariable(String name, String scopeName, Object value)(Code) | | Sets the value of the given variable name in the given variable scope
Parameters: name - is the name of the variable Parameters: scopeName - is the optional scope name such as 'parent'. For servlet environmentsthis could be 'application', 'session' or 'request'. Parameters: value - is the value of the attribute |
setVariables | public void setVariables(Map variables)(Code) | | Sets the Map of variables to use
|
|
|