|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.logging.Handler
bb.util.logging.HandlerAbstract
public abstract class HandlerAbstract
Abstract subclass of Handler
which makes it easier to write further subclasses.
The chief reason why this class was written is because Sun annoyingly hid key functionality for Handler subclasses.
First, from ConsoleHandler
, this class copied and modified configure
.
Second, from LogManager
, this class copied and modified some code, which it exposes in the following methods:
getLevelProperty
, getFilterProperty
, getFormatterProperty
, getStringProperty
.
These methods are needed by configure.
Also to support configure, this class introduces the methods
getEncodingDefault
, getFilterDefault
,
getFormatterDefault
, and getLevelDefault
.
This class introduces a new field, alive
, along with accessor (isAlive
) and mutator (setAlive
) methods for it.
This field is used by close
, which this class overrides from its superclass (Handler).
Also, this class overrides isLoggable
, since its superclass method does not detect null record params.
It is unclear whether or not this class is multithread safe. This is because it is unclear whether or not its superclass, Handler, is multithread safe: its javadocs do not mention thread safety, and Sun's source code is bizarre (as of JDK 1.6.0_11, two of Handler's methods are synchronized, but many others are not even tho they involve shared mutable state). There exists a bug report with Sun on this matter (status as of 2009-03-23: "Your report has been assigned an internal review ID of 1484784, which is NOT visible on the Sun Developer Network (SDN).") Every method added by this class is synchronized.
Nested Class Summary | |
---|---|
static class |
HandlerAbstract.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private boolean |
alive
Records whether or not this instance is considered alive. |
Constructor Summary | |
---|---|
HandlerAbstract()
Constructor. |
Method Summary | |
---|---|
void |
close()
If isAlive returns true,
then calls super.close before calling . |
protected void |
configure()
Initializes an instance using the following LogManager configuration properties:
className.encoding the name of the character set encoding to use (default: getEncodingDefault )
className.filter specifies the name of a Filter class to use (default: getFilterDefault )
className.formatter specifies the name of a Formatter class to use (default: getFormatterDefault )
className.level specifies the default level for the Handler (default: getLevelDefault )
If any property is not defined (or has an invalid value) then the specified default value is used. |
protected String |
getEncodingDefault()
Returns the default value to use for the encoding . |
protected Filter |
getFilterDefault()
Returns the default value to use for the filter . |
protected Filter |
getFilterProperty(String name,
Filter defaultValue)
|
protected Formatter |
getFormatterDefault()
Returns the default value to use for the formatter . |
protected Formatter |
getFormatterProperty(String name,
Formatter defaultValue)
|
protected int |
getIntProperty(String name,
int defaultValue)
|
protected Level |
getLevelDefault()
Returns the default value to use for the level . |
protected Level |
getLevelProperty(String name,
Level defaultValue)
|
protected String |
getStringProperty(String name,
String defaultValue)
|
protected boolean |
isAlive()
Accessor for alive . |
boolean |
isLoggable(LogRecord record)
If record is null, immediately returns false., Otherwise, returns . |
protected void |
setAlive(boolean alive)
Mutator for alive . |
Methods inherited from class java.util.logging.Handler |
---|
flush, getEncoding, getErrorManager, getFilter, getFormatter, getLevel, publish, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private boolean alive
close
is first called.
Constructor Detail |
---|
public HandlerAbstract()
Method Detail |
---|
protected void configure() throws RuntimeException
LogManager
configuration properties:
className.encoding
the name of the character set encoding to use (default: getEncodingDefault
)className.filter
specifies the name of a Filter class to use (default: getFilterDefault
)className.formatter
specifies the name of a Formatter class to use (default: getFormatterDefault
)className.level
specifies the default level for the Handler (default: getLevelDefault
)
RuntimeException
- (or some subclass) if any problem occursprotected String getEncodingDefault()
encoding
.
This method is called by configure()
.
Implementation here returns null (which means use the platform default).
protected Filter getFilterDefault()
filter
.
This method is called by configure()
.
Implementation here returns null (which means use no Filter).
protected Formatter getFormatterDefault()
formatter
.
This method is called by configure()
.
Implementation here returns a new FormatterShort
instance.
protected Level getLevelDefault()
level
.
This method is called by configure()
.
Implementation here returns Level.INFO
.
protected Level getLevelProperty(String name, Level defaultValue)
protected Filter getFilterProperty(String name, Filter defaultValue)
protected Formatter getFormatterProperty(String name, Formatter defaultValue)
protected String getStringProperty(String name, String defaultValue)
protected int getIntProperty(String name, int defaultValue)
protected boolean isAlive()
alive
.
protected void setAlive(boolean alive)
alive
.
public void close()
isAlive
returns true,
then calls super.close
before calling setAlive
(false)
.
close
in class Handler
public boolean isLoggable(LogRecord record)
super.isLoggable
(record)
.
isLoggable
in class Handler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |