Clearing parameter values – HP NonStop G-Series User Manual
Page 90
![background image](/manuals/398286/90/background.png)
...
// Unsubscribe the HELLO event and unsolicited notification.
helloEvent.unsubscribe();
unsolEvent.unsubscribe();
}
}
Clearing Parameter Values
The Jolt Class Library includes a method (the clear method) that allows the developer to remove an object's existing attributes and in
effect provides for the reuse of the object. The reuseSample.java example illustrates how to use the clear method for clearing parameter
values.
The reuseSample.java example shows how to reuse the JoltRemoteService parameter values. The example shows that you do not have to
destroy the service to reuse it. Instead, the svc.clear(); statement is used to discard the existing input parameters before reusing the
addString method.
Example 6-12. Jolt Object Reuse (reuseSample.java)
/* Copyright 1996 BEA Systems, Inc. All Rights Reserved */
import java.net.*;
import java.io.*;
import bea.jolt.*;
/*
* This is a Jolt sample program that illustrates how to reuse the
* JoltRemoteService after each invocation.
*/
class reuseSample
{
private static JoltSession s_session;
static void init( String host, short port )
{
/* Prepare to connect to the TUXEDO domain. */
JoltSessionAttributes attr = new JoltSessionAttributes();
attr.setString(attr.APPADDRESS,"//"+ host+":" + port);
String username = null;
String userrole = "sw-developer";
String applpasswd = null;
String userpasswd = null;
/* Check what authentication level has been set. */
switch (attr.checkAuthenticationLevel())
{
case JoltSessionAttributes.NOAUTH:
break;
case JoltSessionAttributes.APPASSWORD:
applpasswd = "secret8";
break;
case JoltSessionAttributes.USRPASSWORD:
username = "myName";
userpasswd = "BEA#1";
applpasswd = "secret8";
break;
}
/* Logon now without any idle timeout (0). */
/* The network connection is retained until logoff. */
attr.setInt(attr.IDLETIMEOUT, 0);
s_session = new JoltSession(attr, username, userrole,
userpasswd, applpasswd);
}