how to call gen_server with JInterface

ingo.schramm schramm.ingo@REDACTED
Tue Mar 23 11:07:26 CET 2010


Just a hint :)

As a side effect of a project I'm working on I wrote a rather generic
facade from Erlang to Java and back. I have an Erlang app ej
supervising a
Java node. On Erlang you can use an ej_srv:send or ej_srv:call and on
the Java side you implement a message handler. That's it. The solution
has
still some limitations but it abstracts a lot of the marshalling
stuff.

You may find it here: http://github.com/nerlo/nerlo.

I think about releasing ej sometimes as a separate package, if useful.

Cheers,
Ingo

On Mar 22, 7:09 pm, Vlad Dumitrescu <vladd...@REDACTED> wrote:
> On Mon, Mar 22, 2010 at 16:38, patrick <preic...@REDACTED> 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("javaN...@REDACTED", "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", "p...@REDACTED", msg);
>
> With reservation for silly mistakes, this corresponds wrapping your o
> above inside a {'$gen_call', {self(), make_ref()}, o}
>
> best regards,
> Vlad
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> Seehttp://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscr...@REDACTED


More information about the erlang-questions mailing list