org.objectweb.util.monolog.wrapper.config
Class BasicFactory

java.lang.Object
  extended by org.objectweb.util.monolog.wrapper.config.BasicFactory
All Implemented Interfaces:
Serializable, HandlerFactory, LevelFactory, LoggerFactory, MonologFactory

public class BasicFactory
extends Object
implements MonologFactory, Serializable

This class is a basic implementation of the monolog factories (HandlerFactory, LoggerFactory and LevelFactory). It does not linked to an any underlying log system.

Author:
Sebastien Chassande-Barrioz
See Also:
Serialized Form

Field Summary
protected  HashMap handlers
          This field references the handler instance by their names.
key = a String object which is an handler name.
protected  HashMap 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  HashMap loggers
          This field references the handler instance by their names.
key = a String object which is a logger topic.
protected  HashMap 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 resource bundle linked to the LoggerFactory.
 
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
BasicFactory()
          It intializes the data struture, defines the default level and the root logger.
 
Method Summary
 void addLogInfo(Character pattern, LogInfo logInfoProvider)
          Add the extention
 void addMonologFactoryListener(MonologFactoryListener mfl)
           
 void configure(Properties prop)
           
 Handler createHandler(String hn, String handlertype)
           
protected  void defineDefaultLevels()
          It initializes the default monolog level: DEBUG: 10 000 INFO: 20 000 WARN: 30 000 ERROR: 40 000 FATAL: 50 000
 Level defineLevel(String name, int value)
           
 Level defineLevel(String name, String value)
           
protected  void defineRootLogger()
          It defines the level of the root logger to WARN.
 Handler getHandler(String hn)
           
 Handler[] getHandlers()
           
 Level getLevel(int value)
           
 Level getLevel(String name)
           
 Level[] getLevels()
           
 Logger getLogger(String _key)
           
 Logger getLogger(String key, String resourceBundleName)
           
 Logger[] getLoggers()
           
 LogInfo getLogInfo(Character pattern)
          Gets the provider of the extension
 String getResourceBundleName()
           
 String getTopicPrefix()
           
 Handler removeHandler(String hn)
           
 void removeLevel(String name)
           
 void removeLogger(Logger logger)
           
 void removeLogInfo(char pattern)
          Remove an extension
 void removeMonologFactoryListener(MonologFactoryListener mfl)
           
 void setResourceBundleName(String rbn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameToLevel

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


intToNames

protected HashMap 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.


handlers

protected HashMap 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.


loggers

protected HashMap loggers
This field references the handler instance by their names.
key = a String object which is a logger topic. value = the unique handler instance which has the key for name.


resourceBundleName

protected String resourceBundleName
The resource bundle linked to the LoggerFactory.

Constructor Detail

BasicFactory

public BasicFactory()
It intializes the data struture, defines the default level and the root logger.

Method Detail

defineDefaultLevels

protected void defineDefaultLevels()
It initializes the default monolog level:


defineRootLogger

protected void defineRootLogger()
It defines the level of the root logger to WARN.


addMonologFactoryListener

public void addMonologFactoryListener(MonologFactoryListener mfl)
Specified by:
addMonologFactoryListener in interface MonologFactory

removeMonologFactoryListener

public void removeMonologFactoryListener(MonologFactoryListener mfl)
Specified by:
removeMonologFactoryListener in interface MonologFactory

defineLevel

public Level defineLevel(String name,
                         int value)
Specified by:
defineLevel in interface LevelFactory

defineLevel

public Level defineLevel(String name,
                         String value)
Specified by:
defineLevel in interface LevelFactory

getLevel

public Level getLevel(String name)
Specified by:
getLevel in interface LevelFactory

getLevel

public Level getLevel(int value)
Specified by:
getLevel in interface LevelFactory

getLevels

public Level[] getLevels()
Specified by:
getLevels in interface LevelFactory

removeLevel

public void removeLevel(String name)
Specified by:
removeLevel in interface LevelFactory

configure

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

getLogger

public Logger getLogger(String _key)
Specified by:
getLogger in interface LoggerFactory

removeLogger

public void removeLogger(Logger logger)

getLogger

public Logger getLogger(String key,
                        String resourceBundleName)
Specified by:
getLogger in interface LoggerFactory

getResourceBundleName

public String getResourceBundleName()
Specified by:
getResourceBundleName in interface LoggerFactory

setResourceBundleName

public void setResourceBundleName(String rbn)
Specified by:
setResourceBundleName in interface LoggerFactory

getLoggers

public Logger[] getLoggers()
Specified by:
getLoggers in interface LoggerFactory

getTopicPrefix

public String getTopicPrefix()
Specified by:
getTopicPrefix in interface LoggerFactory

createHandler

public Handler createHandler(String hn,
                             String handlertype)
Specified by:
createHandler in interface HandlerFactory

getHandlers

public Handler[] getHandlers()
Specified by:
getHandlers in interface HandlerFactory

getHandler

public Handler getHandler(String hn)
Specified by:
getHandler in interface HandlerFactory

removeHandler

public Handler removeHandler(String hn)
Specified by:
removeHandler in interface HandlerFactory

addLogInfo

public void addLogInfo(Character pattern,
                       LogInfo logInfoProvider)
Add the extention

Specified by:
addLogInfo in interface MonologFactory
Parameters:
pattern - Character corresponding to the info to add
logInfoProvider - instance of info provider

removeLogInfo

public void removeLogInfo(char pattern)
Remove an extension

Specified by:
removeLogInfo in interface MonologFactory
Parameters:
pattern - log info pattern

getLogInfo

public LogInfo getLogInfo(Character pattern)
Gets the provider of the extension

Specified by:
getLogInfo in interface MonologFactory
Parameters:
pattern -
Returns:
LogInfo provider


Copyright © 2012 OW2 Consortium. All Rights Reserved.