Class DelayedHandler
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,FlushableCloseable
- Author:
- James R. Perkins
-
Field Summary
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHandler(Handler handler) Add a sub-handler to this handler.Handler[]A convenience method to atomically get and clear all sub-handlers.final voidclose()Close all child handlers.protected voiddoPublish(ExtLogRecord record) Do the actual work of publication; the record will have been filtered already.final booleanIndicates whether or not this handler has been activated.booleanIndicates whether or not the formatter associated with this handler or a formatter from a child handler requires the caller to be calculated.voidremoveHandler(Handler handler) Remove a sub-handler from this handler.voidsetCallerCalculationRequired(boolean callerCalculationRequired) Sets whether or not caller information will be required when formatting records.Handler[]setHandlers(Handler[] newHandlers) A convenience method to atomically get and replace the sub-handler array.Methods inherited from class org.jboss.logmanager.ExtHandler
flush, getHandlers, isAutoFlush, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, reportError, reportError, setAutoFlush, setCloseChildren, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setLevelMethods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable
-
Constructor Details
-
DelayedHandler
public DelayedHandler() -
DelayedHandler
public DelayedHandler(int queueLimit)
-
-
Method Details
-
doPublish
Description copied from class:ExtHandlerDo the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if theautoFlushproperty is set totrue; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.- Overrides:
doPublishin classExtHandler- Parameters:
record- the log record to publish
-
close
Description copied from class:ExtHandlerClose all child handlers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classExtHandler- Throws:
SecurityException
-
addHandler
Add a sub-handler to this handler. Some handler types do not utilize sub-handlers.Note that once this is invoked the handler will be activated and the messages will no longer be queued. If more than one child handler is required the
setHandlers(Handler[])should be used.- Overrides:
addHandlerin classExtHandler- Parameters:
handler- the handler to add- Throws:
SecurityException- See Also:
-
setHandlers
A convenience method to atomically get and replace the sub-handler array.Note that once this is invoked the handler will be activated and the messages will no longer be queued.
- Overrides:
setHandlersin classExtHandler- Parameters:
newHandlers- the new sub-handlers- Returns:
- the old sub-handler array
- Throws:
SecurityException
-
removeHandler
Remove a sub-handler from this handler. Some handler types do not utilize sub-handlers.Note that if the last child handler is removed the handler will no longer be activated and the messages will again be queued.
- Overrides:
removeHandlerin classExtHandler- Parameters:
handler- the handler to remove- Throws:
SecurityException- See Also:
-
clearHandlers
A convenience method to atomically get and clear all sub-handlers.Note that once this is invoked the handler will no longer be activated and messages will again be queued.
- Overrides:
clearHandlersin classExtHandler- Returns:
- the old sub-handler array
- Throws:
SecurityException- See Also:
-
isCallerCalculationRequired
public boolean isCallerCalculationRequired()Indicates whether or not the formatter associated with this handler or a formatter from a child handler requires the caller to be calculated.Calculating the caller on a log record can be an expensive operation. Some handlers may be required to copy some data from the log record, but may not need the caller information. If the formatter is a
ExtFormattertheExtFormatter.isCallerCalculationRequired()is used to determine if calculation of the caller is required.This can be overridden to always require the caller calculation by setting the
setCallerCalculationRequired(boolean)value totrue.- Overrides:
isCallerCalculationRequiredin classExtHandler- Returns:
trueif the caller should be calculated, otherwisefalseif it can be skipped- See Also:
-
setCallerCalculationRequired
public void setCallerCalculationRequired(boolean callerCalculationRequired) Sets whether or not caller information will be required when formatting records.If set to
truethe caller information will be calculated for each record that is placed in the queue. A value offalsemeansExtHandler.isCallerCalculationRequired()will be used.Note that the caller information is only attempted to be calculated when the handler has not been activated. Once activated it's up to the children handlers to determine how the record is processed.
- Parameters:
callerCalculationRequired-trueif the caller information should always be calculated before the record is being placed in the queue
-
isActivated
public final boolean isActivated()Indicates whether or not this handler has been activated.- Returns:
trueif the handler has been activated, otherwisefalse
-