此内容没有您所选择的语言版本。
13.4.3. Object State Viewers (OSV)
When an object is selected in the Objects pane of the main window, the registered Object State Viewer (OSV) for the object's type is invoked. An OSV makes information about the selected object available via the user interface. An OSV for Atomic Actions (transactions) is distributed with the standard tools. It displays information on the Abstract Records in its lists of methods, such as heuristic, failed, read-only, and others. You can write your own OSVs to display information about object types you have defined.
13.4.3.1. Writing an OSV 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
You can write an OSV plug-in so that the Object Store browser can show the state of user-defined abstract records. An OSV plug-in is a class which implements the
com.arjuna.ats.tools.objectstorebrowser.stateviewers.StateViewerInterface
interface.
It must be packaged in a JAR within the
plugins/
directory. The example at Example 13.1, “AbstractRecord
Class” creates an OSV plugin for the AbstractRecord
class.
Example 13.1. AbstractRecord
Class
The goal is to show the current value of the abstract record when it is viewed in the object store browser. You can read the state into an instance of your abstract record, and call the
getValue()
method to accomplish this easily.
The
uidNodeExpanded
method is invoked when a Unique Identification (UID) representing the given type is expanded in the object store hierarchy tree. This abstract record is not visible in the object store directly. It is only viewable via one of the lists in an atomic action. The entrySelected
method is invoked when an entry is selected from the Object view, which represents an object with the given type. In both methods, the StatePanel is used to display information regarding the state of the object. The StatePanel includes the methods listed in StatePanel Methods to assist in display this information.
StatePanel Methods
setInfo
(Stringinfo
)- Shows general information.
setData
(Stringname
, Stringvalue
)- Puts information into the table which is displayed by the object store browser tool.
enableDetailsButton
(DetailsButtonListenerlistener
)- Enable the Details button. The listener interface allows a plug-in to be informed when the button is pressed. You, as the developer, control how to display this information.
In this example, the state is read from the object store and the value returned by the
getValue()
method is used to put an entry into the state panel table. The getType()
method returns the type of this plug-in for registration.
To add this plug-in to the object store browser, package it into a JAR file with a name that is prefixed with osbv-. The JAR file must contain certain information within the manifest file, to inform the object store browser which classes are plug-ins. Refer to Example 13.2, “Packing the Plug-In with Ant” to do this using an Apache Ant script.
Example 13.2. Packing the Plug-In with Ant
After you have created the JAR with the correct information in the manifest file, place it in the
bin/tools/plugins
directory.