I have a Java library that uses Jython to allow users to add custom scripts to interact with particular parts of the library.
Having Java give data to the scripts is easy, but let's say I want to follow this pattern in on of the Jython scripts:
data = do_stuff()
# Heavy lifting! have the java lib do this
results = java_lib_help_me_out(data)
do_stuff_with_results(results)
Is it possible to do this easily? I realize that I can make the library act as a service and use REST for intercommunication, or I can use callbacks and make the process a bit more roundabout:
data = do_stuff()
#heavy lifting
java_lib_help_me_out(data, callback)
...
def callback(results):
do_stuff_with_results(results)
Is there a better way to do this?