From users-return-514-apmail-groovy-users-archive=groovy.apache.org@groovy.incubator.apache.org Mon Jul 20 12:22:39 2015 Return-Path: X-Original-To: apmail-groovy-users-archive@minotaur.apache.org Delivered-To: apmail-groovy-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4CF9118C54 for ; Mon, 20 Jul 2015 12:22:39 +0000 (UTC) Received: (qmail 74104 invoked by uid 500); 20 Jul 2015 12:22:34 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 74071 invoked by uid 500); 20 Jul 2015 12:22:34 -0000 Mailing-List: contact users-help@groovy.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.incubator.apache.org Delivered-To: mailing list users@groovy.incubator.apache.org Received: (qmail 74061 invoked by uid 99); 20 Jul 2015 12:22:34 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2015 12:22:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id ADBDDC09A5 for ; Mon, 20 Jul 2015 12:22:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.9 X-Spam-Level: *** X-Spam-Status: No, score=3.9 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, KAM_LIVE=1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id wOicnidDutz0 for ; Mon, 20 Jul 2015 12:22:20 +0000 (UTC) Received: from mail-ob0-f174.google.com (mail-ob0-f174.google.com [209.85.214.174]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 47AAE21143 for ; Mon, 20 Jul 2015 12:22:19 +0000 (UTC) Received: by obnw1 with SMTP id w1so100169623obn.3 for ; Mon, 20 Jul 2015 05:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=IGgpAWUI9xusGGQq42r7xrnfXmWb2sRnfvdbsHJly3c=; b=0RAPdcRlvUh02T+KU+TT/cuAvtkfWwa1A1z/lWAF1LacAt4sPlAJ2+CVTnVbFhZawZ 5ulldeY2aCliQdTi0Vaq2CXR7lLYGgmf4r5Urbo8xN0K36jIoEx37oloWSh3pAzVg2tR VUbbRTD7LRR0fPkzJ2Zh/RZSEL3sdCa8uc75Sq0dtktmGwx2oRRhtYSuyJOcKtVluTY+ 0auY03d9lgKnr5gAS4vf7XBT3NecenkKxg+gGEG4myaybJvYp3D8GisIAIzvf9rTC5Bm fbJ6dHlP1fZko8K/i2N/z/GG4P+H6Jw/PASOL2tuE1qYou4e6OoJQ+3R4yffn2CLs7xP mtnw== MIME-Version: 1.0 X-Received: by 10.182.65.164 with SMTP id y4mr25331542obs.65.1437394887516; Mon, 20 Jul 2015 05:21:27 -0700 (PDT) Received: by 10.202.95.131 with HTTP; Mon, 20 Jul 2015 05:21:27 -0700 (PDT) In-Reply-To: References: <55ACE16F.4040403@sas.com> Date: Mon, 20 Jul 2015 14:21:27 +0200 Message-ID: Subject: Re: Groovy has: Add Imports Transparently to Scripts with ImportCustomizer; Is there a Java equivalent? From: Guillaume Laforge To: users@groovy.incubator.apache.org Content-Type: multipart/related; boundary=001a11c1fbbeac6bdf051b4d9310 --001a11c1fbbeac6bdf051b4d9310 Content-Type: multipart/alternative; boundary=001a11c1fbbeac6bd6051b4d930f --001a11c1fbbeac6bd6051b4d930f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Agreed with C=C3=A9dric, as JSR-223 is really too brained-down to be really useful. It's still however possible to cast the Groovy javax script engine to its concrete implementation class, and then you can access the underlying GroovyClassLoader used, and set the CompilerConfiguration to what you want. But you're now tied to the specifics of the Groovy implementation of JSR-233. I had a customer that really wanted to use JSR-223/javax.script, but had to worrkound that way to such things as customize the imports and more. They had come up with this solution. On Mon, Jul 20, 2015 at 2:13 PM, C=C3=A9dric Champeau wrote: > No. That's what one of the limitations we fight against in JSR-223. It is > very limited, and doesn't support any kind of configuration of the engine= . > In other words, if you don't need to rely on the limited JSR-223 api, > better use the Groovy specific engine instead. > > 2015-07-20 13:54 GMT+02:00 Steve Amerige : > >> I received the question: >> >> *org.codehaus.groovy *implementation of Groovy (groovy-all) provides a >> mechanism to set imports when evaluating Groovy code via * >> CompilerConfiguration *and *ImportCustomizer*. I don't see the >> equivalent in *javax.script *in *ScriptEngine*/*ScriptContext*. Is there >> a way I can add (implicit) imports in *javax.script*, perhaps by setting >> a *ScriptContext *attribute? >> >> >> Can anyone throw any light on this? MrHaki has a nice article >> >> on the Groovy side. >> >> Thanks, >> Steve Amerige >> Principal Software Developer, Fraud and Compliance Solutions Developmen= t >> SAS Institute, 100 SAS Campus Dr, Room U3050, Cary, NC 27513-8617 >> >> >> >> >> > --=20 Guillaume Laforge Groovy Project Manager Product Ninja & Advocate at Restlet Blog: http://glaforge.appspot.com/ Social: @glaforge / Google+ --001a11c1fbbeac6bd6051b4d930f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Agreed with C=C3=A9dric, as JSR-223 is really too brained-= down to be really useful.

It's still however possibl= e to cast the Groovy javax script engine to its concrete implementation cla= ss, and then you can access the underlying GroovyClassLoader used, and set = the CompilerConfiguration to what you want.
But you're now ti= ed to the specifics of the Groovy implementation of JSR-233.
I ha= d a customer that really wanted to use JSR-223/javax.script, but had to wor= rkound that way to such things as customize the imports and more. They had = come up with this solution.

On Mon, Jul 20, 2015 at 2:13 PM, C=C3=A9dric Champeau= <cedric.champeau@gmail.com> wrote:
No. That's what one of the limitati= ons we fight against in JSR-223. It is very limited, and doesn't suppor= t any kind of configuration of the engine. In other words, if you don't= need to rely on the limited JSR-223 api, better use the Groovy specific en= gine instead.

2015-07-20 13:54 GMT+02:00 = Steve Amerige <Steve.Amerige@sas.com>:
=20 =20 =20
I received the question:

org.codehaus.groovy implementation of Groovy (groovy-all) provides a mechanism to set imports when evaluating Groovy code via CompilerConfiguration and ImportCustomizer. I don't see the equivalent in javax.script in ScriptEngine/S= criptContext. Is there a way I can add (implicit) imports in javax.script, perhaps by setting a ScriptContext attribute?

Can anyone throw any light on this?=C2=A0 MrHaki has a nice article on the Groovy side.

Thanks,
Steve Amerige
Principal Software Developer, Fraud and Compliance Solutions Development
SAS Institute, 100 SAS Campus Dr, Room U3050, Cary, NC 27513-8617


3D""






--
=
=
Guillaume Laforge
Groovy Project Manager
Product Ninja & Advocate at Restlet

--001a11c1fbbeac6bd6051b4d930f-- --001a11c1fbbeac6bdf051b4d9310 Content-Type: image/gif; name="SAS_TPTK_logo.gif" Content-Disposition: inline; filename="SAS_TPTK_logo.gif" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: 64878633a8e44ffb_0.1.1 R0lGODlhtQArAMQAAJzN6Li5uzOXz9bX2MTFx2Ov2sPh8Y2LjFFPT+3u7vr8/GpnaPL09L2+v5yb nDc0Nd7v+ODh4tvc3fX4+KyusdDR0rKztsvMzejp6hSHyOTl5n58faeprAB9wyMfIP7//yH5BAAA AAAALAAAAAC1ACsAAAX/4CeOZGmeaKqubOu+cCzPEFAIWZ4JBcDMwKAQ1UgMj8gRpJDpOJ/QTAGS rFpPAeN16wJAv+AMgEs+Fsvo0qQAbn8L6fjrLC9PBO5nToBrOuEtCREVEQkTMQwYAwOFhy6Jixha MnQoCgmYmQwMmCKcDJeZmD9xbG5SABAKqw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