Pause and Resume

A. Sundararajan sundararajan.athijegannathan at oracle.com
Wed Mar 11 12:47:30 UTC 2015


Nashorn script objects, functions are *not* Java Serializable objects. I 
suggest you "serialize" required data (scope or other JS objects) as 
JSON string and also store the associated script string. If script is 
loaded from same URL and persistent code is enabled ( 
https://blogs.oracle.com/nashorn/entry/improving_nashorn_startup_time_using 
), when you re-load the script, nashorn would use already compiled 
classes. You can call the desired script function passing JSON.parse'd 
string as argument.

This is the closest things I can think of in nashorn world. Any further 
ideas from anyone else on the list?

Thanks,
-Sundar

On Wednesday 11 March 2015 02:59 PM, Ankit Narang wrote:
> Hi all,
>
> I'm migrating to Nashorn from Rhino (v1.7R4). In my use case, I make
> asynchronous service calls from Javascript.
>
> I accomplished it in Rhino by:
> 1. Serializing Scope and Callback Function on S3 (AWS). Send S3 key as a
> payload to the service.
> 2. After getting the response from service (async), de-serializing Scope
> and Callback Function from S3 (AWS) using the S3 key (present in service's
> response as the payload).
> 3. Continue script execution by invoking Callback Function with service
> response as the argument (with the Scope obtained from step 2).
>
> What's the way to do the same in Nashorn?
>
> Thanks
> Ankit



More information about the nashorn-dev mailing list