Expresso 5-6

com.jcorporate.expresso.kernel.management
Class DefaultServiceWriter

java.lang.Object
  extended bycom.jcorporate.expresso.kernel.ComponentBase
      extended bycom.jcorporate.expresso.kernel.management.DefaultServiceWriter
All Implemented Interfaces:
ComponentLifecycle, Describable, ExpressoComponent, Serializable, ServiceWriter

public class DefaultServiceWriter
extends ComponentBase
implements ServiceWriter, ComponentLifecycle

Default Implementation of the class used to write the ExpressoServices configuration file to a file or stream. This class is an ExpressoComponent that receives various configuration items from the system.

This class also keeps keeps intact an instance of a DOM Writer. The particular implementation class for the DOMWriter depends on the contents of the Expresso Configuration file.

Version:
$Revision: 1.5 $ on $Date: 2004/11/17 20:48:17 $
Author:
Michael Rimov
See Also:
Serialized Form

Constructor Summary
DefaultServiceWriter()
          Default Constructor
 
Method Summary
protected  org.w3c.dom.Document buildDOMTree(ExpressoServicesConfig configRoot)
          Convert the ExpressoServicesConfig bean to a DOM document that's compatible with what is expected in the expresso-services.xml file.
 void configure(Configuration newConfig)
          Configure the DefaultServiceWriter.
 void destroy()
          Implementation of the Destroy() lifecycle event.
 DOMWriter getDOMWriter()
          Retrieves the DOMWriter isntantiated class.
 String getDomWriterClass()
          Retrieves the previously set classname of the Dom Writer
 void initialize()
          Initialize the component, this is called before the component receives any configuration information.
protected  void processComponent(ComponentConfig config, org.w3c.dom.Element parent, org.w3c.dom.Document dom)
          Recursively go through the Expresso-services.config and convert all the various components into the DOM tree.
protected  void processComponentProperties(ComponentConfig config, org.w3c.dom.Element parent, org.w3c.dom.Document dom)
          Write the current component's configuration to the current DOM element.
 void reconfigure(Configuration newConfig)
          Reconfigure lifecycle event for this component.
 void setDomWriterClass(String domWriterClass)
          Sets and loads the specified domWriter class.
 void writeServicesFile(RootContainerInterface rootContainer, OutputStream os)
          Write the services file to a particular output stream
 void writeServicesFile(RootContainerInterface rootContainer, String location)
          Write the services file to a particular file location.
 
Methods inherited from class com.jcorporate.expresso.kernel.ComponentBase
getMetaData, getMetadataLocation, getParent, setMetaData, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceWriter

public DefaultServiceWriter()
Default Constructor

Method Detail

getDOMWriter

public DOMWriter getDOMWriter()
Retrieves the DOMWriter isntantiated class. May be null if the component was unable to load the specified system.

Specified by:
getDOMWriter in interface ServiceWriter
Returns:
an instantiated DOMWRiter for file writing.

writeServicesFile

public void writeServicesFile(RootContainerInterface rootContainer,
                              String location)
                       throws ExpressoRuntimeException
Write the services file to a particular file location.

Specified by:
writeServicesFile in interface ServiceWriter
Parameters:
rootContainer - The RootContainer interface that will contain base information about the system state we are about to save.
location - The location to save the services file. (File name should be included in this parameter).
Throws:
ExpressoRuntimeException - upon error.

writeServicesFile

public void writeServicesFile(RootContainerInterface rootContainer,
                              OutputStream os)
                       throws ExpressoRuntimeException
Write the services file to a particular output stream

Specified by:
writeServicesFile in interface ServiceWriter
Parameters:
rootContainer - The RootContainer interface that will contain base information about the system state we are about to save.
os - The output stream to save the services file to.
Throws:
ExpressoRuntimeException - upon error.

buildDOMTree

protected org.w3c.dom.Document buildDOMTree(ExpressoServicesConfig configRoot)
                                     throws ExpressoRuntimeException
Convert the ExpressoServicesConfig bean to a DOM document that's compatible with what is expected in the expresso-services.xml file.

Parameters:
configRoot - the root of the configuration tree.
Returns:
a DOM document representing the entire tree.
Throws:
ExpressoRuntimeException - if there is an error building the DOM tree

processComponent

protected void processComponent(ComponentConfig config,
                                org.w3c.dom.Element parent,
                                org.w3c.dom.Document dom)
Recursively go through the Expresso-services.config and convert all the various components into the DOM tree.

Parameters:
config - the current config bean in the tree
parent - the Parent DOM Element to append items to
dom - the DOM tree, used for building the various elements in the DOM tree.

processComponentProperties

protected void processComponentProperties(ComponentConfig config,
                                          org.w3c.dom.Element parent,
                                          org.w3c.dom.Document dom)
Write the current component's configuration to the current DOM element.

Parameters:
config - the current config to glean the properties from
parent - the parent element to append properties to as children.
dom - the DOM tree to use for Element factores

initialize

public void initialize()
Description copied from interface: ComponentLifecycle
Initialize the component, this is called before the component receives any configuration information.

Specified by:
initialize in interface ComponentLifecycle

configure

public void configure(Configuration newConfig)
               throws ConfigurationException
Configure the DefaultServiceWriter. The chief configuration value is the domWriter class, which describes which implementation to use for writing out DOM documents.

Specified by:
configure in interface ComponentLifecycle
Parameters:
newConfig - the Configuration object to load items from.
Throws:
ConfigurationException - if the domWriterClass cannot be instantiated

reconfigure

public void reconfigure(Configuration newConfig)
                 throws ConfigurationException
Reconfigure lifecycle event for this component. It attempts to load a new DOMWriter class, however, if unable to do so, it will rollback the configuration internally and throw a ConfigurationException.

Specified by:
reconfigure in interface ComponentLifecycle
Parameters:
newConfig - the Configuration object to load items from.
Throws:
ConfigurationException - if the system is unable to load the new DOMWriter class specified.

destroy

public void destroy()
Implementation of the Destroy() lifecycle event. nulls out all member properties.

Specified by:
destroy in interface ComponentLifecycle

getDomWriterClass

public String getDomWriterClass()
Retrieves the previously set classname of the Dom Writer

Returns:
java.lang.String

setDomWriterClass

public void setDomWriterClass(String domWriterClass)
                       throws ExpressoRuntimeException
Sets and loads the specified domWriter class.

Parameters:
domWriterClass - The classname of the DOMWriter to load
Throws:
ExpressoRuntimeException

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.