de.fhg.igd.logging
Class AbstractWrapper

java.lang.Object
  extended byde.fhg.igd.logging.AbstractWrapper
All Implemented Interfaces:
Wrapper
Direct Known Subclasses:
Log4jWrapper, SunWrapper

public abstract class AbstractWrapper
extends Object
implements Wrapper

This is an abstract wrapper class for a logger instance of the underlying logging mechanism. On configuration change requests, updates of output destinations and log levels will be performed on all affected instances through a bunch of (hidden) static methods, implicitly called by the LoggingConfiguration.

Specific operations like actually posting log messages or dealing with Forwarder objects are defined here but yet need to be implemented by subclasses for each specific underlying logging system.

Version:
"$Id: AbstractWrapper.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Field Summary
private static Set cache_
          The storage for all deployed target loggers
private  int cnt_
          The reference counter
private static Set forwarders_
          Storage for references of deployed Forwarder objects
protected  LogLevel level_
          The log level
protected  String lname_
          The log level name
protected  String name_
          The name of the wrapped target logger
protected  String oname_
          The output destination name
 
Constructor Summary
protected AbstractWrapper(String name, LoggerImpl ref)
          Hidden construction.
 
Method Summary
protected static void addForwarder(Forwarder forwarder)
          Register a Forwarder to be updated in case of buffer configuration changes.
protected abstract  void addForwarderFor(URL url)
          Add a new Forwarder for the given URL to the wrapped logger.
(package private) static void addLogLevel(String name, LogLevel level)
          Add a log level definition for the given name and update all wrappers whose best log level names match the given name.
(package private) static void addOutput(String name, URL output)
          Add a new output destination for the given name and update all wrappers whose current output names match the given name.
(package private) static void changeBuffer(URL output, Integer buffersize)
          Change the buffer size of affected Forwarder instances (that have been registered before).
(package private) static void changeLogLevel(String name, LogLevel level)
          Change the log level definition for the given name and update all wrappers whose current log level name match the given name.
protected static Chronometer chronometerFor(URL url)
          This method allows subclasses to access the protected Chronometer.instanceFor(de.fhg.igd.util.URL) to request Chronometer objects.
(package private) static void deleteOutput(String name)
          After deleting all output destinations of the given name, update all wrappers whose output name matches the given name and replace their output destinations by the best matching substitutes.
 void dismiss()
          This method will be called in case the corresponding instance of the implementing class will not be used anymore.
 boolean equals(Object obj)
           
 LogLevel getLogLevel()
          Get the log level of the wrapped logger.
 String getName()
          Get the name of the wrapped logger, which automatically is also the name of the corresponding LoggerImpl object.
 int hashCode()
           
(package private) static void initOutput(String name, URL output)
          After adding the first output destination for the given name, update all wrappers whose best output names match the given name.
protected abstract  void initTarget(LoggerImpl ref)
          Initialize the implementation specific logger target.
protected abstract  void removeAllForwarders()
          Remove all Forwarder and similar objects (e.g.
protected static void removeForwarder(Forwarder forwarder)
          Deregister a Forwarder from buffer configuration change updates.
protected abstract  void removeForwarderFor(URL url)
          Remove a Forwarder for the given URL from the wrapped logger.
(package private) static void removeLogLevel(String name)
          Remove the log level definition for the given name and replace it by the best matching substitute.
(package private) static void removeOutput(String name, URL output)
          Remove an output destination for the given name and update all wrappers whose current output name match the given name.
(package private) static AbstractWrapper requestFor(String name, Class wclazz, LoggerImpl ref)
          Request an AbstractWrapper for a given name.
protected abstract  void setLogLevel(LogLevel level)
          Set the log level of the wrapped logger.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.fhg.igd.logging.Wrapper
postLogEntry
 

Field Detail

forwarders_

private static Set forwarders_
Storage for references of deployed Forwarder objects


cache_

private static Set cache_
The storage for all deployed target loggers


cnt_

private int cnt_
The reference counter


name_

protected String name_
The name of the wrapped target logger


oname_

protected String oname_
The output destination name


lname_

protected String lname_
The log level name


level_

protected LogLevel level_
The log level

Constructor Detail

AbstractWrapper

protected AbstractWrapper(String name,
                          LoggerImpl ref)
Hidden construction.

Parameters:
name - The name of the wrapped logger
ref - A reference to the requesting instance
Method Detail

initTarget

protected abstract void initTarget(LoggerImpl ref)
Initialize the implementation specific logger target.

Parameters:
ref - The Logger implementation that originally requested this wrapper

requestFor

static AbstractWrapper requestFor(String name,
                                  Class wclazz,
                                  LoggerImpl ref)
Request an AbstractWrapper for a given name.

Parameters:
name - The name of the requested wrapper
wclazz - The Wrapper implementation class of the requested wrapper
ref - A reference to the requesting instance
Returns:
The requested wrapper
Throws:
LoggingException - in case the requested wrapper could not be created

getName

public String getName()
Description copied from interface: Wrapper
Get the name of the wrapped logger, which automatically is also the name of the corresponding LoggerImpl object.

Specified by:
getName in interface Wrapper
Returns:
The name of the wrapped logger

getLogLevel

public LogLevel getLogLevel()
Description copied from interface: Wrapper
Get the log level of the wrapped logger.

Specified by:
getLogLevel in interface Wrapper
Returns:
The log level of the wrapped logger

initOutput

static void initOutput(String name,
                       URL output)
After adding the first output destination for the given name, update all wrappers whose best output names match the given name.

Parameters:
name - The name to initialize the output destinations for
output - The new output destination

addOutput

static void addOutput(String name,
                      URL output)
Add a new output destination for the given name and update all wrappers whose current output names match the given name.

Parameters:
name - The name to add the new output destination for
output - The new output destination

removeOutput

static void removeOutput(String name,
                         URL output)
Remove an output destination for the given name and update all wrappers whose current output name match the given name.

Parameters:
name - The name to remove the output destination for
output - The output destination to remove

deleteOutput

static void deleteOutput(String name)
After deleting all output destinations of the given name, update all wrappers whose output name matches the given name and replace their output destinations by the best matching substitutes.

Parameters:
name - The name to delete the output destinations for

addForwarderFor

protected abstract void addForwarderFor(URL url)
Add a new Forwarder for the given URL to the wrapped logger.

Parameters:
url - The new output destination to be added to the wrapped logger

removeForwarderFor

protected abstract void removeForwarderFor(URL url)
Remove a Forwarder for the given URL from the wrapped logger.

Parameters:
url - The output destination to be removed from the wrapped logger

removeAllForwarders

protected abstract void removeAllForwarders()
Remove all Forwarder and similar objects (e.g. Handler instances for the Sun logging system) for the given URL.


addLogLevel

static void addLogLevel(String name,
                        LogLevel level)
Add a log level definition for the given name and update all wrappers whose best log level names match the given name.

Parameters:
name - The name to add the log level for
level - The log level for the given name

changeLogLevel

static void changeLogLevel(String name,
                           LogLevel level)
Change the log level definition for the given name and update all wrappers whose current log level name match the given name.

Parameters:
name - The name to change the log level for
level - The new log level of the given name

removeLogLevel

static void removeLogLevel(String name)
Remove the log level definition for the given name and replace it by the best matching substitute.

Parameters:
name - The name to add the log level for

setLogLevel

protected abstract void setLogLevel(LogLevel level)
Set the log level of the wrapped logger.

Parameters:
level - The new log level

dismiss

public void dismiss()
Description copied from interface: Wrapper
This method will be called in case the corresponding instance of the implementing class will not be used anymore. If all deployed instances have been dismissed, the wrapped logger object may be in turn released as well (if supported by the underlying system).

Specified by:
dismiss in interface Wrapper

chronometerFor

protected static Chronometer chronometerFor(URL url)
This method allows subclasses to access the protected Chronometer.instanceFor(de.fhg.igd.util.URL) to request Chronometer objects.

Parameters:
url - The URL to get the Chronometer instance for
Returns:
The requested Chronometer

addForwarder

protected static void addForwarder(Forwarder forwarder)
Register a Forwarder to be updated in case of buffer configuration changes.


removeForwarder

protected static void removeForwarder(Forwarder forwarder)
Deregister a Forwarder from buffer configuration change updates.


changeBuffer

static void changeBuffer(URL output,
                         Integer buffersize)
Change the buffer size of affected Forwarder instances (that have been registered before).

Parameters:
output - The output destination of affected Forwarder instances
buffersize - The new buffer size
See Also:
addForwarder(de.fhg.igd.logging.Forwarder)

equals

public boolean equals(Object obj)

hashCode

public int hashCode()

toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.