|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jdmk.TraceListener
An object of this class can be used to receive notifications sent out by the class Trace, and all notifications received will be saved to a file specified, or write to user screen. This listener will print or save information with two formats:
(className methodName threadName timeStamp) Message. This is a default format
Global sequence number: 7 Sequence number: 3
Level: LEVEL_TRACE Type: INFO_CONNECTOR_RMI
Class Name: MBeanServer
Method Name: sendTraceInfo
Thread name: Thread-1 (the name of a thread which created this notification)
TimeStamp: dd:mm:ss:nn (the time when the notification was created)
Information: This is a example to send a trace information.
A user should call the method setFormated with the value "true" to select this format.
This class can be used as a default listener, a user can write his own listener to treat trace information the way he wants.
Field Summary | |
protected boolean |
formated
|
protected boolean |
needTobeClosed
|
protected PrintStream |
out
|
Constructor Summary | |
TraceListener()
Construct a default trace listener. |
|
TraceListener(PrintStream ps)
Construct a trace listener with a specified. |
|
TraceListener(String fileName)
Construct a trace listener with a file specified to save all information received. |
Method Summary | |
void |
handleNotification(Notification notif,
Object handback)
Called by the class Trace to receive trace information. |
void |
setFile(String fileName)
Specify a file to save information received |
void |
setFormated(boolean f)
Choose a format to output trace information. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected PrintStream out
protected boolean needTobeClosed
protected boolean formated
Constructor Detail |
public TraceListener()
public TraceListener(PrintStream ps) throws IllegalArgumentException
ps
- a PrintStream object used to print trace information.
For example, it can take value as System.out or System.err.
IllegalArgumentException
- thrown if the parameter ps is null.public TraceListener(String fileName) throws IOException
If specified file exists currently, all trace information will be appended to this file.
fileName
- the file used to save information.
IOException
- thrown if failed to open or to write the file.Method Detail |
public void setFormated(boolean f)
f
- if true, the full information will be printed out.public void handleNotification(Notification notif, Object handback)
handleNotification
in interface NotificationListener
notif
- The notification.handback
- An opaque object which helps the listener to associate information
regarding the MBean emitter. This object is passed to the MBean during the
addListener call and resent, without modification, to the listener. The MBean object
should not use or modify the object.public void setFile(String fileName) throws IOException
fileName
- the file used to save information. It will
replace the old file or the PrintStream object setted before.
IOException
- thrown if failed to open or to write the file.
|
JMX 1.2_8 2002.10.31_20:03:55_MET | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |