Defining a new recorder
To capture a new kind of data or an existing kind of data with a new recording technique, define a new recorder.
The only required task for a recorder is to capture data. The recorder does not start or configure a client. If you need to start a client or configure a client so that the client can be recorded by a recorder, see Defining a new client and Defining how a recorder can record a client.
To define a new recorder:
- Declare a new recorder type in the plugin.xml file. Use the
com.ibm.rational.test.lt.recorder.core.recorder
extension point. - Determine whether the recorder can be run locally, within the workbench, or if it must run remotely in a separate Java™ virtual machine (JVM).
- Define a delegate, which is the implementation class of the recorder. The delegate starts and stops the recorder, and captures data.
- If the recorder is remote, define a remote launcher implementation that provides details about the JVM that runs the delegate.
- Optionally, define a prerequisite validator that performs basic verification that the recorder can be run on the current computer.
- Declare which types of recorder packets are emitted by the recorder.
Follow these requirements for implementing the IRecorderDelegate
interface:
- This interface starts and stops the recorder and provides notification about events such as "recorder started," "recorder stopped," and "packet captured." You must provide an implementation of this interface. Optionally, a recorder can support being paused and resumed. If the recorder does not support pause and resume operations, ensure that the implementations of the methods are empty.
- Most methods are asynchronous. In other words, the framework does not require that the operation be completed when the method returns. For this reason, a recorder delegate must notify the framework when an operation is complete.
- A recorder can have a configuration. The configuration is built either by using a XML file with the .recconfig extension or by using a wizard. For an example of an XML file, open an existing recording session file, and then click . The configuration is stored in a RecorderConfiguration object, which is a map of strings to various types of objects. A recorder delegate reads its configuration in its initialize() method.
- A recorder delegate is given a context in its initialize() method. This context enables the recorder to send notifications of events, record log messages, and send captured packets.
- Typically, you extend the BaseRecorderDelegate class rather than
directly implement
IRecorderDelegate
interface. The base abstract class provides a basic behavior for most methods, so that you can override only those needed. - A recorder must use the getContext().packetCaptured() method to notify the framework when it has captured data.
- When a recorder constructs a packet, the packet must be filled with a recorder ID. The recorder ID is attributed by the framework and can be retrieved using the getContext().getComponentUniqueId() method.
- When a recorder constructs a packet, the packet must be filled with time information. The time information must be expressed in a unit that the framework defines. The current time, expressed in the framework units, can be retrieved using the getContext().currentTime() method.
- A recorder delegate can send messages to the user by invoking the sendUserMessage() method or the getContext().sendMessage(new UserMessage(...)) method if the delegate does not extend the BaseRecorderDelegate class.
- A recorder delegate can be enabled to communicate with outside entities by setting or retrieving dynamic properties or by receiving messages. A recorder delegate is useful only if you develop a specific UI for the recorder or if you define a client decorator for the recorder.