1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

// // // // // //

This class implements the remote interface for use as an RMI remote object. It supports multiple users by using an array of the 'connectPSE' connection object, which contains the logic for database assess and data retrieval. The separate interface class defines those methods which are available to the client (with no programming logic).

import java.util.*; import java.rmi.*; import COM.odi.*;

//for Vector

//ObjectStore PSE classes

public class remotePSE extends UnicastRemoteObject implements interfacePSE {

private connectPSE PSEthread[] = new connectPSE[5];
Thread mainThread;

public remotePSE() throws RemoteException {}

public void setMainThread(Thread thread) {

// default constructor

// // //

Initialize PSE with the main RMI Server thread - all cooperating threads must subsequently call
ObjectStore.initialize(mainThread)

mainThread = thread;
ObjectStore.initialize(null, null);

Create the remote threads to be used by client

}

//

public int openDatabase() throws RemoteException {

int connectionID;
synchronized(PSEthread) {

for (connectionID=0; connectionID < threads.length; connectionID++) {

if (PSEthread[connectionID] == null) break;
}
if (connectionID >= PSEthread.length) {

return -1;//Out of connections
}
PSEthread[connectionID] = new connectPSE(mainThread);
}

PSEthread[connectionID].start(); PSEthread[connectionID].openDatabase(); return connectionID;

}

public Vector getMoleculeList(int id) throws RemoteException {

return PSEthread[id].getMoleculeList();
}
public molData getData(int id, String molName) throws RemoteException {

return PSEthread[id].getData(molName);

} }

Fig 13. Java Code for the Remote Object