org.objectweb.util.monolog.file.monolog
Class PropertiesConfAccess

java.lang.Object
  extended byorg.objectweb.util.monolog.file.monolog.PropertiesConfAccess
All Implemented Interfaces:
java.io.Serializable

public class PropertiesConfAccess
extends java.lang.Object
implements java.io.Serializable

This class permits to load and store a monolog configuration. The chooseen format is java.util.Properties. It also easy to write or load a Properties from a file. The encoding format is the following:
handler..=

level.=

logger..level=
logger..additivity=
logger..handler.=
logger..topic.=

Author:
Sebastien Chassande-Barrioz
See Also:
Serialized Form

Field Summary
static java.lang.String ADDITIVITY_FIELD
           
static java.lang.String CLEAN_HANDLERS_FIELD
           
static char DOT
           
static java.lang.String HANDLER_FIELD
           
static java.lang.String HANDLER_TYPE_ATTRIBUTE
           
static java.lang.String HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE
           
static java.lang.String HANDLER_TYPE_ATTRIBUTE_FILE_VALUE
           
static java.lang.String HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE
           
static java.lang.String HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE
           
static java.lang.String LEVEL_FIELD
           
static java.lang.String LOGGER_FIELD
           
protected  java.util.Vector loggerCleaned
           
static java.lang.String TOPIC_FIELD
           
static java.lang.String USE_PARENT_FIELD
           
 
Constructor Summary
PropertiesConfAccess()
           
 
Method Summary
protected  void cleanOldHandler(TopicalLogger l)
          Clear all the handlers associated to a logger which are not defined into this file
 void debug(java.lang.String m)
           
protected  java.lang.String[] getDependsLevel(java.lang.String expr)
          It retrieves the list of the referenced levels in the String parameter.
protected  boolean isDefaultLevel(Level l)
          It checks if the level parameter is a default monolog level.
static void load(java.util.Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
static void load(java.util.Properties prop, MonologFactory mf)
           
protected  Handler parseHandlerProp(java.util.Properties prop, java.lang.String key, HandlerFactory hf)
          It parses a property entry to build or configure a Handler instance.
protected  Level parseLevelProp(java.util.Properties prop, java.lang.String key, LevelFactory lef)
          It parses a property entry to build or configure a Level instance.
protected  Level parseLevelProp(java.util.Properties prop, java.lang.String key, LevelFactory lef, java.util.Vector currentLevelParse)
          It parses a property entry to build or configure a Level instance.
protected  Logger parseLoggerProp(java.util.Properties prop, java.lang.String key, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
          It parses a property entry to build or configure a Logger instance.
protected  Logger parseLoggerProp(java.util.Properties prop, java.lang.String key, MonologFactory mf)
          It parses a property entry to build or configure a Logger instance.
 void read(java.util.Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
 void read(java.util.Properties prop, MonologFactory mf)
           
static void store(java.util.Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
static void store(java.util.Properties prop, MonologFactory mf)
           
 void write(java.util.Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER_FIELD

public static final java.lang.String LOGGER_FIELD
See Also:
Constant Field Values

ADDITIVITY_FIELD

public static final java.lang.String ADDITIVITY_FIELD
See Also:
Constant Field Values

USE_PARENT_FIELD

public static final java.lang.String USE_PARENT_FIELD
See Also:
Constant Field Values

HANDLER_FIELD

public static final java.lang.String HANDLER_FIELD
See Also:
Constant Field Values

LEVEL_FIELD

public static final java.lang.String LEVEL_FIELD
See Also:
Constant Field Values

TOPIC_FIELD

public static final java.lang.String TOPIC_FIELD
See Also:
Constant Field Values

CLEAN_HANDLERS_FIELD

public static final java.lang.String CLEAN_HANDLERS_FIELD
See Also:
Constant Field Values

DOT

public static final char DOT
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE

public static final java.lang.String HANDLER_TYPE_ATTRIBUTE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_FILE_VALUE

public static final java.lang.String HANDLER_TYPE_ATTRIBUTE_FILE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE

public static final java.lang.String HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE

public static final java.lang.String HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE

public static final java.lang.String HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE
See Also:
Constant Field Values

loggerCleaned

protected java.util.Vector loggerCleaned
Constructor Detail

PropertiesConfAccess

public PropertiesConfAccess()
Method Detail

load

public static void load(java.util.Properties prop,
                        LoggerFactory lof,
                        HandlerFactory hf,
                        LevelFactory lef)
                 throws java.lang.Exception
Throws:
java.lang.Exception

load

public static void load(java.util.Properties prop,
                        MonologFactory mf)
                 throws java.lang.Exception
Throws:
java.lang.Exception

store

public static void store(java.util.Properties prop,
                         LoggerFactory lof,
                         HandlerFactory hf,
                         LevelFactory lef)
                  throws java.lang.Exception
Throws:
java.lang.Exception

store

public static void store(java.util.Properties prop,
                         MonologFactory mf)
                  throws java.lang.Exception
Throws:
java.lang.Exception

read

public void read(java.util.Properties prop,
                 LoggerFactory lof,
                 HandlerFactory hf,
                 LevelFactory lef)
          throws java.lang.Exception
Throws:
java.lang.Exception

read

public void read(java.util.Properties prop,
                 MonologFactory mf)
          throws java.lang.Exception
Throws:
java.lang.Exception

write

public void write(java.util.Properties prop,
                  LoggerFactory lof,
                  HandlerFactory hf,
                  LevelFactory lef)
           throws java.lang.Exception
Throws:
java.lang.Exception

isDefaultLevel

protected boolean isDefaultLevel(Level l)
It checks if the level parameter is a default monolog level. The default monolog levels are the following:


parseLoggerProp

protected Logger parseLoggerProp(java.util.Properties prop,
                                 java.lang.String key,
                                 LoggerFactory lof,
                                 HandlerFactory hf,
                                 LevelFactory lef)
                          throws java.lang.Exception
It parses a property entry to build or configure a Logger instance.

Parameters:
prop - is the property where the entry is reachable.
key - is the entry key
lof - is the logger factory to use for building a new instance or fetching existent loggers.
hf - is the handler factory to use for building a new instance or fetching existent handlers.
lef - is the level factory to use for building a new instance or fetching existent levels.
Returns:
the level instance which has been built or configured
Throws:
java.lang.Exception - when a parameter is null or the entry is malformed.

parseLoggerProp

protected Logger parseLoggerProp(java.util.Properties prop,
                                 java.lang.String key,
                                 MonologFactory mf)
                          throws java.lang.Exception
It parses a property entry to build or configure a Logger instance.

Parameters:
prop - is the property where the entry is reachable.
key - is the entry key
mf - is the monolog factory to use for building a new instance or fetching existent loggers, handlers or levels.
Returns:
the level instance which has been built or configured
Throws:
java.lang.Exception - when a parameter is null or the entry is malformed.

parseHandlerProp

protected Handler parseHandlerProp(java.util.Properties prop,
                                   java.lang.String key,
                                   HandlerFactory hf)
                            throws java.lang.Exception
It parses a property entry to build or configure a Handler instance.

Parameters:
prop - is the property where the entry is reachable.
key - is the entry key
hf - is the handler factory to use for building a new instance or fetching existent handlers.
Returns:
the handler instance which has been built or configured
Throws:
java.lang.Exception - when a parameter is null or the entry is malformed.

parseLevelProp

protected Level parseLevelProp(java.util.Properties prop,
                               java.lang.String key,
                               LevelFactory lef)
                        throws java.lang.Exception
It parses a property entry to build or configure a Level instance.

Parameters:
prop - is the property where the entry is reachable.
key - is the entry key
lef - is the level factory to use for building a new instance or fetching existent levels.
Returns:
the level instance which has been built or configured
Throws:
java.lang.Exception - when a circular level definition is found or when a parameter is null or the entry is malformed.

parseLevelProp

protected Level parseLevelProp(java.util.Properties prop,
                               java.lang.String key,
                               LevelFactory lef,
                               java.util.Vector currentLevelParse)
                        throws java.lang.Exception
It parses a property entry to build or configure a Level instance.

Parameters:
prop - is the property where the entry is reachable.
key - is the entry key
lef - is the level factory to use for building a new instance or fetching existent levels.
currentLevelParse - the list of current level name which are searched.
Throws:
java.lang.Exception - when a circular level definition is found or when a parameter is null.

getDependsLevel

protected java.lang.String[] getDependsLevel(java.lang.String expr)
It retrieves the list of the referenced levels in the String parameter.

Parameters:
expr - is a string which can contain level identifier. The string is an arithmetic expression which contains number, operator and levels identifier.
Returns:
the list of the referenced levels.

cleanOldHandler

protected void cleanOldHandler(TopicalLogger l)
                        throws java.lang.Exception
Clear all the handlers associated to a logger which are not defined into this file

Throws:
java.lang.Exception

debug

public void debug(java.lang.String m)