Listing 5
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
// This class runs as server process for the remotable // TradingSystemImpl class
public class RMITradingSystem
{
protected TradingSystemImpl tradeStock = null;
public static void main(String [] args) {
try {
// Load the JNI C++ native code
System.loadLibrary("JNITradingSystem");
// Remaining work done in the constructor below
RMITradingSystem rmiTS = new RMITradingSystem();
}
catch ( Exception e ) {
e.printStackTrace();
}
}
public RMITradingSystem() {
try {
// Create a reference the Remotable class
tradeStock = new TradingSystemImpl();
// Register this class with the local RMI registry
Registry localRegistry =
LocateRegistry.getRegistry();
try {
localRegistry.bind( "TradingSystem", tradeStock );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}