org.mmbase.util.xml
Class UtilReader

java.lang.Object
  extended byorg.mmbase.util.xml.UtilReader

public class UtilReader
extends Object

This class reads configuration files for utilities, that are placed in /config/utils/. A typical way to use it may be like so:

    private UtilReader.PropertiesMap utilProperties = new UtilReader("myutil.xml", new Runnable() { public void run() { init();}}).getProperties();
    private void init() {
      // use utilProperties
    }
    {
      init();
    }
 
This produces a 'watched map' utilProperties. Every time the underlying config file(s) are changed 'init' is called. Init is called on instantation of the surrounding class too.

Since:
MMBase-1.6.4
Version:
$Id: UtilReader.java,v 1.25 2006/07/15 10:52:05 michiel Exp $
Author:
Rob Vermeulen, Michiel Meeuwissen

Nested Class Summary
static class UtilReader.PropertiesMap
          A unmodifiable Map, with extra 'Properties'-like methods.
 
Field Summary
static String CONFIG_UTILS
           
static String DTD_UTIL
          DTD respource filename of the most recent Utilities config DTD
static String DTD_UTIL_1_0
          DTD resource filename of the Utilities config DTD version 1.0
static String PUBLIC_ID_UTIL
          Public ID of the most recent Utilities config DTD
static String PUBLIC_ID_UTIL_1_0
          Public ID of the Utilities config DTD version 1.0
 
Constructor Summary
UtilReader(String fileName)
          Instantiates a UtilReader for a given configuration file in /utils.
UtilReader(String fileName, ResourceWatcher w)
          Produces a UtilReader for the given resource name.
UtilReader(String resourceName, Runnable onChange)
          Produces a UtilReader for the given resource name.
 
Method Summary
 void finalize()
           
static UtilReader get(String fileName)
          Returns a UtilReader for the given fileName.
 UtilReader.PropertiesMap getProperties()
          Get the properties of this utility.
protected  void readProperties(String s)
           
static void registerPublicIDs()
          Register the Public Ids for DTDs used by UtilReader This method is called by XMLEntityResolver.
 boolean resourceAvailable()
          Reports whether the configured resource (in the constructor) is actually backed.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_UTILS

public static final String CONFIG_UTILS
See Also:
Constant Field Values

PUBLIC_ID_UTIL_1_0

public static final String PUBLIC_ID_UTIL_1_0
Public ID of the Utilities config DTD version 1.0

See Also:
Constant Field Values

DTD_UTIL_1_0

public static final String DTD_UTIL_1_0
DTD resource filename of the Utilities config DTD version 1.0

See Also:
Constant Field Values

PUBLIC_ID_UTIL

public static final String PUBLIC_ID_UTIL
Public ID of the most recent Utilities config DTD

See Also:
Constant Field Values

DTD_UTIL

public static final String DTD_UTIL
DTD respource filename of the most recent Utilities config DTD

See Also:
Constant Field Values
Constructor Detail

UtilReader

public UtilReader(String fileName)
Instantiates a UtilReader for a given configuration file in /utils. If the configuration file is used on more spots, then you may consider using the static method get(String) in stead.

Parameters:
fileName - The name of the property file (e.g. httppost.xml).

UtilReader

public UtilReader(String fileName,
                  ResourceWatcher w)
Produces a UtilReader for the given resource name.

Parameters:
fileName - a Resource name relative to config/utils
w - A unstarted ResourceWatcher without files. (It will be only be called from the filewatcher in this reader). It defines what must happen if something changes in the util's configuration. Since you probably don't need the resource name for that any more, you can also simply use UtilReader(String, Runnable)
Since:
MMBase-1.8

UtilReader

public UtilReader(String resourceName,
                  Runnable onChange)
Produces a UtilReader for the given resource name.

Parameters:
resourceName - a Resource name relative to config/utils
onChange - A Runnable defining what must happen if something changes.
Since:
MMBase-1.8
Method Detail

registerPublicIDs

public static void registerPublicIDs()
Register the Public Ids for DTDs used by UtilReader This method is called by XMLEntityResolver.


get

public static UtilReader get(String fileName)
Returns a UtilReader for the given fileName. When you use this, the UtilReader instance will be cached.

Since:
MMBase-1.8

finalize

public void finalize()

getProperties

public UtilReader.PropertiesMap getProperties()
Get the properties of this utility.


resourceAvailable

public boolean resourceAvailable()
Reports whether the configured resource (in the constructor) is actually backed. If not, getProperties will certainly return an empty Map.

Since:
MMBase-1.8.1

readProperties

protected void readProperties(String s)


MMBase build 1.8.1.20060716