com.sun.management.jmx
Class Trace

java.lang.Object
  |
  +--com.sun.management.jmx.Trace

public class Trace
extends java.lang.Object

This class is a static class and is used to get JMX internal runtime information.

Two levels of information can be specified:

1) trace. It provides information to tell what JMX is doing, this information is used to help a user to develop a JMX application.

2) debug. It provides information to help a JMX developper to diagnose the JMX implementation.

A user can specify information types to select information. The following types are specified:

1) INFO_ADAPTOR_HTML Information from HTML adaptor.

2) INFO_MBEANSERVER. Information from a MBean Server.

3) INFO_MLET. Information from a MLet service.

4) INFO_MONITOR. Information from a Monitor.

5) INFO_TIMER. Information from a Timer.

6) INFO_MISC. Information from all other classes except those specified types.

7) INFO_ALL. Information from all classes.

8) INFO_RELATION. Information from Relation Service.

8) INFO_MODELMBEAN. Information from the Model MBean components.

This class uses notification machanism to distribute the information. To register a listener, a TraceFilter object should be provided to do filtering. There are two ways to receive trace information:


Field Summary
static int INFO_ADAPTOR_HTML
          Information type defined for HTML adaptor information.
static int INFO_ALL
          Information type defined to represent all types defined.
static int INFO_MBEANSERVER
          Information type defined for MBean Server information.
static int INFO_MISC
          Information type defined for all other classes.
static int INFO_MLET
          Information type defined for MLet service information.
static int INFO_MODELMBEAN
          Information type defined for Model MBean
static int INFO_MONITOR
          Information type defined for Monitor information.
static int INFO_RELATION
          Information type defined for Relation Service.
static int INFO_TIMER
          Information type defined for Timer information.
static int LEVEL_DEBUG
          Information level defined for debug level.
static int LEVEL_TRACE
          Information level defined for trace level.
protected static java.lang.String UNKOWNTYPE
           
 
Constructor Summary
Trace()
           
 
Method Summary
static void addNotificationListener(NotificationListener listener, NotificationFilter f, java.lang.Object handback)
          Add a listener with filtering conditions
static void addNotificationListener(TraceListener listener, java.lang.Object handback)
          Add a listener with default filtering conditions: all types but only trace level are selected.
protected static java.lang.String getRIType(int type)
           
static boolean isSelected(int level, int type)
          Verify whether the specified info level and the info type are selected by a listener.
static void parseTraceProperties()
          Parses the system properties specified at the command-line to determine the specified trace conditions
static void removeAllListeners()
          Remove all listeners.
static void removeNotificationListener(NotificationListener listener)
          Remove a listener
static boolean send(int level, int type, java.lang.String className, java.lang.String methodName, java.lang.String info)
          Send a new information to this Trace class
static boolean send(int level, int type, java.lang.String className, java.lang.String methodName, java.lang.Throwable exception)
          Send an exception to this Trace class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEVEL_TRACE

public static final int LEVEL_TRACE
Information level defined for trace level. The formation will be provided to help development of JDMK applications.

LEVEL_DEBUG

public static final int LEVEL_DEBUG
Information level defined for debug level. The formation will be provided to help diagnosy. Selecting this level will result to select the LEVEL_TRACE too.

INFO_MBEANSERVER

public static final int INFO_MBEANSERVER
Information type defined for MBean Server information.

INFO_MLET

public static final int INFO_MLET
Information type defined for MLet service information.

INFO_MONITOR

public static final int INFO_MONITOR
Information type defined for Monitor information.

INFO_TIMER

public static final int INFO_TIMER
Information type defined for Timer information.

INFO_ADAPTOR_HTML

public static final int INFO_ADAPTOR_HTML
Information type defined for HTML adaptor information.

INFO_MISC

public static final int INFO_MISC
Information type defined for all other classes.

INFO_RELATION

public static final int INFO_RELATION
Information type defined for Relation Service.

INFO_MODELMBEAN

public static final int INFO_MODELMBEAN
Information type defined for Model MBean

INFO_ALL

public static int INFO_ALL
Information type defined to represent all types defined.

UNKOWNTYPE

protected static final java.lang.String UNKOWNTYPE
Constructor Detail

Trace

public Trace()
Method Detail

isSelected

public static boolean isSelected(int level,
                                 int type)
Verify whether the specified info level and the info type are selected by a listener.

It is strongly recommanded to call this method before sending an information to this Trace class.

Parameters:
level - the level of trace information.
type - the type of the trace information.

parseTraceProperties

public static void parseTraceProperties()
                                 throws java.io.IOException
Parses the system properties specified at the command-line to determine the specified trace conditions

send

public static boolean send(int level,
                           int type,
                           java.lang.String className,
                           java.lang.String methodName,
                           java.lang.String info)
Send a new information to this Trace class
Parameters:
level - the level of trace information to be sent.
type - the type of trace information to be sent.
className - the name of the class from which the trace information is from.
methodName - the name of the method from which the trace information is from.
info - the trace information to be sent.
Returns:
false if the level and the type are not selected.

send

public static boolean send(int level,
                           int type,
                           java.lang.String className,
                           java.lang.String methodName,
                           java.lang.Throwable exception)
Send an exception to this Trace class.
Parameters:
level - the level of trace information to be sent.
type - the type of trace information to be sent.
className - the name of the class from which the trace information is from.
methodName - the name of the method from which the trace information is from.
exception - exception sent as the trace information.

addNotificationListener

public static void addNotificationListener(NotificationListener listener,
                                           NotificationFilter f,
                                           java.lang.Object handback)
                                    throws java.lang.IllegalArgumentException
Add a listener with filtering conditions
Parameters:
listener - the listener to be added to receive trace notification.
f - the filter used to select a trace notification. This filter should be an instance of the class TraceFilter or its sub-class. If the filter is set to null all trace information with any type and any level will be send to the listener.
handback - the object sent back to listener.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified filter is not an instance of the class TraceFilter or its sub-classes, or no listener is specified.

addNotificationListener

public static void addNotificationListener(TraceListener listener,
                                           java.lang.Object handback)
                                    throws java.lang.IllegalArgumentException
Add a listener with default filtering conditions: all types but only trace level are selected.
Parameters:
listener - the listener to be added to receive trace notification.
handback - the object will send back to listener.
Throws:
java.lang.IllegalArgumentException - Thrown if the listener is null.

removeNotificationListener

public static void removeNotificationListener(NotificationListener listener)
Remove a listener
Parameters:
listener - the listener to be removed.

removeAllListeners

public static void removeAllListeners()
Remove all listeners.

getRIType

protected static java.lang.String getRIType(int type)