Reusing objects – HP NonStop G-Series User Manual

Page 91

Advertising
background image

public static void main( String args[] )
{
String host;
short port;
JoltRemoteService svc;

if (args.length != 2)
{
System.err.println("Usage: reuseSample host port");
System.exit(1);
}

/* Get the host name and port number for initialization. */
host = args[0];
port = (short)Integer.parseInt(args[1]);

init(host, port);

/* Get the object reference to the DELREC service. This
* service has no output parameters, but has only one input
* parameter.
*/
svc = new JoltRemoteService("DELREC", s_session);
try
{
/* Set input parameter REPNAME. */
svc.addString("REPNAME", "Record1");
svc.call(null);
/* Change the input parameter before reusing it */
svc.setString("REPNAME", "Record2");
svc.call(null);

/* Simply discard all input parameters */
svc.clear();
svc.addString("REPNAME", "Record3");
svc.call(null);
}

catch (ApplicationException e)
{
System.err.println("Service DELREC failed: "+
e.getMessage()+" "+ svc.getStringDef("MESSAGE", null));
}

/* Logoff now and get rid of the object. */
s_session.endSession();
}
}

Reusing Objects

The following extendSample.java example illustrates one way to subclass the JoltRemoteService class. In this case, a TransferService
class is created by subclassing the JoltRemoteService class. The TransferService class extends the JoltRemoteService class, adding a
Transfer feature which makes use of the TUXEDO bankapp funds TRANSFER service.

The example uses the "extends" mechanism from the Java language. The extend is used in Java to subclass a base (parent) class. The
following code shows only one of many different ways to extend from JoltRemoteService.

Example 6-13. Extending Jolt Remote Service (extendSample.java)

Advertising