Server Reference Guide : 8. Java Interface : Java Classes : Example
 
Share this page                  
Example
Following is an example of a Java interface.
Note:  This example assumes that the Server Manager has been used to create the AkaName “comtest” pointing to the non-ASOLib comtest.img application.
import com.ca.openroad.*;
 
class comtest 
    //
    // COMExceptions are allowed to escape.
    //
    public static void main(String[] args) throws COMException 
    //
    // The PDO and RSO are declared here so that they can be accessed
    // from both the try block and the finally block.
    //
    ParameterData pdo = null;
    RemoteServer  rso = null;
 
        try 
        //
    // Using the convenience constructor for the PDO.
    //
    pdo = new ParameterData("hellostring=STRING; counter=INTEGER");
        pdo.setString("hellostring", "Hello ASO, from Java!");
        pdo.setInt("counter", 99);
 
        rso = new RemoteServer();
        rso.connect("comtest", null, null);
 
        rso.callProc("helloworld", null, pdo);
 
        System.out.println(pdo.getString("hellostring"));
        System.out.println(pdo.getInt("counter"));
        rso.disconnect();
    
    finally 
        //
        // Not catching COMExceptions.  Just let them bubble up.
        // HOWEVER, we MUST ensure that the pdo.release() and rso.release()
        // get called regardless of exception exits.  That's why we need
        // to put those in a “finally” block.
        //
        if (pdo != null)
        pdo.release();
        if (rso != null)
        rso.release();