The common base event export service defines a set of APIs to export a set of common base events to various output formats such as XML, CSV, HTML, etc. Exporting a set of common base events follow a simple workflow:
The following code snippet illustrates this workflow and demonstrates how to export a set of common base events to a XML file.
1 |
TRCAgent agent = createAgent(); |
2 |
IOperationContext context = new OperationContextImpl(); OutputStream outputStream = new FileOutputStream(new File("MyFile.xml")); context.setProperty(IExportHandler.CONTEXT_OUTPUT_STREAM, outputStream); |
3 |
IExportHandler handler = new XMLExportHandler(); |
4 |
handler.exportLog(agent, context); |
5 |
if (context.getStatus().isOK()) System.out.println("Export successful!"); |
Each export handler will consume a certain data structure containing a set of common base events. For example, an export handler may consume a list of common base events, a TRCAgent object that contains a set of events, or a custom data structure. Consult the java doc for the export handler one is interested in to determine the data structure the export handler is expecting.
A context object must be created to contain the necessary data needed to export the common base event to an output format. At a minimum the context object must contain an output stream that the export handler will write to. Consult the java doc for the export handler one is interested in to determine any additional context data required to export the set of common base events. The java doc should list a set of context properties needed by the export handler.
The common base event export service provides a list of export handlers classes. Each of these classes implement the org.eclipse.tptp.monitoring.log.provisional.export.IExportHandler interface. A set of export handlers can be found under the org.eclipse.tptp.monitoring.log.provisional.export package.
The IExportHandler interface defines a simple API to export the common base events.
public abstract void exportLog(Object input, IOperationContext context);
The "input" parameter represents the data structure that contains the list of common base events. The context object contains context information needed by the export handler to complete the export operation.
Once the export has completed status information should be checked to make sure the export operation was successful. The status information is stored in a org.eclipse.tptp.platform.common.provisional.IOperationStatus instance which can be extracted from the context object.
(C) Copyright IBM Corporation 2000, 2008.