<div dir="ltr">In a completely JS application, I would have code like:<div>var somelib = require(&#39;somelib&#39;);</div><div>and later</div><div>var test = somelib(inputStr);</div><div>test.evaluate(someMsg);</div><div><br></div><div>The somelib returns a function that has parsed the inputStr, and the method evaluate applies the rule created from the parsed inputStr against the someMsg json object input.and returns the updated json object.</div><div><br></div><div>Is it possible to allow a context for JavaScript to handle the require and then later reference the variable (somelib) to call its functions?</div><div><br></div><div>Is there a recommended way to enable what is required to be &quot;warmed up&quot; ahead of time?</div><div><br></div><div>My goal is to execute this JavaScript library within Java code so ideally I could create a static or class variable for the library and perform the warmup in a static function or during construction and reference the library in other methods as required. Something conceptually like:</div><div><br></div><div>Context context = Context.create();</div><div>Value somelib = context.eval(&quot;js&quot;,(var somelib = require(&quot;somelib&quot;); var evalfct = somelib.evaluate; {evaluate : evalfct });</div><div>Value newMsg = somelib.evaluate(someMsg);</div><div><br></div><div>There was a comment about using ProxyObject but I wasn&#39;t sure how to get it set with the function (evaluate) that I want to call later.</div><div><br></div><div>Thanks in advance for your help.</div><div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best Regards, Nat<br><br>Nathaniel Mills<br>16 Deer Hill Ln<br>Coventry, CT, 06238<br><br><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__researcher.watson.ibm.com_researcher_view.php-3Fperson-3Dus-2Dwnm3&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=eZITAP8Wsco5IpfAp3zGFyO9fzoLroCJo2FlSI5rpoM&s=14S2ZNqGXZVRQlspMehnm9acYncNV93l-hhcsv9cwXs&e=" target="_blank">http://researcher.watson.ibm.com/researcher/view.php?person=us-wnm3</a><div><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__plus.google.com_u_0_110971604421564116308_about&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=eZITAP8Wsco5IpfAp3zGFyO9fzoLroCJo2FlSI5rpoM&s=CtZuGOJUUMS4DjSzfxmt6DmveJrDqqckYv4TXJeZAiU&e=" target="_blank">https://plus.google.com/u/0/110971604421564116308/about</a></div><div><a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.linkedin.com_profile_view-3Fid-3D5260256&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=eZITAP8Wsco5IpfAp3zGFyO9fzoLroCJo2FlSI5rpoM&s=aLdyTttp_V5IErEcZxOe0sjXUsjiHZuSI7ih1duyhG4&e=" target="_blank">http://www.linkedin.com/profile/view?id=5260256</a><br></div><div><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.facebook.com_wnmills3&d=DwMFaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=CUkXBxBNT_D5N6HMJ5T9Z6rmvNKYsqupcbk72K0lcoQ&m=eZITAP8Wsco5IpfAp3zGFyO9fzoLroCJo2FlSI5rpoM&s=IfJzoiMFai8oHAhSC-Y77Q2NJFBgWkqmF1gH0-ZTXoc&e=" target="_blank">https://www.facebook.com/wnmills3</a></div><div><br>Please note new email <b><a href="mailto:wnmills3@gmail.com" target="_blank">wnmills3@gmail.com</a></b> replaces <a href="mailto:nat@classobjects.com" target="_blank">nat@classobjects.com</a><br></div></div></div></div></div>