ji — simplify mapping custom Java objects to Erlang tuples/lists/etc.

Dmitrii Dimandt <>
Thu Aug 26 14:10:48 CEST 2010


If anyon'es interested, I've put my half-baked somewhat-working library up on GitHub: http://github.com/dmitriid/ji/

This is a simple and some what dumb library to facliltate conversion between custom Java types and Erlang.

[----------------code start ----------------]

CoversionManager cm = new ConversionManager();

// loads basic convertors for integers, booleans, 
// strings and the like
cm.registerBasic(); 

ArrayList arr = new ArrayList();
arr.add("hello");
arr.add(10);

OtpErlangList list = cm.convert(arr);
// if you send this list over to Erlang, you'll get
// ["hello", 10] 

[----------------code end ----------------]




A basic usage would be something like this:


[----------------code start ----------------]

ConversionManager cm = new ConversionManager();
cm.registerBasic();

cm.register(
    new MyCustomConverter1(),
    new MyCustomConverter2(),
    new MyCustomConverter3()
);

OtpNode self = new OtpNode("");
OtpMbox mbox = self.createMbox("mbox");

while(true) {
    Object o = o = mbox.receive();

    Object result = do_something_horrible(o);
    OtpErlangObject out = cm.convert(result);

    mbox.send(from, out);
}

[----------------code start ----------------]


Code is extremely simple, so writing a converter — any type of converter — shouldn't be a problem. It might not be as useful as it sounds, but I don't have the necessary Java skills to make it an uber-library :) 



More information about the erlang-questions mailing list