org.mmbase.module
Class Config

java.lang.Object
  extended byorg.mmbase.module.Module
      extended byorg.mmbase.module.ProcessorModule
          extended byorg.mmbase.module.Config
All Implemented Interfaces:
ProcessorInterface

public class Config
extends ProcessorModule

This module analyses the MMBase XML configuration files.

LIST functions are:
  - token=SHOW
  - type={builders,databases,modules}
  Returns an list of arrays:
   $ITEM1 = name of file
   $ITEM2 = DTD-based syntax check: false, nodtd, true
  and for builders and databases there is:
   $ITEM3 = whether the item is active: false, true


 REPLACE functions are: SHOW, CHECK and ANNOTATE
    where the next argument is the directory, e.g. 'builders'
    and the third the name of the file without the .xml extension.
    SHOW: return a string with syntax colored XML file
    CHECK: return 1 if validates ok, -1 if not
    ANNOTATE: return a string with the XML file with errors listed
      and pointed out visually.

    Example: $MOD-CONFIG-SHOW-builders-people

 Additional REPLACE function is: REPORT
    which has no arguments.
 

Version:
$Id: Config.java,v 1.23.2.1 2004/07/30 18:04:53 michiel Exp $
Author:
Cees Roele
To Do:
- Add code for examples
- Add code to check whether database configuration works
- Add code for fault oriented results, rather than directory oriented results
- Remove xerces specific code

Nested Class Summary
 class Config.XMLFilenameFilter
          Implement a FilenameFilter for xml files
 
Constructor Summary
Config()
          Config, a support module for servscan
 
Method Summary
protected  java.lang.String annotateXML(java.lang.String path)
           
 boolean builderIsActive(java.lang.String path)
           
protected  java.lang.String checkXML(java.lang.String path)
           
protected  int checkXMLOk(java.lang.String path)
          Do validity check on XML file
 boolean databaseIsActive(java.lang.String path)
           
 java.util.Vector getList(scanpage sp, StringTagger tagger, java.lang.String value)
          Generate a list of values from a command to the processor
 java.lang.String getModuleInfo()
          provide some info on the module
protected  java.lang.String htmlEntities(java.lang.String s)
           
 void init()
          Initializes the module. Init must be overridden to read the environment variables it needs.
This method is called by Module.startModule(), which makes sure it is not called more than once. You should not call init() directly, call startModule() instead.
 java.util.Vector listConfigDirectories(java.lang.String path)
           
protected  java.util.Vector listDirectory(java.lang.String path)
          Retrieve all xml files in a directory
 void onload()
          prepares the module when loaded. Onload must be overridden to execute methods that need to be performed when the module is loaded but before any other modules are initailized.
This method is called by Module.startModules(). You should not call onload() directly.
protected  java.lang.String prettyPrintXML(java.lang.String path)
           
 boolean process(scanpage sp, java.util.Hashtable cmds, java.util.Hashtable vars)
          Execute the commands provided in the form values
 void reload()
          What should this do, when is this called? (MM)
 java.lang.String replace(scanpage sp, java.lang.String cmds)
          Handle a $MOD command
 java.lang.String report(java.lang.String eol)
          Temporary overall wrapper for report information
 java.lang.String reportBuilders(java.lang.String eol)
           
 void shutdown()
          Shuts down the module.
 void unload()
          What should this do, when is this called? (MM)
 
Methods inherited from class org.mmbase.module.ProcessorModule
cacheCheck, getListBuilder, getNodeList, replace
 
Methods inherited from class org.mmbase.module.Module
getInitParameter, getInitParameters, getMaintainer, getMimeType, getMimeTypeFile, getModule, getModule, getModules, getName, getProperties, getProperty, getVersion, hasStarted, loadModulesFromDisk, maintainance, setInitParameter, setMaintainer, setName, setVersion, shutdownModules, startModule, startModules, state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config

public Config()
Config, a support module for servscan

Method Detail

builderIsActive

public boolean builderIsActive(java.lang.String path)

databaseIsActive

public boolean databaseIsActive(java.lang.String path)
Parameters:
path - Relative path to database mapping file
Returns:
Whether a database mapping file is for the active DBMS

init

public void init()
Description copied from class: ProcessorModule
Initializes the module. Init must be overridden to read the environment variables it needs.
This method is called by Module.startModule(), which makes sure it is not called more than once. You should not call init() directly, call startModule() instead.

Overrides:
init in class ProcessorModule

reload

public void reload()
Description copied from class: ProcessorModule
What should this do, when is this called? (MM)

Overrides:
reload in class ProcessorModule

onload

public void onload()
Description copied from class: ProcessorModule
prepares the module when loaded. Onload must be overridden to execute methods that need to be performed when the module is loaded but before any other modules are initailized.
This method is called by Module.startModules(). You should not call onload() directly.

Overrides:
onload in class ProcessorModule

unload

public void unload()
Description copied from class: ProcessorModule
What should this do, when is this called? (MM)

Overrides:
unload in class ProcessorModule

shutdown

public void shutdown()
Description copied from class: Module
Shuts down the module. This method is called by shutdownModules.

Overrides:
shutdown in class Module

getList

public java.util.Vector getList(scanpage sp,
                                StringTagger tagger,
                                java.lang.String value)
                         throws ParseException
Generate a list of values from a command to the processor

Specified by:
getList in interface ProcessorInterface
Overrides:
getList in class ProcessorModule
Throws:
ParseException

listConfigDirectories

public java.util.Vector listConfigDirectories(java.lang.String path)
Parameters:
path - Path to root of configuration files
Returns:
Vector containing the names of the main configuration directories

listDirectory

protected java.util.Vector listDirectory(java.lang.String path)
                                  throws java.io.IOException
Retrieve all xml files in a directory

Parameters:
path - Directory path
Returns:
String array containing the names of the xml files in the directory
Throws:
java.io.IOException

process

public boolean process(scanpage sp,
                       java.util.Hashtable cmds,
                       java.util.Hashtable vars)
Execute the commands provided in the form values

Specified by:
process in interface ProcessorInterface
Overrides:
process in class ProcessorModule

report

public java.lang.String report(java.lang.String eol)
Temporary overall wrapper for report information


reportBuilders

public java.lang.String reportBuilders(java.lang.String eol)
Returns:
String of newline separated active builders

replace

public java.lang.String replace(scanpage sp,
                                java.lang.String cmds)
Handle a $MOD command

Specified by:
replace in interface ProcessorInterface
Overrides:
replace in class ProcessorModule

getModuleInfo

public java.lang.String getModuleInfo()
Description copied from class: Module
provide some info on the module

Overrides:
getModuleInfo in class Module

prettyPrintXML

protected java.lang.String prettyPrintXML(java.lang.String path)

checkXMLOk

protected int checkXMLOk(java.lang.String path)
Do validity check on XML file

Returns:
  • 0: No DTD defined
  • 1: ok
  • -1: false

htmlEntities

protected java.lang.String htmlEntities(java.lang.String s)
Returns:
String with '<' and '>' converted to respectively < and >

annotateXML

protected java.lang.String annotateXML(java.lang.String path)

checkXML

protected java.lang.String checkXML(java.lang.String path)


MMBase build 1.7.1.20041002