LANDP Java Beans - Supervisor
Introduction
This tutorial shows you how to use the LANDP JavaBeans to construct a
simple supervisor application that executes an 'SI' function call to determine
what is loaded in your LANDP Workgroup.
Customising a Suitable LANDP Client
The Supervisor server is present on all LANDP workstations and requires no
common definitions. The LANDP Java Manager server will be used in this
tutorial, although it is only required if you are running multiple
client applications on the same JVM.
Create a workgroup directory in EHCCUS called LDPBEANS,
and in it place the LANCONF.SPC file
containing the following vectors:
LANCONF  |
NAME=LDPBEANS,
WSNAMES=JB
|
LWSCONF |
NAME=JB,
TYPE=NT,
SERVER=JAVA,
PAR&JAVA=(Y,,,,)
|
The next step is to validate these configuration
files, then distribute the LANDP runtime files.
The LANDP distribution stage is described in detail in part 4 of the
LANDP Installation and Customization manual
Creating the Java Client Application
First you must create a new class that you develop into your application.
Before you begin, make sure you have imported the LANDP Java Beans
into the Visual Age environment.
- From the menu bar at the top of the screen, select File->Quick Start.

- In the dialog box that appears, select the option to create a class.

- Choose 'LANDP Beans' as the Project Name.
- Enter 'supervisor' as the package name. The superclass for the application will be 'javax.swing.JFrame'. The name of our class is 'SPVSample'.
- Choose to 'Browse the class when finished' & 'Compose class visually'. Click Next to be taken to a new page.

- In the first box, you are asked what import statements you require. Choose to 'Add a package'. Select 'com.ibm.landp' and 'com.ibm.landp.spv' because these contain the methods we want to use in our application.
- In the second box, enter the names of the Interfaces that are to be implemented. Browse for 'com.ibm.landp.spv.LandpSPVConst'.
- Click Finish. You are now presented with a new window. You can now start placing the beans and buttons onto the workspace, and building connections for your application.
Next place a Supervisor and a RmtReq bean onto the workspace.

- In the component palette, choose the LANDP category from the drop down list.
- Choose the Supervisor bean.
- Move the cursor onto a free area of the workspace, and click the left mouse button. The icon representing the bean should appear.
- Repeat the previous two steps for the RmtReq bean.
Now you must initialise the beans.
- Open the property sheet for the RmtReq Bean by clicking the icon twice.

- For the field labelled 'mode', select MODE_OWN_PID and close the property sheet.
- Right click on the RmtReq bean and select Connect -> this from the dialog box.
- Move the cursor over the Supervisor bean and click the left mouse button once.
- Select Connectable Features and the following dialogue box will appear.

Now add three Buttons to our JFrame to issue the LANDP commands.
- In the component palette, choose the 'Swing' category from the drop down list.
- Select a JButton Bean.
- Move the cursor over the window and single click the left mouse button. A JButton bean should now appear.
- Repeat the previous steps to add 2 more buttons.
Now change the text of these buttons to the functions you want to perform.
- Double click the left mouse button on JButton1. A properties sheet should appear.

- Find the field labelled 'text'. Change the value of this field to 'Connect'.
- Click on JButton2 in the JFrame. The property sheet should now refer to this bean.
- Find the field labelled 'text'. Change the value of this field to 'System Status'.
- Click on JButton3 in the JFrame. Change the 'text' property to 'Disconnect'.
- Close the property sheet by clicking the 'x' in the top right corner.

Our Interface is now complete. Now we need to add connection between the beans so that they perform functions when a button is clicked.
You must create two connections needed to register and unregister the application with the Java Manager.
First we shall make the connection that registers with the Java Manager.
- Select the JFrame by clicking on the title bar
- Single Click the right mouse button.
- From the pop up Menu select 'Connect', then the 'windowOpened' event.
- Move the cursor over the RmtReq bean and single click the left mouse button.
- Choose 'register()' from the pop up menu.
Now we shall make a connection that unregisters the application.
- Select the JFrame by clicking on the title bar
- Single Click the right mouse button.
- From the pop up Menu select 'Connect', then 'Connectable Features'....

- Select the 'windowClosing' event and click 'OK'.
- Move the cursor over the RmtReq bean and single click the left mouse button.
- Choose 'unregister()' from the pop up menu.
You now need to connect the 'actionPerformed' event of the 'Connect' Button to
the 'connect' method of the Supervisor Bean.
- Right click on the 'Connect' button.
- Select 'Connect->actionPerformed' from the pop up menu.
- Move the cursor over the Supervisor bean and click the left mouse button.
- Select the 'connect()' method.
- Repeat the above to connect the 'actionPerformed' event of the 'Disconnect' Button
to the 'disconnect()' method of the Supervisor Bean.
Next you need to connect the 'actionPerformed' event of the 'System Status' Button
to the 'systemStatus()' method of the Supervisor Bean and display the results to Standard Out.
This is performed as follows:
- Connect the 'actionPerformed' event to the 'systemStatus()' method of the Supervisor Bean
in the same way as you did for the connect and disconnect buttons.
- Right click the mouse button on this new connection.
- Select 'Connect->Normal Result' from the pop up menu.
- Move the cursor over to a free part of the workspace and single left click.
Chose 'Event to Code' from the pop-up menu.
We now need to write the method to format the result of the systemStatus call. The
following example shows how to format the result into a tabular format and then print
to standard out.

- Enter the this code into the coding
area of the pop up window. Remember to change the method's parameter name to
'systemStatus' as shown in the image.
- Click 'OK'.
The application is now complete.
From the menu bar at the top of the screen, select Bean->Save Bean to
save your work.
Testing the Application
To test the class you have created you should export it from the Visual Age environment
and run it from within the LANDP environment.
- Click on the 'Hierarchy' tab on the workspace.
- Right click the 'SPVSample' class at the bottom of the heirarchy.
- Select 'export' from the menu that appears. And choose to export to a jar file.

- Select your LANDP workstation directory as the destination for the jar file and click 'Finish'.
The class has now been exported. You also need to copy the LDPBEANS.JAR file from the LANDP install directory
into the same location as your jar file.
Use a command prompt to start LANDP, and run the supervisor application with the following command.
You need to have the java executable on your path.
java -classpath supervisor.jar;LDPBEANS.JAR supervisor.SPVSample
A window should open on the screen. Press 'Connect' to connect to the Supervisor.
Pressing 'System Status' will display the currently running LANDP processes in the
command prompt. Press 'Disconnect' and close the window to exit gracefully from the client.