Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.management
Class Trace

    java.lang.Object
      |
      +--com.sun.management.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_CONNECTOR_HTML. Information from HTML connector.

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.

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:

- adding a listener with a filter in the code. It is possible to have more than one listeners but with different filters.
- specifying system properties in the command to start the Java interpreter when you run a class. In this case, the code of the class must include a call to the parseTraceProperties method of this class.

  To specifiy trace level, add -DLEVEL_TRACE or -DLEVEL_DEBUG to you command line. By default, the level is set to LEVEL_TRACE.

  To specifiy trace types, add the selected types to the command line as: -DINFO_MLET -DINFO_TIMER to select mlet and snmp information, it is possible to add more than one type. By default, the type is set to INFO_ALL.

  To specify output, add -DTRACE_OUTPUT=name_of_outfile to the command line, name_of_outfile is a file name to write message. By default, the message is written to screen.

  If at least of the three properties is specified in the command, all other which are not specified will be set to default value.

Field Summary
`static int` | `INFO_ALL` Information type defined to represent all types defined.
`static int` | `INFO_CONNECTOR_HTML` Information type defined for HTML connector information.
`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_MONITOR` Information type defined for Monitor information.
`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.
`static java.lang.String` | `getType(int type)`
`static boolean` | `isSelected(int level, int type)` Verify whether the specified info level and the info type are selected.
`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_CONNECTOR_HTML

    public static final int INFO_CONNECTOR_HTML

  Information type defined for HTML connector information.

### INFO_MISC

    public static final int INFO_MISC

  Information type defined for all other classes.

### 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.

  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 check of types or levels is failed or the trace is 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.
    `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.

### 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.

### getType

    public static java.lang.String getType(int type)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD