www.ibm.comLANDP Webpage

A LANDP SNA Application Using the LANDP Java Beans

This guide is intended to give you a basic understanding of how to use the LANDP JavaBeans to create a simple SNA application that enables us to read and send messages to a SNA Host. The difficulty level of this tutorial is advanced. We suggest you complete the LANDP MSRE Bean Tutorial before attempting this one.

Step 1: Creating a new Class

Create a new class for us to develop into our application. The name of the class will be SNASample, in a package called 'sna'. We shall continue to use the 'LANDP Beans' project that we created in the Supervisor Bean tutorial This class should be a subclass of 'javax.swing.JFrame'.

We need to import 'com.ibm.landp', 'com.ibm.landp.spv' and 'com.ibm.landp.sna', and use the 'com.ibm.landp.sna.LandpSNAConst' interface. If you can not remember how to do this, refer to the Supervisor Bean tutorial.

Step 2: Placing LANDP beans onto the workspace.

Step 3: Changing the type of the variables to HostMessage and HostSession.

Step 4: Initialising the Beans.

We must now add beans to our JFrame to allow us to read and write data. The following image shows the template we wish to create.

By using the component palette, place the appropriate beans onto your JFrame and set the 'text' property of each bean so that it matches the above template.

Note: If you can not remember how to do this, please refer to the Supervisor Bean tutorial where we added beans to a JFrame and set their text properties.

Now we have our Interface set up, we can start making connections between the visual beans and our LANDP beans.

Step 5: Connecting the WindowOpened Event

Connect the 'windowOpened' event of the JFrame to the 'register()' method of the RmtReq bean. This is so that we register the application with the Java Manager when it is run.

Step 6: Connecting the WindowClosing Event

Connect the 'windowClosing' event of the JFrame to the 'unregister()' method of the RmtReq bean. This is so that we deregister the application with the Java Manager when it is closed.

Step 7: Connecting the "Open Session" Button

Connect the 'Action Performed' event of the 'Open Session' button to the 'openSession()' method of the SNAServer Bean.

Notice that the line is dashed and incomplete. This is because 'openSession()' requires parameters and it is not complete until we supply these parameters.

Step 8: Connecting the openSession() Parameters

The application now has the capability to open a session with a SNA server. However we also need to be able to close sessions.

Step 9: Connecting the "Close Session" Button

Connect the 'Action Performed' event of the 'Close Session' button to the 'closeSession()' method of the SNAServer Bean.

Notice that the line is dashed and incomplete. This is because 'closeSession()' requires parameters and it is not complete until we supply these parameters.

Step 10: Connecting the closeSession() Parameters

Step 11: Connecting the "Get Session" Button

Connect the 'Action Performed' event of the 'Get Session' button to the 'getSession()' method of the SNAServer Bean.

Notice that the line is dashed and incomplete. This is because 'getSession()' requires parameters and it is not complete until we supply these parameters.

Step 12: Connecting the getSession() Parameters

When the getSession method is executed, a HostSession object is returned. As we need to make method calls to this object, the Host Session variable on the workspace shall act as a place holder for the object.

Next we must connect the 'Normal Result' event of the connection made in step 11 to the HostSession Variable.

Step 13: Connecting the Normal Result of the getSession() method.

Now every time the get session button is clicked, the HostSession variable will represent the required session. We have now completed connections to our SNAServer bean.

We have now completed connections to our SNAServer bean. Your screen should now look like the following image:

Step 14: Connecting the actionPerformed Event of the "Open LU" Button

Connect the 'actionPerformed' event of the 'Open LU' button to the 'openLU()' method of the HostSession object.

Notice that the line is dashed and incomplete. This is because 'openLU()' requires parameters and it is not complete until we supply these parameters.

Step 15: Connecting the openLU() Parameters

Step 16: Connecting the actionPerformed Event of the "Close LU" Button

Connect the 'actionPerformed' event of the 'Close LU' button to the 'closeLU()' method of the HostSession object.

Notice that the line is dashed and incomplete. This is because 'closeLU()' requires parameters and it is not complete until we supply these parameters.

Step 17: Connecting the closeLU() Parameters

At this stage, we now have an application that can open a session with a SNA server, and open an LU-LU connection using this Session. All that remains is for our application to be able to send and receive messages to our host application.

Step 18: Connecting the actionPerformed Event of the "Read Host" Button.

Connect the 'actionPerformed' event of the 'Read Host' button to the 'readHost()' method of the HostSession object.

This method returns a HostMessage object. We shall use the HostMessage variable to represent this message.

Step 19: Connecting the Normal Result of the readHost() method.

Connect the 'Normal Result' event of the connection made in step 18 to the HostMessage Variable.

The JTextArea labelled Message shall be used to display the result of a readHost command. To enable this we need to connect the text property of the HostMessage variable to the text property of the JTextArea.

Step 20: Connecting the HostMessage Text to the JTextArea

To enable this we need to connect the text property of the HostMessage variable to the text property of the JTextArea.

All that remains to complete our SNA application is the facility to send a message to the host application.

Step 21: Connecting the "Send Host" Button

Connect the 'actionPerformed' event of the 'Send Host' button to the 'HostMessage(String)' method of the HostMessage object.

Notice that the line is dashed and incomplete. This is because 'HostMessage(String)' requires a parameter and it is not complete until we supply this parameter.

Step 22: Connecting the HostMessage() Parameters.

This connection now constructs a new HostMessage object with the command specified in the Command text field every time we click send host. We now want to send this message to the application.

Step 23: Connecting the Normal Result of the sendHost() method.

Connect the 'Normal Result' event of the connection made in step 16 to the sendHost() method of the HostSession object.

The application is now complete. From the menu bar at the top of the screen, select Bean->Save Bean to save your work.

Introduction New to LANDP? Make the most of LANDP Solving LANDP problems Feedback