JBoss LogManager 1.1.0.CR6

org.jboss.logmanager
Class ExtHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by org.jboss.logmanager.ExtHandler
All Implemented Interfaces:
Flushable
Direct Known Subclasses:
AsyncHandler, NullHandler, WriterHandler

public abstract class ExtHandler
extends Handler
implements Flushable

An extended logger handler. Use this class as a base class for log handlers which require ExtLogRecord instances.


Field Summary
protected  Handler[] handlers
          The sub-handlers for this handler.
protected static org.jboss.logmanager.AtomicArray<ExtHandler,Handler> handlersUpdater
          The atomic updater for the handlers field.
 
Constructor Summary
ExtHandler()
           
 
Method Summary
 void addHandler(Handler handler)
          Add a sub-handler to this handler.
protected static void checkAccess()
          Check access.
 Handler[] clearHandlers()
          A convenience method to atomically get and clear all sub-handlers.
protected  void doPublish(ExtLogRecord record)
          Do the actual work of publication; the record will have been filtered already.
 Handler[] getHandlers()
          Get a copy of the sub-handlers array.
 boolean isAutoFlush()
          Determine if this handler will auto-flush.
 void publish(ExtLogRecord record)
          Publish an ExtLogRecord.
 void publish(LogRecord record)
          
 void removeHandler(Handler handler)
          Remove a sub-handler from this handler.
 void setAutoFlush(boolean autoFlush)
          Change the autoflush setting for this handler.
 Handler[] setHandlers(Handler[] newHandlers)
          A convenience method to atomically get and replace the sub-handler array.
 
Methods inherited from class java.util.logging.Handler
close, flush, getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.Flushable
flush
 

Field Detail

handlers

protected volatile Handler[] handlers
The sub-handlers for this handler. May only be updated using the handlersUpdater atomic updater. The array instance should not be modified (treat as immutable).


handlersUpdater

protected static final org.jboss.logmanager.AtomicArray<ExtHandler,Handler> handlersUpdater
The atomic updater for the handlers field.

Constructor Detail

ExtHandler

public ExtHandler()
Method Detail

publish

public final void publish(LogRecord record)

Specified by:
publish in class Handler

publish

public final void publish(ExtLogRecord record)
Publish an ExtLogRecord.

The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.

The ExtHandler is responsible for formatting the message, when and if necessary. The formatting should include localization.

Parameters:
record - the log record to publish

doPublish

protected void doPublish(ExtLogRecord record)
Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if the autoFlush property is set to true; 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

public void addHandler(Handler handler)
                throws SecurityException
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 have LoggingPermission(control)

removeHandler

public void removeHandler(Handler handler)
                   throws SecurityException
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 have LoggingPermission(control)

getHandlers

public Handler[] 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

public Handler[] clearHandlers()
                        throws SecurityException
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 have LoggingPermission(control)

setHandlers

public Handler[] setHandlers(Handler[] newHandlers)
                      throws SecurityException
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 have LoggingPermission(control)

isAutoFlush

public boolean isAutoFlush()
Determine if this handler will auto-flush.

Returns:
true if auto-flush is enabled

setAutoFlush

public void setAutoFlush(boolean autoFlush)
                  throws SecurityException
Change the autoflush setting for this handler.

Parameters:
autoFlush - true to automatically flush after each write; false otherwise
Throws:
SecurityException - if a security manager exists and if the caller does not have LoggingPermission(control)

checkAccess

protected static void checkAccess()
                           throws SecurityException
Check access.

Throws:
SecurityException - if a security manager is installed and the caller does not have the "control" LoggingPermission

JBoss LogManager 1.1.0.CR6

Copyright © 2009 JBoss, a division of Red Hat, Inc.