|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.logging.Handler
org.x4juli.global.components.AbstractHandler
Abstract superclass of the other handlers in the package. This class provides
the code for common functionality, such as support for threshold filtering
and support for general filters. This class takes care of usage of
org.x4juli.global.spi.ExtendedFilter,
org.x4juli.global.spi.ExtendedFormatter,
org.x4juli.global.spi.ExtendedLogRecord.
| Attribute | Description | Required |
|---|---|---|
| .name | Name of the handler. | YES. No default, exception instead. |
| .level | Level of the handler. Allowed valued are from
java.util.logging.Level.*. |
No. Default ALL |
| .formatter | Formatter of the handler. Value is the full qualified classname of the formatter. | No, but recommened. Default
org.x4juli.formatter.SimpleFormatter |
| .filter | Filter of the handler. Value is the full qualified Classname of the filter. WARNING STILL UNDER DEVELOPMENT! | No. Default null. |
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.
| Field Summary | |
protected boolean |
active
Is the appender ready for action. |
protected boolean |
closed
Is this appender closed? |
private int |
errorCount
The component error counter. |
protected ExtendedFormatter |
extFormatter
The extendedFormatter remains null if an java.util.Logging.Formatter is set. |
private boolean |
guard
The guard prevents an appender from repeatedly calling its own doAppend method. |
protected ExtendedFilter |
headFilter
The first @link{ExtendedFilter} in the filter chain. |
private ExtendedLogger |
logger
The component logger. |
protected java.util.logging.LogManager |
manager
The component logmanager. |
protected java.lang.String |
name
Handlers are named. |
protected ObjectStore |
repository
The component object store. |
protected ExtendedFilter |
tailFilter
The last @link{ExtendedFilter} in the filter chain. |
| Fields inherited from class java.util.logging.Handler |
|
| Constructor Summary | |
protected |
AbstractHandler()
Default Constructor instantiation used for configuration by file. |
protected |
AbstractHandler(java.lang.String handlerName)
Utility Constructor. |
| Method Summary | |
void |
activateOptions()
Activate the options that were previously set with calls to option setters.
This allows to defer activiation of the options until all options have
been set. This is required for components which have related options that
remain ambigous until all are set.
|
void |
addFilter(ExtendedFilter newFilter)
Add a filter to end of the filter list. |
protected abstract void |
appendLogRecord(ExtendedLogRecord record)
Subclasses of AbstractHandler should implement this method
to perform actual logging. |
void |
clearFilters()
Clear the filters chain. |
void |
configure()
Configure all properties of the object. |
protected void |
finalize()
Finalize this appender by calling the derived class' close
method.
|
java.util.logging.Filter |
getFilter()
Returns the head filter of the filter chain. |
java.util.logging.Formatter |
getFormatter()
|
java.lang.String |
getFullQualifiedClassName()
Determine performant the FullQualifiedClassName. Subclasses should overwrite this method. Dynamic determination is not recommended. |
protected ExtendedLogger |
getLogger()
Return an instance specific logger to be used by the component itself. |
protected ObjectStore |
getLoggerRepository()
Return the ObjectStore this component is attached to. |
MessageProperties |
getMessageProperties()
Specifiy Properties for the component. Default Implementation returns null. |
java.lang.String |
getName()
Retrieve name of the Handler. |
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 propname,
boolean defaultValue)
Get an property value out of the LogManager by name. |
protected int |
getProperty(java.lang.String propname,
int defaultValue)
Get an property value out of the LogManager by name. |
protected java.lang.String |
getProperty(java.lang.String propname,
java.lang.String defaultValue)
Get an property value out of the LogManager by name. |
boolean |
isActive()
Returns true if this appender is working order. |
boolean |
isClosed()
Returns true if this appender instance is closed. |
boolean |
isLoggable(ExtendedLogRecord record)
Checks whether a record should be logged or not. Criteria: not null, level, filter chain passed. |
boolean |
isLoggable(java.util.logging.LogRecord record)
|
void |
publish(ExtendedLogRecord record)
|
void |
publish(java.util.logging.LogRecord record)
|
protected void |
resetErrorCount()
Called by derived classes when they deem that the component has recovered from an erroneous state. |
void |
setFilter(java.util.logging.Filter newFilter)
Different to the super Class, the filter is wrapped and added to the chain. |
void |
setFormatter(java.util.logging.Formatter newFormatter)
|
void |
setName(java.lang.String name)
Set the name of this Appender. |
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. |
java.lang.String |
toString()
|
| Methods inherited from class java.util.logging.Handler |
close, flush, getEncoding, getErrorManager, getLevel, reportError, setEncoding, setErrorManager, setLevel |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.x4juli.global.spi.ExtendedHandler |
close, flush, getEncoding, getErrorManager, getLevel, setEncoding, setErrorManager, setLevel |
| Field Detail |
protected ObjectStore repository
protected final java.util.logging.LogManager manager
protected ExtendedFilter headFilter
null
initially.
protected ExtendedFilter tailFilter
null
initially.
protected boolean closed
protected boolean active
protected java.lang.String name
protected ExtendedFormatter extFormatter
java.util.Logging.Formatter is set. Then the formatter of
the super class is used instead.
private ExtendedLogger logger
private int errorCount
private boolean guard
| Constructor Detail |
protected AbstractHandler()
protected AbstractHandler(java.lang.String handlerName)
handlerName - of the current instance.| Method Detail |
public void activateOptions()
This allows to defer activiation of the options until all options have
been set. This is required for components which have related options that
remain ambigous until all are set.
Subclasses have not set active to true, but call super as
last statement!
activateOptions in interface OptionHandlerpublic void configure()
public java.lang.String getFullQualifiedClassName()
getFullQualifiedClassName in interface ExtendedHandlerpublic void setObjectStore(ObjectStore objectstore)
setObjectStore in interface Componentobjectstore - The repository where the configuration is storedpublic MessageProperties getMessageProperties()
getMessageProperties in interface Componentpublic final void publish(java.util.logging.LogRecord record)
publish in interface Handlerpublic void publish(ExtendedLogRecord record)
publish in interface ExtendedHandlerrecord - to check and write in the log.publish(LogRecord)public final boolean isLoggable(java.util.logging.LogRecord record)
isLoggable in interface Handlerpublic boolean isLoggable(ExtendedLogRecord record)
isLoggable in interface ExtendedHandlerrecord - the record to check.
public java.util.logging.Filter getFilter()
getFilter in interface Handler
public final void setFilter(java.util.logging.Filter newFilter)
throws java.lang.SecurityException
setFilter in interface HandlernewFilter - the filter to add
java.lang.SecurityException - if changing the filter is not allowed.public void addFilter(ExtendedFilter newFilter)
addFilter in interface ExtendedHandlernewFilter - the filter to addpublic void clearFilters()
clearFilters in interface ExtendedHandler
public final void setFormatter(java.util.logging.Formatter newFormatter)
throws java.lang.SecurityException
setFormatter in interface Handlerjava.lang.SecurityExceptionpublic final java.util.logging.Formatter getFormatter()
getFormatter in interface Handlerpublic boolean isClosed()
isClosed in interface ExtendedHandlerpublic boolean isActive()
isActive in interface ExtendedHandlerpublic void setName(java.lang.String name)
setName in interface ExtendedHandlerpublic java.lang.String getName()
getName in interface ExtendedHandlerpublic java.lang.String toString()
protected void finalize()
throws java.lang.Throwable
close
method.
java.lang.Throwableprotected ObjectStore getLoggerRepository()
ObjectStore this component is attached to.
protected void resetErrorCount()
protected ExtendedLogger getLogger()
This logger always sends output to an ConsoleHandler,
which outputs to System.err
protected ExtendedLogger getNonFloodingLogger()
protected java.lang.String getProperty(java.lang.String propname,
java.lang.String defaultValue)
LogManager by name.
propname - of the parameter to be obtaineddefaultValue - if propname is not found.
protected int getProperty(java.lang.String propname,
int defaultValue)
LogManager by name.
propname - of the parameter to be obtaineddefaultValue - to return if no value has been found.
protected boolean getProperty(java.lang.String propname,
boolean defaultValue)
LogManager by name.
propname - of the parameter to be obtaineddefaultValue - to return if no value has been found.
protected abstract void appendLogRecord(ExtendedLogRecord record)
AbstractHandler should implement this method
to perform actual logging. See also publish(ExtendedLogRecord)
method.
record - to write to the log
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||