NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)

The JNI specifies an invocation API that native RISC programs written in C or C++ can use to invoke Java methods. The
invocation API includes facilities for starting a JVM, constructing Java objects, and invoking Java methods. This API is used
by programs that embed JVMs, such as Internet browsers and debuggers. The ServletServerClass (SSC) uses the
invocation API for iTP Secure WebServer integration.
The JNI also includes a set of APIs that native RISC programs use to interact with the JVM (for example, APIs to convert Java
Strings to C strings). NonStop
TM
Server for Java supports these APIs.
Return to top of Execution Scenarios.
Remote Method Invocation (RMI)
The Sun Microsystems Remote Method Invocation (RMI) API supports remote method invocation between Java peers or
between Java clients and Java servers. NonStop
TM
Server for Java fully supports this usage for RMI clients and servers.
RMI enables you to create distributed Java-to-Java programs, where the methods of remote Java objects can be invoked from
other Java virtual machines, possibly on different hosts. A Java program can call a remote object after it obtains a reference to
the remote object, either by finding the remote object in the bootstrap-naming service that RMI provides or by receiving the
reference as an argument or returned value. A client can call a remote object in a server, and that server can also be a client of
other remote objects.
The Standard Edition of JDK 1.2.2 includes the Sun Microsystems RMI API for homogeneous distributed objects. Use this
package for remote method invocation when you are certain that all distributed objects are defined in Java.
RMI requires that remote objects specify a SecurityManager class to implement a security policy for remote method
invocation. Sun Microsystems provides a default RMISecurityManager.
RMI clients, servers, tools, and naming services are supported in the standard manner.
RMI Example
To run a Java RMI example on any Java platform, follow these steps, replacing My_Server with the location of the registry
program and the server object:
1. Define the interface between the server and the client in RemOp.java:
package rmi1;
import java.rmi.*;
public interface RemOp extends Remote {
public void call() throws RemoteException;
public String getString() throws RemoteException;
public void sendString(String str) throws RemoteException;
public long doAdd(long a, int b) throws RemoteException;
}
2. Implement the defined interface in RemImpl.java:
package rmi1;
import java.rmi.*;
import java.rmi.server.*;
public class RemImpl extends UnicastRemoteObject implements RemOp {
public static void main(String[] args) {
try {
System.setSecurityManager(new RMISecurityManager());