Create an API for modules in Java side declared by dynamic Javascript files
Closed this issue · 0 comments
hdsdi3g commented
With #281 and Nashorn API.
Usage in Java side:
MyDMAM.factory.getInterfaceDeclaredByJSModule(MyInterface.class, "module name", () -> {
return (class manually crafted);
});
With MyInterface.class:
public interface MyInterface {
public String helloWorld(String me);
public String toto();
public Collection<String> arr();
public Map<String, String> amap();
}
And, in JS side:
module.register({
name: "module name",
vendor: "Meeee",
version: "0.1",
content: {
helloWorld: function(e) {
return "Hello world, " + e;
},
toto: "aa",
arr: ["Merci", "Test"],
amap: {
aaa: "bbb",
ccc: "ddd",
},
},
});
console.log("Done");
The JS file must be set in conf/app.d directory.