|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.jelly.JellyContext
public class JellyContext
JellyContext
represents the Jelly context.
Field Summary | |
---|---|
private boolean |
allowDtdToCallExternalEntities
Do we allow our doctype definitions to call out to external entities? |
private static java.lang.String |
BAD_PARSE
String used to denote a script can't be parsed |
protected java.lang.ClassLoader |
classLoader
The class loader to use for instantiating application objects. |
private java.net.URL |
currentURL
The current URL context (where relative scripts are located from) |
private static boolean |
DEFAULT_ALLOW_DTD_CALLS_TO_EXTERNAL_ENTITIES
Default for DTD calling out to external entities. |
private static boolean |
DEFAULT_EXPORT
Default for export of variables |
private static boolean |
DEFAULT_INHERIT
Default for inheritance of variables |
private boolean |
export
Do we export our variables to parent context? |
private boolean |
exportLibraries
Should we export tag libraries to our parents context |
private boolean |
inherit
Do we inherit variables from parent context? |
private static org.apache.commons.logging.Log |
log
The Log to which logging calls will be made. |
private JellyContext |
parent
The parent context |
private java.net.URL |
rootURL
The root URL context (where scripts are located from) |
private java.util.Map |
taglibs
Tag libraries found so far |
protected boolean |
useContextClassLoader
Do we want to use the Context ClassLoader when loading classes for instantiating new objects? Default is false . |
private java.util.Map |
variables
synchronized access to the variables in scope |
Constructor Summary | |
---|---|
JellyContext()
Create a new context with the currentURL set to the rootURL |
|
JellyContext(JellyContext parent)
Create a new context with the given parent context. |
|
JellyContext(JellyContext parentJellyContext,
java.net.URL currentURL)
Create a new context with the given parent context. |
|
JellyContext(JellyContext parentJellyContext,
java.net.URL rootURL,
java.net.URL currentURL)
Create a new context with the given parent context. |
|
JellyContext(java.net.URL rootURL)
Create a new context with the given rootURL |
|
JellyContext(java.net.URL rootURL,
java.net.URL currentURL)
Create a new context with the given rootURL and currentURL |
Method Summary | |
---|---|
void |
clear()
Clears variables set by Tags. |
protected void |
clearVariables()
Clears variables set by Tags (variables set while running a Jelly script) |
Script |
compileScript(org.xml.sax.InputSource source)
Attempts to parse the script from the given InputSource using the getResource(java.lang.String) method then returns the compiled script. |
Script |
compileScript(java.lang.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(java.net.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 java.net.URL |
createRelativeURL(java.net.URL rootURL,
java.lang.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. |
java.lang.Object |
findVariable(java.lang.String name)
Finds the variable value of the given name in this context or in any other parent context. |
java.lang.ClassLoader |
getClassLoader()
Return the class loader to be used for instantiating application objects when required. |
java.net.URL |
getCurrentURL()
|
protected java.net.URL |
getJellyContextURL(org.xml.sax.InputSource source)
Strips off the name of a script to create a new context URL |
protected java.net.URL |
getJellyContextURL(java.net.URL url)
Strips off the name of a script to create a new context URL |
JellyContext |
getParent()
|
java.net.URL |
getResource(java.lang.String uri)
Returns a URL for the given resource from the specified path. |
java.io.InputStream |
getResourceAsStream(java.lang.String uri)
Attempts to open an InputStream to the given resource at the specified path. |
java.net.URL |
getRootURL()
|
JellyContext |
getScope(java.lang.String name)
|
private java.lang.Object |
getSystemProperty(java.lang.String name)
Get a system property and handle security exceptions |
TagLibrary |
getTagLibrary(java.lang.String namespaceURI)
|
boolean |
getUseContextClassLoader()
Return the boolean as to whether the context classloader should be used. |
java.lang.Object |
getVariable(java.lang.String name)
|
java.lang.Object |
getVariable(java.lang.String name,
java.lang.String scopeName)
|
java.util.Iterator |
getVariableNames()
|
java.util.Map |
getVariables()
|
protected XMLParser |
getXMLParser()
|
private void |
init()
Initialize the context. |
boolean |
isAllowDtdToCallExternalEntities()
|
boolean |
isExport()
|
boolean |
isExportLibraries()
Returns whether we export tag libraries to our parents context |
boolean |
isInherit()
|
boolean |
isTagLibraryRegistered(java.lang.String namespaceURI)
|
JellyContext |
newJellyContext()
A factory method to create a new child context of the current context. |
JellyContext |
newJellyContext(java.util.Map newVariables)
A factory method to create a new child context of the current context. |
void |
registerTagLibrary(java.lang.String namespaceURI,
java.lang.String className)
Registers the given tag library class name against the given namespace URI. |
void |
registerTagLibrary(java.lang.String namespaceURI,
TagLibrary taglib)
Registers the given tag library against the given namespace URI. |
void |
removeVariable(java.lang.String name)
Removes the given variable |
void |
removeVariable(java.lang.String name,
java.lang.String scopeName)
Removes the given variable in the specified scope. |
JellyContext |
runScript(java.io.File file,
XMLOutput output)
Parses the script from the given File then compiles it and runs it. |
JellyContext |
runScript(java.io.File file,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given file then compiles it and runs it. |
JellyContext |
runScript(org.xml.sax.InputSource source,
XMLOutput output)
Parses the script from the given InputSource then compiles it and runs it. |
JellyContext |
runScript(org.xml.sax.InputSource source,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given InputSource then compiles it and runs it. |
JellyContext |
runScript(java.lang.String uri,
XMLOutput output)
Parses the script from the given uri using the JellyContext.getResource() API then compiles it and runs it. |
JellyContext |
runScript(java.lang.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(java.net.URL url,
XMLOutput output)
Parses the script from the given URL then compiles it and runs it. |
JellyContext |
runScript(java.net.URL url,
XMLOutput output,
boolean export,
boolean inherit)
Parses the script from the given URL then compiles it and runs it. |
void |
setAllowDtdToCallExternalEntities(boolean allowDtdToCallExternalEntities)
Sets whether we should allow our doctype definitions to call out to external entities. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set the class loader to be used for instantiating application objects when required. |
void |
setCurrentURL(java.net.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(java.net.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(java.lang.String name,
java.lang.Object value)
Sets the value of the named variable |
void |
setVariable(java.lang.String name,
java.lang.String scopeName,
java.lang.Object value)
Sets the value of the given variable name in the given variable scope |
void |
setVariables(java.util.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 |
---|
private static final org.apache.commons.logging.Log log
private static final boolean DEFAULT_INHERIT
private static final boolean DEFAULT_EXPORT
private static final boolean DEFAULT_ALLOW_DTD_CALLS_TO_EXTERNAL_ENTITIES
private static final java.lang.String BAD_PARSE
protected java.lang.ClassLoader classLoader
useContextClassLoader
variable.
protected boolean useContextClassLoader
false
.
private java.net.URL rootURL
private java.net.URL currentURL
private java.util.Map taglibs
private java.util.Map variables
private JellyContext parent
private boolean inherit
private boolean export
private boolean allowDtdToCallExternalEntities
private boolean exportLibraries
Constructor Detail |
---|
public JellyContext()
public JellyContext(java.net.URL rootURL)
rootURL
- the root URL used in resolving absolute resources i.e. those starting with '/'public JellyContext(java.net.URL rootURL, java.net.URL currentURL)
rootURL
- the root URL used in resolving absolute resources i.e. those starting with '/'currentURL
- the root URL used in resolving relative resourcespublic JellyContext(JellyContext parent)
parentScope
.
parent
- the parent context for the newly created context.public JellyContext(JellyContext parentJellyContext, java.net.URL currentURL)
parentScope
.
parentJellyContext
- the parent context for the newly created context.currentURL
- the root URL used in resolving relative resourcespublic JellyContext(JellyContext parentJellyContext, java.net.URL rootURL, java.net.URL currentURL)
parentScope
.
parentJellyContext
- the parent context for the newly created context.rootURL
- the root URL used in resolving absolute resources i.e. those starting with '/'currentURL
- the root URL used in resolving relative resourcesMethod Detail |
---|
private void init()
context
and
making the System Properties available as systemScope
public JellyContext getParent()
public JellyContext getScope(java.lang.String name)
public java.lang.Object findVariable(java.lang.String name)
public java.lang.Object getVariable(java.lang.String name)
private java.lang.Object getSystemProperty(java.lang.String name)
name
- the name of the property to retrieve
public java.lang.Object getVariable(java.lang.String name, java.lang.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(java.lang.String name, java.lang.Object value)
public void setVariable(java.lang.String name, java.lang.String scopeName, java.lang.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(java.lang.String name)
public void removeVariable(java.lang.String name, java.lang.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 java.util.Iterator getVariableNames()
public java.util.Map getVariables()
public void setVariables(java.util.Map variables)
public JellyContext newJellyContext(java.util.Map newVariables)
public JellyContext newJellyContext()
public void clear()
clearVariables()
protected void clearVariables()
clear()
public void registerTagLibrary(java.lang.String namespaceURI, TagLibrary taglib)
public void registerTagLibrary(java.lang.String namespaceURI, java.lang.String className)
public boolean isTagLibraryRegistered(java.lang.String namespaceURI)
public TagLibrary getTagLibrary(java.lang.String namespaceURI)
public Script compileScript(java.lang.String uri) throws JellyException
getResource(java.lang.String)
method then returns the compiled script.
JellyException
public Script compileScript(java.net.URL url) throws JellyException
getResource(java.lang.String)
method then returns the compiled script.
JellyException
public Script compileScript(org.xml.sax.InputSource source) throws JellyException
getResource(java.lang.String)
method then returns the compiled script.
JellyException
protected XMLParser getXMLParser()
protected XMLParser createXMLParser()
public JellyContext runScript(java.io.File file, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(java.net.URL url, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(org.xml.sax.InputSource source, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(java.lang.String uri, XMLOutput output) throws JellyException
JellyException
public JellyContext runScript(java.lang.String uri, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public JellyContext runScript(java.io.File file, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public JellyContext runScript(java.net.URL url, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public JellyContext runScript(org.xml.sax.InputSource source, XMLOutput output, boolean export, boolean inherit) throws JellyException
JellyException
public java.net.URL getResource(java.lang.String uri) throws java.net.MalformedURLException
java.net.MalformedURLException
public java.io.InputStream getResourceAsStream(java.lang.String uri)
public java.net.URL getRootURL()
public void setRootURL(java.net.URL rootURL)
public java.net.URL getCurrentURL()
getResource(java.lang.String)
to process relative scripts.public void setCurrentURL(java.net.URL currentURL)
getResource(java.lang.String)
to process relative scripts.
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 void setAllowDtdToCallExternalEntities(boolean allowDtdToCallExternalEntities)
public boolean isAllowDtdToCallExternalEntities()
public java.lang.ClassLoader getClassLoader()
setClassLoader()
, if anyuseContextClassLoader
property is set to true
public void setClassLoader(java.lang.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 java.net.URL createRelativeURL(java.net.URL rootURL, java.lang.String relativeURI) throws java.net.MalformedURLException
rootURL
- is the root context from which the relative URI will be appliedrelativeURI
- is the relative URI (without a leading "/")
java.net.MalformedURLException
- if the URL is invalid.protected java.net.URL getJellyContextURL(java.net.URL url) throws java.net.MalformedURLException
java.net.MalformedURLException
protected java.net.URL getJellyContextURL(org.xml.sax.InputSource source) throws java.net.MalformedURLException
java.net.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 |