org.objectweb.util.monolog.wrapper.common

Class AbstractFactory

Implemented Interfaces:
Configurable, HandlerFactory, LevelFactory, LoggerFactory, MonologFactory
Known Direct Subclasses:
LoggerFactory, MonologLoggerFactory

public abstract class AbstractFactory
extends java.lang.Object
implements MonologFactory, Configurable

Author:
S.Chassande-Barrioz

Field Summary

static boolean
debug
Inidicates if the monolog wrapper must be logged itself.
static String[][]
handlerType2className
static String[]
handlerTypes
protected Map
handlers
This field references the handler instance by their names.
key = a String object which is an handler name.
protected Map
intToNames
This field reference the level names by their integer value.
key = a java.lang.Integer which the value is the level
value = a String or an ArrayList of String.
protected Map
nameToLevel
This field references the level instances by their names.
key = a level name
value = the unique Level instance linked to the name.
protected String
resourceBundleName
The default resource bundle of this factory

Fields inherited from interface org.objectweb.util.monolog.api.MonologFactory

DEFAULT, LOG_CONFIGURATION_FILE, LOG_CONFIGURATION_FILE_USE_CLASSPATH, LOG_CONFIGURATION_TYPE, PROPERTY, XML

Constructor Summary

AbstractFactory()
It initializes the default monolog level: INHERIT, DEBUG, INFO, WARN, ERROR, FATAL

Method Summary

void
configure(Properties prop)
Handler
createHandler(String hn, String handlertype)
It retrieves a new instance of an handler which the type is specified by the parameter.
static void
debug(String m)
This method must be only used to debug the Monolog wrappers.
Level
defineLevel(String name, String value)
It defines a new Level with a name and a string value.
Level
defineLevel(String name, int value)
It defines a new Level with a name and an integer value.
protected String[][]
getDefaultHandlerType2className()
Handler
getHandler(String hn)
It retrieves the handler which the name is specified by the parameter
Handler[]
getHandlers()
It retrieves all handler managed by this factory.
Level
getLevel(String name)
It retrieves a Level instance which the name is equals to the parameter.
Level
getLevel(int value)
It retrieves a Level instance which the integer value is equals to the parameter.
Level[]
getLevels()
It retrieves all Level instances defined in this manager.
Logger
getLogger(String key)
This method permits to fetch a Logger.
Logger[]
getLoggers()
It retrieves a list of all loggers.
String
getResourceBundleName()
Accessors to a resource bundle name associated to a LoggerFactory.
String
getWrapperName()
protected void
initHandlerType2className()
Handler
removeHandler(String hn)
It removes the handler which the name is specified by the parameter
void
removeLevel(String name)
It removes a Level instance to this manager.
void
setResourceBundleName(String rbn)
Accessors to a resource bundle name associated to a LoggerFactory.
static void
warn(String m)

Field Details

debug

public static boolean debug
Inidicates if the monolog wrapper must be logged itself.


handlerType2className

public static String[][] handlerType2className


handlerTypes

public static String[] handlerTypes


handlers

protected Map handlers
This field references the handler instance by their names.
key = a String object which is an handler name. value = the unique handler instance which has the key for name.


intToNames

protected Map intToNames
This field reference the level names by their integer value.
key = a java.lang.Integer which the value is the level
value = a String or an ArrayList of String. The strings represent the name which match to the integer value. Indeed both name can be associated to the same integer value.


nameToLevel

protected Map nameToLevel
This field references the level instances by their names.
key = a level name
value = the unique Level instance linked to the name.


resourceBundleName

protected String resourceBundleName
The default resource bundle of this factory

Constructor Details

AbstractFactory

public AbstractFactory()
It initializes the default monolog level: INHERIT, DEBUG, INFO, WARN, ERROR, FATAL

Method Details

configure

public void configure(Properties prop)
            throws Exception
Specified by:
configure in interface MonologFactory


createHandler

public Handler createHandler(String hn,
                             String handlertype)
It retrieves a new instance of an handler which the type is specified by the parameter.
Specified by:
createHandler in interface HandlerFactory

Parameters:
handlertype - is the type of the parameter. The possible value are defined in this interface by the XXX_HANDLER_TYPE constants.

Returns:
a new instance of an handler


debug

public static void debug(String m)
This method must be only used to debug the Monolog wrappers. To active the log of monolog assign the "true" value to the system property "monolog.debug".

Parameters:
m - the message to log.


defineLevel

public Level defineLevel(String name,
                         String value)
It defines a new Level with a name and a string value. The string value is analyzed to obtain the integer value.
Specified by:
defineLevel in interface LevelFactory

Parameters:
name - is the name of the new level
value - is the string value of the new level

Returns:
a Level instance or a null value if It exists a Level with the same name but with another integer value.


defineLevel

public Level defineLevel(String name,
                         int value)
It defines a new Level with a name and an integer value.
Specified by:
defineLevel in interface LevelFactory

Parameters:
name - is the name of the new level
value - is the integer value of the new level

Returns:
a Level instance or a null value if It exists a Level with the same name but with another integer value.


getDefaultHandlerType2className

protected String[][] getDefaultHandlerType2className()


getHandler

public Handler getHandler(String hn)
It retrieves the handler which the name is specified by the parameter
Specified by:
getHandler in interface HandlerFactory

Parameters:

Returns:
an handler instance or a null value.


getHandlers

public Handler[] getHandlers()
It retrieves all handler managed by this factory.
Specified by:
getHandlers in interface HandlerFactory

Returns:
a set of Handler instance or an empty set.


getLevel

public Level getLevel(String name)
It retrieves a Level instance which the name is equals to the parameter.
Specified by:
getLevel in interface LevelFactory

Parameters:
name - is the name of request Level

Returns:
a Leve instance or a null value if the level does not exist.


getLevel

public Level getLevel(int value)
It retrieves a Level instance which the integer value is equals to the parameter.
Specified by:
getLevel in interface LevelFactory

Parameters:
value - is the integer value of request Level

Returns:
a Leve instance or a null value if the level does not exist. As it is possible to define several Levels which have the same integer value this methods returns the Level instance of first name found in the list.


getLevels

public Level[] getLevels()
It retrieves all Level instances defined in this manager.
Specified by:
getLevels in interface LevelFactory


getLogger

public Logger getLogger(String key)
This method permits to fetch a Logger. If the Logger described by the parameters does not exist, then the LoggerFactory must return a new instance of Logger. The key parameter is a description of the expected Logger. In simple cases, the key is the initial topic of the Logger.
Specified by:
getLogger in interface LoggerFactory


getLoggers

public Logger[] getLoggers()
It retrieves a list of all loggers.
Specified by:
getLoggers in interface LoggerFactory


getResourceBundleName

public String getResourceBundleName()
Accessors to a resource bundle name associated to a LoggerFactory.
Specified by:
getResourceBundleName in interface LoggerFactory


getWrapperName

public String getWrapperName()


initHandlerType2className

protected void initHandlerType2className()


removeHandler

public Handler removeHandler(String hn)
It removes the handler which the name is specified by the parameter
Specified by:
removeHandler in interface HandlerFactory

Parameters:

Returns:
the removed handler instance or a null value if it does not exist.


removeLevel

public void removeLevel(String name)
It removes a Level instance to this manager.
Specified by:
removeLevel in interface LevelFactory


setResourceBundleName

public void setResourceBundleName(String rbn)
Accessors to a resource bundle name associated to a LoggerFactory.
Specified by:
setResourceBundleName in interface LoggerFactory


warn

public static void warn(String m)