Replies: 3 comments 4 replies
-
Thank you for raising these. Yes, Javet supports all the requirements you listed. Annotation @V8Function(name = "abc")
public Double getPrice() In JavaScript, Javet is very smart in guessing types. In your case, you just specify you need a Also, Javet allows application to register functions with annotation. It frees developers from manually registering interceptors. Please refer to this doc for detail and let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
**Update I removed the try block now it is working Hi again, i could fix the problems above. But i got one more, but it should be the last one. How can i pass back a interceptor on a function call and assign it to a variable. I tried it like this but i get
public class V8Product {
private V8Runtime v8Runtime;
public V8Product(V8Runtime v8Runtime) {
this.v8runtime = v8Runtime;
}
@V8Function
public V8ValueObject addAttribute(String name) {
V8Attribute attribute = new V8Attribute(v8Runtime, name);
// try (V8ValueObject obj = v8Runtime.createV8ValueObject()) {
obj.bind(attribute);
return obj;
// }
}
} and the V8Product interceptor is created like this: V8Product product = new V8Product(v8Runtime);
try (V8ValueObject v8ValueObject = v8Runtime.createV8ValueObject()) {
v8Runtime.getGlobalObject().set("p", v8ValueObject);
v8ValueObject.bind(product);
} the V8Attribute class is similar to the V8Product. The script would then look like this: var attribute1 = p.addAttribute("Test Attribute"); thanks in advance |
Beta Was this translation helpful? Give feedback.
-
I have prepared a detailed migration guide. |
Beta Was this translation helpful? Give feedback.
-
Hi,
we had our own JS-Parser for our online shop and i was trying to integrate J2V8 i got it running at the end but it was very unstable at server stress tests. I was looking for alternatives and found Javet it looks very promising. I am trying to get it running but can't figure out how to solve my problems.
in J2V8 I was registering for each Methode a call Methode from an abstract class that was handling the conversion and the metode overloading based on the amount of parameters and the function name and calling the function on the object at the end.
i hope there is a simple solution to my problemes and I don't have to refactor to much of my codebase.
Best Regards
Jörg Widmann
Beta Was this translation helpful? Give feedback.
All reactions