(c)Copyright IBM Corp.,1999, 2005

NetView 3270 Management Console Help


Writing an HACL Application

IBM eNetwork Host-On-Demand provides a host access class library to enable users to write Java applications to automate NetView 3270 management console (NMC-3270) sessions. These automation applications can be used to interact with the NMC-3270-provided sessions for routine tasks. The automation applications can also be used from GEM or the NMC.

Providing a Host Access class library application for the NMC-3270 involves the following steps:

Refer to the IBM eNetwork Host Access Class Library (HACL) for more information.


Writing the Application

The Host Access Class Library (HACL) classes associated with a particular NetView session can be obtained from an instance of ECLSession.

To do this, the application must implement FLB_NVApplInterface. This interface provides the methods for passing the active session to the application which is done through the init method of the interface.

After getting a session object in the init method, you can gain access to the presentation space and interact with it. The presentation space is encapsulated in the ECLPS class, and an instance of it can be obtained using the GetPS() method on ECLSession. ECLPS provides methods that do the following:

The sample below gets an instance of ECLPS from the session described above.

public void init(ECLSession session)
   {
      ps = session.GetPS();  
      oia = session.GetOIA(); 
      
   }

Once an instance of ECLPS is established, you can register as a com.ibm.eNetwork.ECL.event.ECLPSListener to receive notification of presentation space changes. Registered listeners are notified whenever the presentation space is changed. This event notification model is the primary mechanism used by an application to drive interactions with the presentation space.

The sample code below registers the current class with the instance of ECLPS.

try { 
       ps.RegisterPSEvent(this); 
    }  catch(ECLErr e) { System.out.println(e.GetMsgText()); } 
 

Even though you are registered for presentation space events, you still need to implement com.ibm.eNetwork.ECL.event.ECLPSListener interface.

The ECLPSListener interface is comprised of three methods which handle different kinds of events occurring within the presentation space. The PSNotifyEvent() method handles normal, non-error events and is the main method for receiving and handling events. The PSNotifyStop() method handles stop events, and the PSNotifyError() method handles errors which occur during event generation.

The following sample defines a PSNotifyEvent() method which prints out screen updates.

public void PSNotifyEvent(ECLPSEvent evt)
 {
  try
   {
   char[] temp = new char[1921]; // Screen size is assumed to be 24x80
   ps.GetScreen(temp, 1920, 1, 1920, ps.TEXT_PLANE);
   System.out.println(new String(temp));
   ps.UnregisterPSEvent(this);
 
   }
  catch (Exception ECLErr)
   {
   System.out.println("ECLErr Exception --> " + ECLErr.toString());
   }

FLB_NVApplInterface also requires you to implement three other methods (addListener, removeListener, and closeDown). The closeDown method allows the application to listen for a closeDown event from the NMC-3270, and is triggered when the NMC-3270 is ready to close the session. The closeDown method allows the user to clean up before the session ends. The removeListener method stops the application from listening for closeDown events from the NMC-3270.

The following is a sample implementation:

public void addListener( FLB_NVApplListener listener ){
 
      this.listener  = listener ;
 
   }
public void closeDown(){
 
   //Your clean up code goes here.
 
   }
 
public void removeListener( FLB_NVApplListener listener ){
 
      this.listener = null;
 
   }
 

Finally, in order to notify the NMC-3270 of application termination code the following in your termination or finalize routine:

 listener.applClosing(this);

Building Host Access Class Library Applications

This section describes how to build a Java application which uses the Host Access Class Library (HACL). The source code preparation and compiling requirements are described.

Source Code Preparation

Programs that use HACL classes must import the HACL package to obtain class definitions and other compile-time information. The HACL package can be imported into a Java source file using the following statements:

import com.ibm.eNetwork.ECL.*;
import com.ibm.eNetwork.ECL.event.*;
import com.ibm.eNetwork.beans.HOD.*;
import src.ibmflb.*;
 

Compilation

To compile the new Java source file, the CLASSPATH must be updated to include the directory containing the HACL package. If HACL was installed in a Windows environment, the CLASSPATH should already be updated. If HACL was not installed in a Windows environment, you will have to either update the CLASSPATH environment variable manually or use the '-classpath' parameter of the Java compiler, javac, to specify the location of HACL.


Launching the HACL Application

The NetView 3270 management console provides two ways to load and run a user-defined application. A user application can be launched from the Execute HACL App dialog or as an Initial HACL App when a session is started. The Run Application dialog can be displayed from the toolbar. The dialog prompts for the name of a user-defined class (fully-qualified class name), constructs an instance of the class using the default constructor, and gives the class access to the current NetView session in the init method. If you do not know the class name you can use the find button to locate the class. In this instance the class will be freshly loaded. The Initial HACL App can be specified in the session configuration window.
Note:When an application that uses HACL is run, the directory containing the HACL package must be found in the path specified by the CLASSPATH environment variable.

Helper Class

The NetView 3270 management console provides a helper class to help an application writer get ECLSessions for various console sessions (for example, the hardware monitor, session monitor, and so on).

The following is a sample:

   ECLSession session = FLB_HACLhelper.getSession("NPDA");
   ECLPS ps = session.GetPS();  
   ECLOIA oia = session.GetOIA();       

Sample Applications

The following two sample applications are shipped with the NetView 3270 management console (in the examples subdirectory):


[ Top of Page | Table of Contents | Index ]