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



Appendix C

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]


Installing Java Action Server

To execute Java actions from Tango, you need to install and 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.


!Note: JAS requires that you have installed a Java virtual machine (VM), such as the one that comes with the Java Development Kit (JDK) 1.1 from Sun Microsystems (http://java.sun.com/).


When you install Tango Server, the following directory hierarchy is present in your destination folder:

java\com\everyware\tango\jas

Refer to your Java documentation for details on modifying your class path.

These directories have all of the files necessary to run the JAS. In order for the Java VM to find these files, you need to add this hierarchy to your Java class path. Using the Sun JDK on Windows NT, for example, you would:

  1. Open the System control panel.
  2. Click the Environment tab.
  3. Locate (or add) a variable called CLASSPATH.
  4. If your Tango installation is in Tango 3.0 (for example), add the following to CLASSPATH:

    C:\Tango 3.0\java

  5. Apply your changes and close the control panel.

    The Java server is run from the command line. Open a new DOS window (or shell on UNIX), and set the current directory to the jas directory. Then execute the following command:

    java com.everyware.tango.jas.JASMain

    On UNIX, you probably want to append an ampersand to cause the server to run in the background. You should now be able to use Tango to connect to JAS and execute Java class files. You can test your setup by running the JAStest.taf application file installed with Tango Server (/JavaDemo/JAStest.taf).

[top] [back to top]


Configuring JAS

There are several parameters that can be configured in the Java server to tune its performance. These parameters are passed on the command line, or provided in the JAS.properties file that resides in the same directory as the JASMain class file. All the parameters can be found by passing -help to JASMain, but the important ones are:

  • -port p

Listens on port p for requests from Tango (default is 4000).

  • -serversockettimeout s

Specifies the maximum number of seconds to wait for a request, after which JAS quits.

  • -actiontimeout s

Specifies the maximum number of seconds to wait for a class file to execute.

  • -trace

Logs detailed information on server activity for debugging.

[top] [back to top]


Creating Java Action Classes

A Java class or JavaBean that is specified in a Java action must extend the class com.everyware.tango.jas.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 Action class 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 in the jas directory, Hello.java and Echo.java, that illustrate using these methods. The JAStest.taf application file demonstrates using these classes in Tango.


!Note: When specifying the path to your class file in the Java action, you must use the Java "dot" notation (for example, com.everyware.tango.jas.Hello), and the path must be accessible from CLASSPATH.

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 © 1998, Pervasive Software Inc. All rights reserved.