IBM Books

Host On-Demand J2EE Connector


Writing Your First Host On-Demand J2EE Connector Application

This section provides an overview of writing a Host On-Demand J2EE Connector application, with examples of sample code showing the flow of the use of Host On-Demand J2EE Connector classes.

Overview

To write an application that can be fully deployed to an application server, tools from VisualAge for Java Enterprise Edition should be used. VisualAge for Java contains Enterprise Access Builder tools. These tools should be used to generate Records, Commands, and Business Objects. In these, class names and specifications for connections and interactions are specified, along with other associated properties. The resulting output is then deployed to WebSphere Application Server. For specific details on this process, please refer to the specific product documents.

The following sample applications demonstrate the basic flow and logic for using some of the Host On-Demand J2EE Connector classes. This should be developed in VisualAge for Java Enterprise Edition, with the environment set to use Host On-Demand J2EE Connector development.

Sample applications are in \toolkit\connector2\samples\ directory. These samples can be imported into the Enterprise Edition of Visual Age for Java (VAJ) with HOD J2EE Connector support.

These sample applications go through a login and logout process, utilizing screen recognition. Because a user may be connecting to a different server or host, using different screens, these sample applications may not run properly, without modifications. However, from the TN3270 example, you should be able to see the commands, records, and navigational process visually, thus getting a better understanding of the requirements for writing Host On-Demand J2EE Connector applications.

Note: In this document, the terms host and server are meant to denote the same thing.

The steps below describe how to set up this sample in the VAJ environment (Note: VAJ may have this sample included as part of its HOD J2EE Connector feature):

  1. Add the following features to the project:
  2. If HOD Connector (not J2EE) is in the project, remove it.
  3. Add HOD J2EE Connector feature to the project.
  4. Import j2hod_vajsample.dat and select the J2EE HOD Connector Samples project from the samples directory. (The source code for this .dat file is also in the samples directory.) You will need to edit the LoginLogoutNavigator.getLogInCommand() method and specify your ID and Password to the TN3270 server.
  5. You may want to use the EAB Tools to edit each command and set the recognizeString property of J2HODInteractionSpec to blank, since your server may not have the same strings.
  6. Under the IBM Enterprise Access Builder Websphere Samples project, import the files in the ...\samples\com\ibm\ivj\eab\sample\ws\j2ee\servlet\ directory into the package. You will need to edit the LookupDeployerHelper.createBinding() method and specify your TN3270 server name and port number.
  7. Start the Websphere Test Environment Control Center; then:
    1. Start the Servlet Engine (after waiting until the Stop button is enabled).
    2. Start the Persistent Name Server (after waiting until the Stop button is enabled).
  8. Using your browser, connect to the following URL: http://localhost:8080/servlet/com.ibm.ivj.eab.sample.ws.j2ee.servlet.JNDIDeployer

    You should see a following message:

    ConnectionFactory added to the JNDI context as j2hod

  9. Now you are ready to test drive LoginLogoutNavigator. Set your class path to all projects, and run.
  10. Use a SmartGuide to add a servlet:
    1. Create Servlet window:
      1. Enter a class name (i.e. J2HODServlet)
      2. select Import Java bean
    2. On the Web Pages Configuration (1 of 2) window:
      1. Browse for LoginLogoutNavigator java bean class
      2. Select Use Create Servlet SmartGuide default Web resource path
      3. Select request in Scope.
    3. On the Web Pages Configuration (2 of 2) window:
      1. For Action methods to call ... add
        void execute()
    4. On the Attributes window, use default and click finish.
  11. Using your browser, connect to the following URL: http://localhost:8080/J2HODServletInput.html
  12. Click on a Submit button.
  13. Check the Console window for screen input and output.

The sample programs shown in the following two pages include the use of TN5250 sessions. Source code for these samples, and others, are included in the \toolkit\connector2\samples\ directory.

Note: These samples are tested and written based on a particular server. You will need to adjust some of the inputs and string recognitions to match your servers. It should be fairly easy to modify these samples for TN3270 and VT sessions ,so that they match your server environment. You can then have running samples.

The following steps outline what you will need to import into Visual Age for Java, and how to run these samples:

  1. Add the necessary features and projects to set up the Host On-Demand J2EE Connector environment in Visual Age for Java.
  2. Create a new project and import the following files:
  3. Go through each executable java file in the tn5250 package and set the classpath to all projects.
  4. Modify SERVER, USERID, and PASSWORD in the IBM5250Host java file to match your TN5250 server name, user ID, and password.
  5. To run JNDI samples:
    1. Start a WebSphere Test Environment Control Center, and start a Persistent Name Server, and wait until the Stop Name Server button is enabled.
    2. Run the J2HODFatClientJNDIDeployer class before running the J2HODFatClientJNDI sample class.

You are now ready to run all the samples.


[ Top of Page | Previous Page | Next Page | Table of Contents ]