Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B2E07200C5F for ; Sun, 9 Apr 2017 01:22:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B1675160B96; Sat, 8 Apr 2017 23:22:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D2E44160B93 for ; Sun, 9 Apr 2017 01:22:27 +0200 (CEST) Received: (qmail 81585 invoked by uid 500); 8 Apr 2017 23:22:25 -0000 Mailing-List: contact dev-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list dev@polygene.apache.org Received: (qmail 81020 invoked by uid 99); 8 Apr 2017 23:22:25 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Apr 2017 23:22:25 +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 CEA95C00B6 for ; Sat, 8 Apr 2017 23:22:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-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-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id MV6ix6K7rVhy for ; Sat, 8 Apr 2017 23:22:22 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id EB52E5F1E9 for ; Sat, 8 Apr 2017 23:22:21 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id s141so20567247lfe.3 for ; Sat, 08 Apr 2017 16:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to; bh=Xn+XEkNNHUmHmooNCIX3tHCpbxfLP4gpYsjNaZaAc3U=; b=AOJMEbOOelP/mKcmrmmdGegPgFxsr4KqxmTyT8jupOxev+mJtrImLWGbnrRu9exH/Y qgqWdbhgelZI0Ou/m41EeiBdtB4lct/Rvks2e5mRXWtZezmuZHj7Rp02Klc55Bt/UguJ FA9+yBeKrhRuaqIJYfX+K+fqb00KgLBqlwjH9N5lO+H0GSONmkWJBymjcdnofv1RXe4f QoRMB7w/KaaReneWEFUiECkEhRFI/vbnq0drs0PsWyaUXRIg+nbv7ai23l5xNAfgu0/N LoOv/1r0xPn1BUWsKZGmlglQ2b919o1yRzS6WeKQhw6eVyUl5kj3sVt2b9usruWVIeKh 5C+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to; bh=Xn+XEkNNHUmHmooNCIX3tHCpbxfLP4gpYsjNaZaAc3U=; b=KcqZAM09cbOLpJOuID8YTi6BC+iRvDxo8v6LgN3SCim62vPYeACunMjzqRErxxtwhC HImFLVOu97IQNZ7TVCGwwgAmdualIo2JcDfjmJctKV+dPOkAHVdeBi+S97D0yMDWJtEN O6De/rhNVHpiiCIeNrX3tR+hin3/BTmgHnNLitNRkvUdddAWDYOjqMgs4hS6HCzpZ00z 30TeQqDf4KOdWc70/eo0yYyjdL4HjPOcIvtXOCByOBQvVGXV5RWVs0v6ZqL0e/a5+S5B opU8D/OLU5aEnF8a0PkZSkGWBdC2/AhSM6fp4Dat9MLwue70lTESXH8bxx87FgHECgaD m1Mg== X-Gm-Message-State: AN3rC/7WJ4o3gC/j8axI28dlVcS9O9Kg7pmCxq3p9q1sthYh0FlKfN2kE0QTvXGYg4fE9+/Ou1TCO9Fi7mUo2g== X-Received: by 10.25.235.76 with SMTP id j73mr430610lfh.151.1491693741190; Sat, 08 Apr 2017 16:22:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.22.27 with HTTP; Sat, 8 Apr 2017 16:22:20 -0700 (PDT) Received: by 10.46.22.27 with HTTP; Sat, 8 Apr 2017 16:22:20 -0700 (PDT) Reply-To: niclas@hedhman.org In-Reply-To: References: <58E8DE82.10609@apache.org> From: Niclas Hedhman Date: Sun, 9 Apr 2017 07:22:20 +0800 Message-ID: Subject: Re: javax.script To: dev@polygene.apache.org Content-Type: multipart/alternative; boundary=001a113cc7108eb4f1054cb003c2 archived-at: Sat, 08 Apr 2017 23:22:28 -0000 --001a113cc7108eb4f1054cb003c2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Ok, I will try to figure out if single compile per composite type is possible. My initial finding is that it is not. Expect it to complete today. On Apr 8, 2017 20:58, "Paul Merlin" wrote: Having a script scope per composite instance makes sense to me. Script scopes allows scripts to hold state, we don't want to share state between composite instances. Just like you said, this is not a performance issue for Services. And if you need single use composites then that's probably because you don't want to share their state. Ideally we would be able to do the "compilation" once per composite type and then "clone" the scope, or use "sub-contexts" for each instance. Don't know if that's possible using the javax.scripting api though. Niclas Hedhman a =C3=A9crit : > Hi, > I mentioned yesterday that I am working on putting javax.script as the > integration point with JavaScript and Groovy instead of our direct > dependencies on each. > > There is one thing that 'bothers me'; Scopes. > > So a single class ScriptMixin will handle the reading and invoking the > javax.script side, but what is the scope? > > ScriptMixin is the supplied Mixin to any number of Composite Types for an= y > number of interfaces and methods. > > I *could* create one ScriptEngine per method, or per method.declaringClass, > or per Composite primary type or per Polygene runtime. > > A ScriptEngine has ScriptContexts which in turn holds the Bindings. The > Bindings contain the integration objects (accessible in both Java and > script language) as well as the script itself. ScriptContext holds 2 > Bindings (GLOBAL and ENGINE), and the handling of them internally is > non-intuituve. > > Now, the question is what is the scope of the script itself? Should it be a > global script per primary type, or should we isolate each composite > instance with its own script engine? Or should it be a global script > environment to really open the gates of problems? > > I tend to lean on "script engine per composite instance", but it feels a > bit heavy-handed. I guess it doesn't matter which one if the use is > Services, but for short-lived composites it would also mean one compile > cycle per creation (=3D=3Dslow?) > > Ideas and feedback most welcome. > > > For those who have no idea what I am talking about; > > It has been possible to implement the mixin methods of composites in othe= r > languages, such as JavaScript and Groovy. > > package com.abc.script; > > @Mixins( ScriptMixin.class ) > public interface SomeType extends ScriptReloadable > { > String doMyBidding( String whatever ); > } > > and then have (for instance) JavaScript in a resource > com/abc/script/SomeType.js with; > > function doMyBidding( whatever ) { > return "Great: " + whatever; > } > > and the ScriptReloadable.reloadScript() will recompile it for next time, > i.e code replacement in runtime. > > Inside the script environment, things like serviceFinder, > valueBuilderFactory and so on are available as global variables. > > Cheers --001a113cc7108eb4f1054cb003c2--