[erlang-questions] how to call gen_server with JInterface

Vlad Dumitrescu <>
Mon Mar 22 19:09:28 CET 2010


On Mon, Mar 22, 2010 at 16:38, patrick <> wrote:
> Is it possible to access a gen_server with JInterface?

Of course there is.

> ... and here's the java snippet which (obviously) doesn't work
>
> OtpNode otpNode = new OtpNode("", "ourCookie");
> OtpMbox myMbox = otpNode.createMbox("myMbox");
>
> OtpErlangObject[] o = new OtpErlangObject[4];
> o[0] = new OtpErlangAtom("register");
> o[1] = myMbox.self();
> o[2] = new OtpErlangString("a string");
> o[3] = new OtpErlangString("another");
> OtpErlangTuple tuple = new OtpErlangTuple(o);

OtpErlangObject[] tag = new OtpErlangObject[2];
tag[0] = myMbox.self();
tag[1] = new OtpErlangRef(otpNode);

OtpErlangObject[] msg = new OtpErlangObject[3];
msg[0] = new OtpErlangAtom("$gen_call");
msg[1] = new OtpErlangTuple(tag);
msg[2] = o;

myMbox.send("sys_man", "", msg);

With reservation for silly mistakes, this corresponds wrapping your o
above inside a {'$gen_call', {self(), make_ref()}, o}

best regards,
Vlad


More information about the erlang-questions mailing list