[TOC] [Prev] [Next] [Bottom]



Appendix B

Using Java With Tango


Java Actions and the Java Action Server

This appendix provides additional information on calling Java classes from Tango for use with the External action in Tango. This information is provided for those programmers who want to extend the functionality of Tango through the use of Java.

[top] [back to top]


Using Java Action Server

To execute Java actions from Tango, you need to run the Java Action Server (JAS). The JAS is a Java application that accepts requests from Tango to execute Java class files, and returns the results of that execution back to Tango. The JAS can run on the same machine as Tango, or it can run on another, network-accessible (via TCP/IP) machine.

When you install Tango Server components, the JAS is installed, by default, in the JAS folder within the Tango 2000 folder where Tango Editor is installed.

The JAS requires that you have installed Macintosh Runtime for Java (MRJ) 2.0 or greater. MRJ is provided in your Tango 2000 package; see the Getting Started Guide for details.

To use the Java Action Server

By default, these files are installed in the same folder as the JAS application.

  1. Make sure you have MRJ 2.0 or greater installed.
  2. Make sure the following files are located in the same folder:
    • the Java Action Server application
    • JAS.properties file
    • any Java class files or JavaBeans you want to execute.
  3. Double-click the JAS icon.

    The JAS should be running and visible in your Application menu.

About the JAS Test Application

To demonstrate how Tango executes Java actions, you can execute the JASTest.taf application file that is provided with Tango when you install Tango Demos and Tutorials. By default, JASTest.taf is installed in the Java folder inside the Demos folder within the Tango 2000 folder of your Web server document root.

Before you execute JASTest.taf, you must follow the steps below:

To run the JAS test application file

  1. In Tango Editor, open JASTest.taf.
  2. Open the External actions (Hello and Echo) within JASTest.taf.
  3. Enter the IP address of the Java Server into the Java Server field.
  4. Run the JAS by double-clicking the JAS icon.
  5. Execute JAStest.taf in your Web browser.

[top] [back to top]




Configuring JAS

There are several parameters that can be configured in the JAS. These parameters are set in the JAS.properties file that resides in the same folder as the JAS and are case-sensitive. The parameters are:

  • port. The server listens on this port for requests from Tango (default is 4000).
  • serverSocketTimeout. Specifies the maximum number of seconds to wait for a request, after which JAS quits. A value of 0 (the default) means that JAS never quits.
  • actionTimeout. Specifies the maximum number of seconds to wait for a class file to execute.
  • isTracing. Logs or does not log detailed information on server activity for debugging. Possible values are 1 (true) or 0 (false).
  • clientSocketTimeout. Sets the time out for a connected request, in seconds.
  • maxNumThreads. Sets the maximum number of concurrent requests that can be served.
  • maxNumBacklog. Sets the queue length of the server socket for incoming requests.
  • hostName. Sets the host to which the server socket is bound. If the computer running the JAS has multiple IP addresses, use this parameter to specify the one which the JAS should run on. The host name or IP address may be specified.

For advanced configuration of the JAS, read the JAS Read Me file in the JAS folder within the Tango 2000 folder where Tango Editor is installed.

[top] [back to top]


Creating Java Action Classes

A Java class or bean that is specified in a Java action must extend the class Action and provide an implementation for the customProcessing method:

public class Foo extends Action {
// provide an implementation of customProcessing
//to do the work
public void customProcessing(String argv[]) {
// do your stuff here...
}

}

The single String array parameter is the list of parameters that are specified in the Java action in the Tango application file. The class Action provides several methods that you would use in your action processing to provide result data to Tango. These methods are:

  • protected void setNumColumns(int)

Indicate the number of columns to be output in the class results.

  • protected void newRow()

Start a new row in the output.

  • protected void newColumn(String)

Start a new column in the current row containing the given String.

There are two example class files, Hello.java and Echo.java, in the folder that the JAS is in (by default, this is the JAS folder within the Tango 2000 folder of the drive where Tango Editor is installed) that illustrate using these methods.


! Note: When specifying the path to your class file in the Java action, you must use the Java “dot” notation starting at the location of the JAS (for example, com.pvsw.tango.jas.Hello) if the class file is in a folder called java inside the folder that the JAS is in the path would be java.Hello).

JavaBeans are loaded from their serialized form, so not only must you provide a class file but you must also have a .ser file for that class.




[TOC] [Prev] [Next] [Bottom]



docs@pervasive.com

Copyright © 1999, Pervasive Software. All rights reserved.