JWAVE Server Development

JWAVE Server Overview


TIP: The JWAVE wrapper API functions are described in
Appendix A, JWAVE Wrapper API.

Writing JWAVE Wrapper Functions

Example: Simple JWAVE Wrapper

Example 5-1 Simple JWAVE wrapper function

The Input Parameter: client_data

The GETPARAM Function


NOTE: In other situations, it is necessary for GETPARAM to return more than the value. For instance, in many cases, the JWAVE wrapper function will be used to execute one or more PV-WAVE functions. Typically, this is accomplished with the PV-WAVE EXECUTE command, and parameters from the client that were unpacked by GETPARAM are used to "build" a string containing the command for EXECUTE. To facilitate these cases, GETPARAM can return a string that is formatted appropriately. For example, if the Positional keyword were used instead of Value, GETPARAM would return a string of the form: ", param_reference" (where param_reference is a symbolic reference to a value). The result could then be used directly in an EXECUTE statement. For example:

The RETURN Statement

Wrapper Functions Must Be Compiled


TIP: We have provided a set of routines that you can use to test your JWAVE wrapper functions before compiling them and publishing them on your Web server. See
Testing Wrapper Functions for more information.

Using GETPARAM to Unpack Parameters

What Do You Want To Unpack?

Unpacking Values


NOTE: client_data is the single parameter passed to a JWAVE wrapper function, as in: FUNCTION MY_WRAPPER, client_data

Using the Default Keyword

The Expect* Keywords

Unpacking Command Strings


NOTE: GETPARAM does not extract actual data from client_data; rather, it extracts a symbolic reference to data. The data that is referenced might have been sent by the client or retrieved from memory on the server. Therefore, the command:

Positional vs. Keyword Parameters

Unpacking Positional Parameters

Unpacking Keyword Parameters


NOTE: Again, remember that GETPARAM does not extract and return an actual value from client_data. Rather, the function builds a symbolic reference to a value into the string.

Building a PV-WAVE EXECUTE Command

Unpacking Color Data

Returning Multiple Results to the Client

Example 5-2 JWAVE wrapper function that returns multiple results to the client
Example 5-3 Client calls to unpack the associative array sent from the server.

Returning Graphical Data to the Client


NOTE: The client developer uses the
JWaveView class to request that the server return graphical data in addition to numerical data. Whenever JWaveView is used to execute a client request to the server, the server automatically creates a Viewable object. This object is then packaged and streamed back to the client where it can be displayed. If the client calls the wrapper with the JWaveExecute class, the graphics are discarded, and only the data are returned. For more information on JWaveView and graphics, see Chapter 4, JWAVE Graphics.
Example 5-4 Simple JWAVE wrapper that returns a 2D plot

NOTE: You must make sure that all coordinate system information is correct before you return a plot to the client. Also, note that the SURFACE and AXIS procedures create a temporary axis transformation that is not automatically saved by the PV-WAVE session. To ensure that the correct transformation and coordinate system information is sent back to the client, use the Save keyword with these procedures. This causes the correct transformation information to be sent automatically to the client. For more information on coordinate transformations, see
Coordinate System Transformations.

Example: A Typical JWAVE Wrapper


TIP: Refer to the PV-WAVE Reference for information on the EXECUTE, PLOT, and OPLOT commands. These PV-WAVE commands are used in the following example.
Example 5-5 JWAVE wrapper that unpacks positional and keyword parameters and builds a command string

Unpacking the Parameters


NOTE:
Parameter names are not case sensitive. They must begin with a letter, and can contain only alphanumeric characters and the underscore character (_).

NOTE: A client application that provides controls for generating and modifying the appearance of plots or other kinds of graphics probably needs to communicate positional and keyword parameter information to the server. The client user might use option menus to change the colors used in a plot, text fields to add plot titles, push buttons to add axes, and so on. The client developer must retrieve the parameter names and values from the user interface, package those parameters (with setParam and setNamedColor method calls), and send them to the server. As shown here, the JWAVE wrapper function then unpacks the parameters, generates the plot, and sends back a graphic for display on the client.

Unpacking Values

Unpacking Keywords


NOTE: The list of keywords given in this GETPARAM function example represents all of the keywords that can be extracted. Any keywords in the list that are not sent by the client are simply ignored by GETPARAM. If no keywords are sent, this GETPARAM function would return a null (empty) string.

TIP: We recommend that you use a string array (as was done in this example) to specify which keywords you wish to retrieve with GETPARAM. By specifying a string of names in GETPARAM, rather than using the /All keyword, you prevent your program from failing if the client sends unexpected information.

Unpacking Positional Parameters

Unpacking Color Information with GET_NAMED_COLOR


TIP: For more information on JWAVE graphics and color parameters, see
Chapter 4, JWAVE Graphics. See also Managing the Color Table on page A-18.
Example 5-6 JWAVE wrapper calls retrieve colors sent from the client.

TIP: The following lines show the corresponding calls that were made in the Java client program to set the colors retrieved in
Example 5-6:

The RETURN Statement

You Can Only Retrieve Parameters Once


TIP: You can use the Ignore_Used keyword with GETPARAM to request that all requested parameters will be returned whether they have been used or not.

Error Handling

Using the MESSAGE Procedure

Trapping Errors

Using the Expect Keywords

Type Code Data Type
1 Byte
2 Integer
3 Longword integer
4 Floating point
5 Double precision floating
7 String

Testing Wrapper Functions

Testing a Numerical Program

Testing a Graphics Program

Summary





Copyright © 1999, Visual Numerics, Inc. All rights reserved.