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

java.lang.Object
  extended by org.objectweb.util.monolog.file.monolog.PropertiesConfAccess
All Implemented Interfaces:
Serializable

public class PropertiesConfAccess
extends Object
implements 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 String ACTIVATION
           
static String ADDITIVITY_FIELD
           
static String CLEAN_HANDLERS_FIELD
           
static boolean debug
           
static char DOT
           
static String HANDLER_FIELD
           
static String HANDLER_TYPE_ATTRIBUTE
           
static String HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE
           
static String HANDLER_TYPE_ATTRIBUTE_FILE_VALUE
           
static String HANDLER_TYPE_ATTRIBUTE_JMX_VALUE
           
static String HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE
           
static String HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE
           
static String LEVEL_FIELD
           
static String LOGGER_FIELD
           
protected  Vector loggerCleaned
           
static String TOPIC_FIELD
           
static 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(String m)
           
protected  String[] getDependsLevel(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(Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
static void load(Properties prop, MonologFactory mf)
           
protected  Handler parseHandlerProp(Properties prop, String key, HandlerFactory hf)
          It parses a property entry to build or configure a Handler instance.
protected  Level parseLevelProp(Properties prop, String key, LevelFactory lef)
          It parses a property entry to build or configure a Level instance.
protected  Level parseLevelProp(Properties prop, String key, LevelFactory lef, Vector currentLevelParse)
          It parses a property entry to build or configure a Level instance.
protected  Logger parseLoggerProp(Properties prop, String key, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
          It parses a property entry to build or configure a Logger instance.
protected  Logger parseLoggerProp(Properties prop, String key, MonologFactory mf)
          It parses a property entry to build or configure a Logger instance.
 void read(Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
 void read(Properties prop, MonologFactory mf)
           
static void store(Properties prop, LoggerFactory lof, HandlerFactory hf, LevelFactory lef)
           
static void store(Properties prop, MonologFactory mf)
           
 void write(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 String LOGGER_FIELD
See Also:
Constant Field Values

ACTIVATION

public static final String ACTIVATION
See Also:
Constant Field Values

ADDITIVITY_FIELD

public static final String ADDITIVITY_FIELD
See Also:
Constant Field Values

USE_PARENT_FIELD

public static final String USE_PARENT_FIELD
See Also:
Constant Field Values

HANDLER_FIELD

public static final String HANDLER_FIELD
See Also:
Constant Field Values

LEVEL_FIELD

public static final String LEVEL_FIELD
See Also:
Constant Field Values

TOPIC_FIELD

public static final String TOPIC_FIELD
See Also:
Constant Field Values

CLEAN_HANDLERS_FIELD

public static final 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 String HANDLER_TYPE_ATTRIBUTE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_FILE_VALUE

public static final String HANDLER_TYPE_ATTRIBUTE_FILE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE

public static final String HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE

public static final String HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE

public static final String HANDLER_TYPE_ATTRIBUTE_NTEVENT_VALUE
See Also:
Constant Field Values

HANDLER_TYPE_ATTRIBUTE_JMX_VALUE

public static final String HANDLER_TYPE_ATTRIBUTE_JMX_VALUE
See Also:
Constant Field Values

debug

public static boolean debug

loggerCleaned

protected Vector loggerCleaned
Constructor Detail

PropertiesConfAccess

public PropertiesConfAccess()
Method Detail

load

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

load

public static void load(Properties prop,
                        MonologFactory mf)
                 throws Exception
Throws:
Exception

store

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

store

public static void store(Properties prop,
                         MonologFactory mf)
                  throws Exception
Throws:
Exception

read

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

read

public void read(Properties prop,
                 MonologFactory mf)
          throws Exception
Throws:
Exception

write

public void write(Properties prop,
                  LoggerFactory lof,
                  HandlerFactory hf,
                  LevelFactory lef)
           throws Exception
Throws:
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(Properties prop,
                                 String key,
                                 LoggerFactory lof,
                                 HandlerFactory hf,
                                 LevelFactory lef)
                          throws 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:
Exception - when a parameter is null or the entry is malformed.

parseLoggerProp

protected Logger parseLoggerProp(Properties prop,
                                 String key,
                                 MonologFactory mf)
                          throws 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:
Exception - when a parameter is null or the entry is malformed.

parseHandlerProp

protected Handler parseHandlerProp(Properties prop,
                                   String key,
                                   HandlerFactory hf)
                            throws 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:
Exception - when a parameter is null or the entry is malformed.

parseLevelProp

protected Level parseLevelProp(Properties prop,
                               String key,
                               LevelFactory lef)
                        throws 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:
Exception - when a circular level definition is found or when a parameter is null or the entry is malformed.

parseLevelProp

protected Level parseLevelProp(Properties prop,
                               String key,
                               LevelFactory lef,
                               Vector currentLevelParse)
                        throws 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:
Exception - when a circular level definition is found or when a parameter is null.

getDependsLevel

protected String[] getDependsLevel(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 Exception
Clear all the handlers associated to a logger which are not defined into this file

Throws:
Exception

debug

public void debug(String m)


Copyright © 2012 OW2 Consortium. All Rights Reserved.