org.x4juli.global.components
Class AbstractComponent

java.lang.Object
  extended byorg.x4juli.global.components.AbstractComponent
All Implemented Interfaces:
Component
Direct Known Subclasses:
AbstractAction, AbstractFilter, AbstractRollingPolicy, FilterBasedTriggeringPolicy, LoggerUtil, NOPTriggeringPolicy, PatternConverter, PatternParser, SizeBasedTriggeringPolicy

public abstract class AbstractComponent
extends java.lang.Object
implements Component

The basic implementation for all x4juli components.

Logging API as a whole was originally done for Apache log4j. Juli is a port of main parts of that to complete the Java Logging APIs. All credits for initial idea, design, implementation, documentation belong to the log4j crew. This file was originally published by Ceki Gülcü. Please use exclusively the appropriate mailing lists for questions, remarks and contribution.

Since:
0.5
Author:
Boris Unckel

Field Summary
private static java.util.Map componentloggers
           
private  int errorCount
           
(package private) static java.util.logging.Level INTERNAL_LOG_LEVEL
           
private  ExtendedLogger logger
           
protected  java.util.logging.LogManager manager
          Easy access to the LogManager for this component.
protected  ObjectStore repository
          Contains objects for this component.
 
Constructor Summary
AbstractComponent()
           
 
Method Summary
protected  ExtendedLogger getLogger()
          Return an instance specific logger to be used by the component itself.
(package private) static ExtendedLogger getLogger(java.lang.String name, java.lang.String resourceBundle)
           
protected  ObjectStore getLoggerRepository()
          Return the ObjectStore this component is attached to.
 MessageProperties getMessageProperties()
          Specifiy Properties for the component. Default Implementation returns null.
protected  ExtendedLogger getNonFloodingLogger()
          Frequently called methods in juli components can invoke this method in order to avoid flooding the output when logging lasting error conditions.
protected  boolean getProperty(java.lang.String name, boolean defaultValue)
          Get an property value out of the LogManager by name.
protected  int getProperty(java.lang.String name, int defaultValue)
          Get an property value out of the LogManager by name.
protected  long getProperty(java.lang.String name, long defaultValue)
          Get an property value out of the LogManager by name.
protected  java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Get an property value out of the LogManager by name.
protected  void resetErrorCount()
          Called by derived classes when they deem that the component has recovered from an erroneous state.
 void setObjectStore(ObjectStore objectstore)
          Set owning object repository for this component. This operation can only be performed once. Once set, the owning repository cannot be changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_LOG_LEVEL

static final java.util.logging.Level INTERNAL_LOG_LEVEL

repository

protected ObjectStore repository
Contains objects for this component.


manager

protected final java.util.logging.LogManager manager
Easy access to the LogManager for this component.


componentloggers

private static java.util.Map componentloggers

errorCount

private int errorCount

logger

private ExtendedLogger logger
Constructor Detail

AbstractComponent

public AbstractComponent()
Method Detail

setObjectStore

public void setObjectStore(ObjectStore objectstore)
Set owning object repository for this component. This operation can only be performed once. Once set, the owning repository cannot be changed.

Specified by:
setObjectStore in interface Component
Parameters:
objectstore - The repository where the configuration is stored
Since:
0.5

getMessageProperties

public MessageProperties getMessageProperties()
Specifiy Properties for the component. Default Implementation returns null.

Specified by:
getMessageProperties in interface Component
Returns:
the key for the Properties for the component
Since:
0.5

getLoggerRepository

protected ObjectStore getLoggerRepository()
Return the ObjectStore this component is attached to.

Returns:
Owning ObjectStore
Since:
0.5

resetErrorCount

protected void resetErrorCount()
Called by derived classes when they deem that the component has recovered from an erroneous state.

Since:
0.5

getLogger

static ExtendedLogger getLogger(java.lang.String name,
                                java.lang.String resourceBundle)

getLogger

protected ExtendedLogger getLogger()
Return an instance specific logger to be used by the component itself. This logger is not intended to be accessed by the end-user, hence the protected keyword.

This logger always sends output to an ConsoleHandler, which outputs to System.err

Returns:
A Logger instance.
Since:
0.5

getNonFloodingLogger

protected ExtendedLogger getNonFloodingLogger()
Frequently called methods in juli components can invoke this method in order to avoid flooding the output when logging lasting error conditions.

Returns:
a regular logger, or a NOPLogger if called too frequently.
Since:
0.5

getProperty

protected java.lang.String getProperty(java.lang.String name,
                                       java.lang.String defaultValue)
Get an property value out of the LogManager by name.

Parameters:
name - of the parameter to be obtained.
defaultValue - to return if no value has been found.
Returns:
the value of the given property, if null defaultValue.

getProperty

protected int getProperty(java.lang.String name,
                          int defaultValue)
Get an property value out of the LogManager by name.

Parameters:
name - of the parameter to be obtained.
defaultValue - to return if no value has been found.
Returns:
the value of the given property, if null defaultValue.

getProperty

protected long getProperty(java.lang.String name,
                           long defaultValue)
Get an property value out of the LogManager by name.

Parameters:
name - of the parameter to be obtained.
defaultValue - to return if no value has been found.
Returns:
the value of the given property, if null defaultValue.

getProperty

protected boolean getProperty(java.lang.String name,
                              boolean defaultValue)
Get an property value out of the LogManager by name.

Parameters:
name - of the parameter to be obtained.
defaultValue - to return if no value has been found.
Returns:
the value of the given property, if null defaultValue.


${license_html}