Class DigestingPlugIn
- All Implemented Interfaces:
 PlugIn
An implementation of PlugIn which can be configured to
 instantiate a graph of objects using the Commons Digester and place the
 root object of that graph into the Application context.
- Since:
 - Struts 1.2
 - Version:
 - $Rev$
 - See Also:
 
- 
Field Summary
Fields - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyRuleSets(org.apache.commons.digester.Digester digester) Instantiate anyRuleSetclasses defined in therulesetsproperty and use them to add rules to ourDigester.voiddestroy()Receive notification that our owning module is being shut down.protected org.apache.commons.digester.DigesterdigesterFromXml(String path, String source) Instantiate a Digester from an XML input stream using the CommonsDigesterLoader.protected URLgetClassPathURL(String path) Given a string, return a URL to a classpath resource of that name.protected URLgetConfigURL(String path, String source) Look up a resource path using one of a set of known path resolution mechanisms and return a URL to the resource.protected URLgetFileURL(String path) Given a string, return a URL to a Filesystem resource of that name.getKey()booleangetPush()protected URLgetServletContextURL(String path) Given a string, return a URL to a Servlet Context resource of that name.voidinit(ActionServlet servlet, ModuleConfig config) Initialize aDigesterand use it to parse a configuration file, resulting in a root object which will be placed into the ServletContext.protected org.apache.commons.digester.DigesterInitialize theDigesterwhich will be used to process the main configuration.protected org.apache.commons.digester.DigesterInstantiate aDigester.voidsetConfigPath(String configPath) voidsetConfigSource(String configSource) Set the source of the config file.voidsetDigesterPath(String digesterPath) The path to a Digester XML configuration file, relative to thedigesterSourceproperty.voidsetDigesterSource(String digesterSource) The lookup mechanism to be used to resolvedigesterPath(optional).voidvoidsetPush(boolean push) If set totrue, this PlugIn will be pushed onto the Digester stack before the digesterparsemethod is called.voidsetRulesets(String ruleSets) A comma-delimited list of one or more classes which implementorg.apache.commons.digester.RuleSet.protected voidThis method is called after the Digester runs to store the generated object somewhere. 
- 
Field Details
- 
SOURCE_CLASSPATH
- See Also:
 
 - 
SOURCE_FILE
- See Also:
 
 - 
SOURCE_SERVLET
- See Also:
 
 - 
configPath
 - 
configSource
 - 
digesterPath
 - 
digesterSource
 - 
key
 - 
moduleConfig
 - 
rulesets
 - 
servlet
 - 
push
protected boolean push 
 - 
 - 
Constructor Details
- 
DigestingPlugIn
public DigestingPlugIn()Constructor for DigestingPlugIn. 
 - 
 - 
Method Details
- 
destroy
public void destroy()Receive notification that our owning module is being shut down. - 
init
Initialize a
Digesterand use it to parse a configuration file, resulting in a root object which will be placed into the ServletContext.- Specified by:
 initin interfacePlugIn- Parameters:
 servlet- ActionServlet that is managing all the modules in this web applicationconfig- ModuleConfig for the module with which this plug-in is associated- Throws:
 ServletException- if thisPlugIncannot be successfully initialized
 - 
initializeDigester
Initialize theDigesterwhich will be used to process the main configuration.- Returns:
 - a Digester, ready to use.
 - Throws:
 ServletException
 - 
newDigesterInstance
protected org.apache.commons.digester.Digester newDigesterInstance()Instantiate a
Digester.Subclasses may wish to override this to provide a subclass of Digester, or to configure the Digester using object methods.
- Returns:
 - a basic instance of 
org.apache.commons.digester.Digester 
 - 
digesterFromXml
protected org.apache.commons.digester.Digester digesterFromXml(String path, String source) throws IOException Instantiate a Digester from an XML input stream using the Commons
DigesterLoader.- Parameters:
 path- the path to the digester rules XML to be found usingsourcesource- a string indicating the lookup method to be used withpath- Returns:
 - a configured Digester
 - Throws:
 FileNotFoundExceptionMalformedURLExceptionIOException- See Also:
 
 - 
applyRuleSets
Instantiate anyRuleSetclasses defined in therulesetsproperty and use them to add rules to ourDigester.- Parameters:
 digester- the Digester instance to add RuleSet objects to.- Throws:
 ServletException
 - 
getConfigURL
Look up a resource path using one of a set of known path resolution mechanisms and return a URL to the resource.
- Parameters:
 path- a String which is meaningful to one of the known resolution mechanisms.source- one of the known path resolution mechanisms:- file - the path is a fully-qualified filesystem path.
 - servlet - the path is a servlet-context relative path.
 - classpath - the path is a classpath-relative path.
 
- Returns:
 - a URL pointing to the given path in the given mechanism.
 - Throws:
 FileNotFoundExceptionMalformedURLExceptionIOException
 - 
getClassPathURL
Given a string, return a URL to a classpath resource of that name.- Parameters:
 path- a Classpath-relative string identifying a resource.- Returns:
 - a URL identifying the resource on the classpath. TODO Do we need to be smarter about ClassLoaders?
 
 - 
getServletContextURL
Given a string, return a URL to a Servlet Context resource of that name.- Parameters:
 path- a Classpath-relative string identifying a resource.- Returns:
 - a URL identifying the resource in the Servlet Context
 - Throws:
 MalformedURLExceptionIOException
 - 
getFileURL
Given a string, return a URL to a Filesystem resource of that name.- Parameters:
 path- a path to a file.- Returns:
 - a URL identifying the resource in the in the file system.
 - Throws:
 MalformedURLExceptionFileNotFoundExceptionIOException
 - 
setConfigPath
- Parameters:
 configPath- the path to configuration information for this PlugIn.- See Also:
 
 - 
getConfigPath
- Returns:
 - the configPath property
 - See Also:
 
 - 
setConfigSource
Set the source of the config file. Should be one of the following:- "classpath" - indicates that the configPath will be resolved by the ClassLoader.
 - "file" - indicates that the configPath is a fully-qualified filesystem path.
 - "servlet" - indicates that the configPath will be found by the ServletContext.
 
- Parameters:
 configSource- the source (lookup method) for the config file.- See Also:
 
 - 
getConfigSource
- Returns:
 - the string describing which access method should be used to resolve configPath.
 - See Also:
 
 - 
storeGeneratedObject
This method is called after the Digester runs to store the generated object somewhere. This implementation places the given object into the ServletContext under the attribute name as defined inkey.- Parameters:
 obj- The object to save.
 - 
setKey
- Parameters:
 key- The ServletContext attribute name to store the generated object under.
 - 
getKey
- Returns:
 - The ServletContext attribute name the generated object is stored under.
 
 - 
setRulesets
A comma-delimited list of one or more classes which implement
org.apache.commons.digester.RuleSet. (Optional) - 
getRulesets
- Returns:
 - The configured list of 
RuleSetclasses. 
 - 
setDigesterPath
The path to a Digester XML configuration file, relative to the
digesterSourceproperty. (Optional)- See Also:
 
 - 
getDigesterPath
- Returns:
 - the configured path to a Digester XML config file, or null.
 - See Also:
 
 - 
setDigesterSource
The lookup mechanism to be used to resolve
digesterPath(optional).- Parameters:
 digesterSource-- See Also:
 
 - 
getDigesterSource
- Returns:
 - the configured lookup mechanism for resolving
         
digesterPath. - See Also:
 
 - 
setPush
public void setPush(boolean push) If set to
true, this PlugIn will be pushed onto the Digester stack before the digesterparsemethod is called.Defaults to
false- Parameters:
 push-
 - 
getPush
public boolean getPush()- Returns:
 - Whether or not this 
PlugIninstance will be pushed onto theDigesterstack beforedigester.parse()is called. 
 
 -