Just checked.  No info yet on JSAdapter or JSObject in the Java Scripting 
Programmer's Guide. 

-----Original Message-----
From: A. Sundararajan [mailto:[email protected]] 
Sent: Tuesday, October 08, 2013 9:06 AM
To: Rick Bullotta; [email protected]
Subject: Re: From JS to Java objects?

There are tests under $nashorn/test/ directory has tests that demonstrate the 
use of JSAdapter and JSObject (from outside).

I am not sure if "Java Scripting Programmer's Guide" has JSAdapter or not. 
Pluggable JSObject is a more recent thing.

-Sundar

On Tuesday 08 October 2013 02:51 PM, Rick Bullotta wrote:
> Awesome.  Any examples out there in the ether?
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of A. 
> Sundararajan
> Sent: Tuesday, October 08, 2013 8:50 AM
> To: [email protected]
> Subject: Re: From JS to Java objects?
>
> There is JSAdapter support in nashorn (like jdk6/7 Rhino supported).
> JSAdapter is used within script to intercept get/put/call etc. Also it is 
> possible to supply your own impl of jdk.nashorn.api.scripting.JSObject -- 
> which can be used with natural script syntax from script. You can intercept 
> calls, property access in your code.
>
> Hope this helps
> -Sundar
>
> On Tuesday 08 October 2013 02:32 PM, Rick Bullotta wrote:
>> On a related topic, I'm particularly interested in better understanding the 
>> *Adapter model in Nashorn and how it compares to Rhino, particularly in 
>> terms of custom adapters.
>>
>> In Rhino, we use custom adapters to intercept get/set/delete/put and other 
>> methods to allow dynamic access to a variety of data structures and objects 
>> (we can virtualize properties and functions this way, versus automatic 
>> reflection and type munging), and it isn't at all clear how to do this with 
>> Nashorn.
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Tal Liron
>> Sent: Tuesday, October 08, 2013 8:26 AM
>> To: [email protected]
>> Subject: Re: From JS to Java objects?
>>
>> Sorry about that, was trying to be succinct.
>>
>> In detail: I'm creating Nashorn scripts programmatically from Java (using 
>> Context.compileScript and ScriptRuntime.apply), and receiving native results 
>> that need some massaging in order to be usable in Java.
>> (Specifically I'm working on creating a Nashorn adapter for
>> Scripturian.)
>>
>> However, I mostly found the answers myself:
>>
>> 1. It's possible to call NativeJava.to (equivalent to Java.to in JavaScript) 
>> 2. More efficient is to test specifically for NativeArray results and wrap 
>> them in a ListAdapter, which makes them conform to the List interface. This 
>> is what NativeJava.to does internally.
>>
>> On 10/08/2013 08:12 PM, Jim Laskey (Oracle) wrote:
>>> Please be more specific with an example.  I assume you want to 
>>> extend a Java class or some such requirement,
>>>

Reply via email to