![]() | The Java Developer's Guide to Eclipse |
In Chapter 28, Serviceability, you learned how to take advantage of the
service features in Eclipse to inform the user
of a problem, and if appropriate, log diagnosis
information. The features demonstrated
in this example include sending trace messages
to the console, error dialogs and logging
support. Below are those service items that
you'll see demonstrated in the example project
com.ibm.jdg2e.serviceability.
Trace_configuration.
Select Enable tracing for the selected plug-ins
and the com.ibm.jdg2e.serviceability options on the Tracing page
as shown below.

Let's explore the steps involved in creating this example.
Plugin.getLog().
To write to the log, use the method log(IStatus). See the ErrorDialogAction.run(IAction) method
for an example of writing to the Error Log.MultiStatus object which contains children.
Child Status objects are used to populate the details
section of the dialog. See the ServiceablePlugin.getServiceInfo() method
for an example of creating the MultiStatus and Status objects.The Workbench provides a mechanism for controlling
the generation of tracing information
of your plug-in at runtime with or without
a launch configuration. The
flags that plug-ins can query to determine the desired tracing information
are defined in files named .options.
The contents of the .options file also determines the choices
that are shown for your plug-in in the Tracing page of a launch configuration.
This file has the following syntax:
<plug-in-id>/debug = true|false (master switch) <plug-in-id>/<tracing flag> = <value>
The first entry represents the master switch
for tracing your plug-in. The
method isDebugging() of your plug-in class will return the value of this variable.
You can define other tracing flags
and retrieve their value using Platform.getDebugOption(optionName).
Most of the Workbench plug-ins define tracing flags, particularly the Platform
Core. For a new plug-in developer, one interesting set of tracing flags
are the org.eclipse.osgi options related to class loading for diagnosing plug-in
loading problems.
The key classes of the example are shown in the table below.
| Class (All) | Description |
ErrorDialogAction |
Triggers the error dialog and writes to the Error Log |
TraceAction |
Triggers the evaluation of the trace flags and writes to the system console |
ServiceablePlugin |
Plug-in singleton with helper methods to collect global plug-in diagnostics |
ServiceException |
Subclass of CoreException class |
© Copyright International Business Machines Corporation, 2003, 2004, 2006. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.