[erlang-questions] JInterface and rex
Michael Ossareh
ossareh@REDACTED
Wed Feb 18 10:56:49 CET 2009
Hi,
Inspired by http://notdennisbyrne.blogspot.com/2008/07/using-jinterface-to-bridge-erlang-and.html
I decided to mess around a bit with jinterface. I seem to be having
some fundamental problems however.
I have two classes;
public class A {
OtpNode node;
OtpMbox mbox;
A() throws Exception {
node = new OtpNode("a");
mbox = new OtpMbox("a_mbox");
}
public void method1() {
// send value
mbox.send("b", new OtpErlangInt(99));
}
public void method2() {
// remote execution
OtpErlangTuple t = new OtpErlangTuple(
new OtpErlangObject[] {
mbox.self(),
new OtpErlangTuple(
new OtpErlangObject[] {
new OtpErlangAtom("call"),
new OtpErlangAtom("erlang"),
new OtpErlangAtom("node"),
new OtpErlangList(new OtpErlangObject[] {}),
new OtpErlangAtom("user")
}
)}
);
mbox.send("rex", "b", t);
}
public void pingOtherNode() {
assert node.ping("b");
}
}
public class B implements Runnable {
OtpNode node;
OtpMbox mbox;
B() throws Exception {
node = new OtpNode("b");
mbox = new OtpMbox("b_mbox");
}
run() {
// loop continuously reading from mbox and output like below
// OtpErlangObject obj = mbox.receive(1000);
// if (obj!=null) System.out.println("rec "+obj);
}
}
A.ping() successfully pings b when called and B is a running thread.
If I change the name of the node to ping in A.ping it fails, so I'm
sure they're aware of each others presence.
A.method1 results in B.run's method outputting the int. However
A.method2 results in no output in B.run(). Right now I'm working on
the assumption that this is because "rex" isn't running on the other
node (I guess unlike the erlang vm this doesn't happen by default?).
So is there a way I can get rex to run? Slides 19 and 20 of
http://www.slideshare.net/dennisbyrne/integrating-java-and-erlang-with-jinterface-presentation
do not suggest anything along those lines needing to be run - however
the actual presentation video suggests that rex is only used to an
erlang vm.
In essence I'm doing this so that I can build a test suite which lets
me test my client code against a light weight version of our server
code. Allowing me to unit test, etc.
Thanks,
mike
--
god loves atheists, Fact: http://www.mrwiggleslovesyou.com/comics/rehab477.jpg
More information about the erlang-questions
mailing list