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 DE4F910BC8 for ; Fri, 4 Dec 2015 11:01:20 +0000 (UTC) Received: (qmail 39709 invoked by uid 500); 4 Dec 2015 11:01:20 -0000 Delivered-To: apmail-groovy-users-archive@groovy.apache.org Received: (qmail 39678 invoked by uid 500); 4 Dec 2015 11:01:20 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 39668 invoked by uid 99); 4 Dec 2015 11:01:20 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Dec 2015 11:01:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E6A261A2A43 for ; Fri, 4 Dec 2015 11:01:19 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id yv6f6My65fsy for ; Fri, 4 Dec 2015 11:01:19 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id D9D77428DC for ; Fri, 4 Dec 2015 11:01:18 +0000 (UTC) Received: by wmuu63 with SMTP id u63so57140362wmu.0 for ; Fri, 04 Dec 2015 03:01:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=FVdBcRC1U5Bag58nqUWqsS/ZSdl8JAM3FVEKtnmRjNw=; b=zn27GqeB7aM+fkElkFCpmba6Bk7b5UCgIrGtZLHsGlctmFP9jS1NPCq49Z9y5tE6Lr qDWK03lJJKJaQVMrFkwheJepZrHBxsMGBf6z/1fSBrYnRWua6hXkTDSU2yI6pDjD1lzh ns4lnn6zTjvE13fKNKLLjJNQm8Jj35otsK+O/jCYq4WKszd4XQFOoNdjyX1oFu6A4DST ZHDEFSwfYmvh+v+57h7yz6RplCakRAgik8dC/NYh6iGes9Tx2YFErn7lWWm+3Tl1ketQ wglinN9silczcW0yD/TIXC8ORN3+zzYS1IogokRJ893g2wbXNKW2yYFUt3ZXp02N5cWC Qt9A== X-Received: by 10.28.143.11 with SMTP id r11mr4465613wmd.28.1449226878053; Fri, 04 Dec 2015 03:01:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.230.203 with HTTP; Fri, 4 Dec 2015 03:00:58 -0800 (PST) In-Reply-To: References: From: =?UTF-8?B?RGlua28gU3Jrb8SN?= Date: Fri, 4 Dec 2015 12:00:58 +0100 Message-ID: Subject: Re: Get delegate in an ExtensionModule To: users@groovy.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 4 December 2015 at 11:41, Arnaud Est=C3=A8ve w= rote: > [...] > Just a question (pure curiosity) though, what happens when many jars > register many extension modules on the same type/method, and you embed bo= th > the jars ? I would assume one would win and shadow the other. Sounds like a nice experiment. ;-) Cheers, Dinko > > On Fri, Dec 4, 2015 at 11:18 AM, Dinko Srko=C4=8D = wrote: >> >> Just forward the call to the original `asType` method: >> >> org.codehaus.groovy.runtime.StringGroovyMethods.asType(self, someClass= ) >> >> Cheers, >> Dinko >> >> On 4 December 2015 at 10:16, Arnaud Est=C3=A8ve >> wrote: >> > Hello, >> > >> > I'm currently playing with extension modules and congrats, it's very f= un >> > to >> > add syntaxic sugar to an existing API. >> > >> > I was wondering if it was possible to delegate to the "super" method >> > within >> > an extension module. >> > >> > For instance, let's imagine I want to overload String's asType() metho= d >> > : >> > >> > class MyStringExtension { >> > static Object asType(String self, Class someClass) { >> > if (myClass =3D SomethingICanHandler.class) { >> > // create an object from my string >> > } else { >> > // Here I'd like to "delegate" to the default String asType() >> > method >> > } >> > } >> > } >> > >> > With metaclass it would be easy, but is it even possible (and does it >> > make >> > sense ?) to do so with an extension module ? >> > >> > Thanks a lot :) >> > > >