Class ExtHandler
java.lang.Object
java.util.logging.Handler
org.jboss.logmanager.ExtHandler
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable, FlushableCloseable, Protectable
- Direct Known Subclasses:
AsyncHandler, NullHandler, QueueHandler, SyslogHandler, WriterHandler
An extended logger handler. Use this class as a base class for log handlers which require
ExtLogRecord
instances.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final Permissionprivate static final ErrorManagerprivate booleanprivate final ThreadLocal<Boolean> protected Handler[]The sub-handlers for this handler.protected static final AtomicArray<ExtHandler, Handler> The atomic updater for thehandlersfield.private Objectprivate static final AtomicReferenceFieldUpdater<ExtHandler, Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static SecurityExceptionvoidaddHandler(Handler handler) Add a sub-handler to this handler.protected static voidDeprecated.protected static voidcheckAccess(ExtHandler handler) Check access.Handler[]A convenience method to atomically get and clear all sub-handlers.voidclose()Close all child handlers.final voidDisable previous access to the object for modifications on the current thread.protected voiddoPublish(ExtLogRecord record) Do the actual work of publication; the record will have been filtered already.final voidenableAccess(Object protectKey) Enable access to the object for modifications on the current thread.voidflush()Flush all child handlers.Handler[]Get a copy of the sub-handlers array.booleanDetermine if this handler will auto-flush.final booleanDetermine if the handler is enabled.final voidProtect this object from modifications.voidvoidpublish(ExtLogRecord record) Publish anExtLogRecord.voidremoveHandler(Handler handler) Remove a sub-handler from this handler.voidsetAutoFlush(boolean autoFlush) Change the autoflush setting for this handler.final voidsetEnabled(boolean enabled) Enables or disables the handler based on the value passed in.voidsetEncoding(String encoding) voidvoidvoidsetFormatter(Formatter newFormatter) Handler[]setHandlers(Handler[] newHandlers) A convenience method to atomically get and replace the sub-handler array.voidfinal voidAllows the object to be modified if theprotectionKeymatches the key used toprotectthe object.Methods inherited from class Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError
-
Field Details
-
CONTROL_PERMISSION
-
autoFlush
private volatile boolean autoFlush -
enabled
private volatile boolean enabled -
DEFAULT_ERROR_MANAGER
-
protectKey
-
granted
-
protectKeyUpdater
-
handlers
The sub-handlers for this handler. May only be updated using thehandlersUpdateratomic updater. The array instance should not be modified (treat as immutable). -
handlersUpdater
The atomic updater for thehandlersfield.
-
-
Constructor Details
-
ExtHandler
protected ExtHandler()Construct a new instance.
-
-
Method Details
-
publish
-
publish
Publish anExtLogRecord. The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here. TheExtHandleris responsible for formatting the message, when and if necessary. The formatting should include localization.- Parameters:
record- the log record to publish
-
doPublish
Do 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.- Parameters:
record- the log record to publish
-
addHandler
Add a sub-handler to this handler. Some handler types do not utilize sub-handlers.- Parameters:
handler- the handler to add- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
removeHandler
Remove a sub-handler from this handler. Some handler types do not utilize sub-handlers.- Parameters:
handler- the handler to remove- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
getHandlers
Get a copy of the sub-handlers array. Since the returned value is a copy, it may be freely modified.- Returns:
- a copy of the sub-handlers array
-
clearHandlers
A convenience method to atomically get and clear all sub-handlers.- Returns:
- the old sub-handler array
- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
setHandlers
A convenience method to atomically get and replace the sub-handler array.- Parameters:
newHandlers- the new sub-handlers- Returns:
- the old sub-handler array
- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
isAutoFlush
public boolean isAutoFlush()Determine if this handler will auto-flush.- Returns:
trueif auto-flush is enabled
-
setAutoFlush
Change the autoflush setting for this handler.- Parameters:
autoFlush-trueto automatically flush after each write; false otherwise- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
setEnabled
Enables or disables the handler based on the value passed in.- Parameters:
enabled-trueto enable the handler orfalseto disable the handler.- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
isEnabled
public final boolean isEnabled()Determine if the handler is enabled.- Returns:
trueif the handler is enabled, otherwisefalse.
-
protect
Description copied from interface:ProtectableProtect this object from modifications.- Specified by:
protectin interfaceProtectable- Parameters:
protectionKey- the key used to protect the object.- Throws:
SecurityException- if the object is already protected.
-
unprotect
Description copied from interface:ProtectableAllows the object to be modified if theprotectionKeymatches the key used toprotectthe object.- Specified by:
unprotectin interfaceProtectable- Parameters:
protectionKey- the key used to protect the object.- Throws:
SecurityException- if the object is protected and the key doesn't match.
-
enableAccess
Description copied from interface:ProtectableEnable access to the object for modifications on the current thread.- Specified by:
enableAccessin interfaceProtectable- Parameters:
protectKey- the key used toprotectmodifications.
-
disableAccess
public final void disableAccess()Description copied from interface:ProtectableDisable previous access to the object for modifications on the current thread.- Specified by:
disableAccessin interfaceProtectable
-
accessDenied
-
checkAccess
Deprecated.Check access.- Throws:
SecurityException- if a security manager is installed and the caller does not have the"control" LoggingPermission
-
checkAccess
Check access.- Parameters:
handler- the handler to check access on.- Throws:
SecurityException- if a security manager exists and if the caller does not haveLoggingPermission(control)or the handler isprotected.
-
flush
-
close
Close all child handlers.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classHandler- Throws:
SecurityException
-
setFormatter
- Overrides:
setFormatterin classHandler- Throws:
SecurityException
-
setFilter
- Overrides:
setFilterin classHandler- Throws:
SecurityException
-
setEncoding
- Overrides:
setEncodingin classHandler- Throws:
SecurityExceptionUnsupportedEncodingException
-
setErrorManager
- Overrides:
setErrorManagerin classHandler
-
setLevel
- Overrides:
setLevelin classHandler- Throws:
SecurityException
-
checkAccess(ExtHandler)