[kaffe] [Fwd: Kaffe Bug RMI]
Hervé Roussain
Herve.Roussain@univ-ubs.fr
Tue Aug 19 08:05:03 2003
--=-Exorqpj09ROLF90Fp9RX
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by vohkoohe.univ-ubs.fr id h7JF3nPO032382
On Tue, 2003-08-19 at 15:39, Dalibor Topic wrote:
> Salut Herve, salut Nicolas,
Hallo Dalibor,
> sorry for letting you wait so long, without a reply.
It let me time to write an all-in-one test case (it launches a local
registry, a server, a client and then dies).
To use it:
javac RMITest.java
rmic SimpleRMIServerImpl
java RMITest
Note that I don't always have kaffe's bin directory in my PATH variable.
So I noticed that in a such case, rmic can't find kjc. This is why I
attach a patch to rmic.in that modify the PATH variable before running
rmic.
If you prefer a test suite with separated client & server, have a look
at:
http://www.kaffe.org/pipermail/kaffe/2003-April/041775.html
I think the suite may be more useful to debug RMI, and the "all-in-one"
program will be useful in test/regression when everything will work.
Cheers,
Herv=E9
--=-Exorqpj09ROLF90Fp9RX
Content-Disposition: attachment; filename=RMITest.java
Content-Type: text/x-java; name=RMITest.java; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
public class RMITest {
public static void main(String[] args) {
new RMITest();
}
public RMITest() {
// Start the RMI registry
Thread rmiRegistry =
new Thread() {
public void run() {
try {
Registry registry =
LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
};
rmiRegistry.start();
String serverName = "//localhost/SimpleRMIServer";
// Create a server
launchServer(serverName);
// Create a client
launchClient(serverName);
System.exit(0);
}
private void launchServer(String serverName) {
if(System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
SimpleRMIServer server = new SimpleRMIServerImpl();
Naming.rebind(serverName, server);
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
private void launchClient(String serverName) {
try {
SimpleRMIServer server = (SimpleRMIServer)Naming.lookup(serverName);
System.out.println(server.hello("world !"));
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
// The server interface
interface SimpleRMIServer extends Remote {
public String hello(String s) throws RemoteException;
}
// The server implementation
class SimpleRMIServerImpl extends UnicastRemoteObject implements SimpleRMIServer {
public SimpleRMIServerImpl() throws RemoteException {
super();
}
public String hello(String s) throws RemoteException {
return "Hello, " + s;
}
}
/* Expected Output:
Hello, world !
*/
--=-Exorqpj09ROLF90Fp9RX
Content-Disposition: attachment; filename=rmic.in.diff
Content-Type: text/x-patch; name=rmic.in.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit
Index: rmic.in
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/scripts/rmic.in,v
retrieving revision 1.5
diff -r1.5 rmic.in
3a4,7
>
> PATH=${PATH}:@bindir@
> export PATH
>
--=-Exorqpj09ROLF90Fp9RX--