The MAINVIEW Data Server uses a set of user-defined requests to identify the fields from various views of MAINVIEW products. Each field is associated with the recording exit that exports the data to wherever the user wants to store it. A couple of exit routines are provided by BMC Software with the release of the product, but it is expected that the users of the product will provide their own variations on these samples in order to meet their specific requirements.
For information about using of the ODBC sample exit, see Using the ODBC Sample Exit.
The MAINVIEW Data Server is written in Java. Some knowledge of Java is needed in order to modify the exits. In addition to the many books on Java that are available, documentation of the language can be found at developer.java.sun.com/developer/infodocs/.
The exits are written in a variant of Java called BeanShell. The full documentation of this language can be found at www.beanshell.org/docs.html . This section outlines the major differences from Java for the benefit of those familiar with Java.
A MAINVIEW Data Server exit is a BeanShell file stored in the Exits directory which implements the following methods. Any code not included in a method is executed each time the exit is prepared for use.
Declaration | Usage |
---|---|
String id() |
Returns the text string that is used to identify this exit in the setup screens.. |
boolean begin() |
Initialize a recording cycle for a view. If it returns false, the recording is cancelled. |
boolean record() |
Invoked once for each row of a view to be recorded. If it returns false, the recording is cancelled. |
boolean end() |
Invoked when all the rows that have been requested have been passed to the record() method. If it returns false, the recording is retried later. |
In each exit taken from MAINVIEW Data Server, a set of variables are predefined in the global scope. Which set of variables depends upon which exit is being taken.
These variables are the same in all exits.
Declaration | Usage |
---|---|
java.util.logging.Logger log |
Access to the MAINVIEW Data Server log. |
java.util.Hashtable anchor |
A common repository for items to be shared across exit invocations. All exits have access to the same "anchor" and can use the put(key,object) and get(key) methods to pass objects around. |
These variables are available in begin(), record(), and end() invocations.
Declaration | Usage |
---|---|
String context |
The name of the selected context defined in the MAINVIEW CASDEF. |
String system |
The name of the system from which the sample is being drawn. |
String server |
The name of the Product Address Space (PAS) providing the data. |
String product |
The name of the MAINVIEW product to which the view belongs. |
String view |
The name of the view being sampled. |
com.bmc.mainview.nvbapi.XML |
The internal definition of the view being sampled. It can be converted to a String by invoking viewDef.toString() |
java.util.Date time |
The date and time of the end of the interval. |
int duration |
The length of the interval in minutes. |
java.util.Vector fields |
A Vector of Strings giving the internal names of the fields that were requested. |
These variables are used to pass the data from each row.
Declaration | Usage |
---|---|
int row |
The current row number, starting with 1. |
java.util.Vector values |
Strings containing the values corresponding to the fields in the fields Vector. If it is a numeric field it has been reformatted to replace any scaling suffix such as "K" or "M" with the required number of zeros. |
java.util.Vector types |
Strings giving the field type. It may be one of the following:
|
The following code is a dummy exit which implements the required methods:
/* Sample recording exit for MAINVIEW Data Server This script is written for use with BeanShell, a Java interpreter. For documentation of Java see http://developer.java.sun.com/developer/infodocs/ For documentation of BeanShell see: http://www.beanshell.org/docs.html Items available from the caller: Logger log The product log service Hashtable anchor A common area for exits to store things */ // Identify this exit String id() { return "Dummy test exit"; } /* Begin recording data from one interval Items available for "begin", "record", and "end" String context The MAINVIEW Context (see CASDEF) String system The system where the product is running String server The product address space (PAS) String product The product that owns the view String view The view that provides the fields Date time The ending time of this interval Vector fields The names of the fields being recorded Note: All of the calls for a single interval will use the same data space. */ boolean begin() { log.info("Sample server entered to record view "+product+"."+view); return true; // Signal success } // Finish recording data from one interval boolean end() { return true; } /* Receive the data from one row of the view Items available for each call int row The row number starting with 1 Vector values The data values. Same size() as fields Vector types The data types: char, number, hex, date, or time */ boolean record() { return true; }