Jamie Echlin | 26 Mar 22:36 2015
Picon

[groovy-user] Secure AST customiser and script binding

Evening… I’m having some problems with extending SecureASTCustomizer. I am setting the receiversClassesWhiteList.


The problem is, in visitPropertyExpression and visitMethodCallExpression, the receiver.getType() is java.lang.Object. I suspect this is because I am running a script like this:


foo.getCreated()


where foo is passed in in the script binding. So at compilation stage, it can’t be known that foo is actually a Foo, and not just an Object.


Is it possible to somehow hook up the types in the script binding with the secure AST customiser?


Thanks in advance,
jamie
Marcin Zajączkowski | 26 Mar 22:00 2015
Picon

[groovy-user] Force Closure to be treated as Callable not Runnable

Hi,

The following code fails:

ExecutorService threadPool = Executors.newFixedThreadPool(1)
Callable<String> callable = { "foo" } as Callable

String value = threadPool.submit(callable).get(1, TimeUnit.SECONDS)

assert value == "foo" //is null


It is probably because Closure implements both Runnable and Callable (http://stackoverflow.com/a/15016387) and I need to add "additional" coercion to call sumbit(Callable).

String value = threadPool.submit(callable as Callable).get(1, TimeUnit.SECONDS)

In that simple case it is pretty visible, but in some places of my code where Callable is returned (to be compatible also with external Java code which can call it) I use "return { "foo" }" to not be forced to create an anonymous Callable instance in old plain Java <8 form (as it cannot be coerced from Closure). In Groovy it can cause problem when that result is put into an executor (in Java it works as expected). As it is a library I cannot find all usages and just fix it.

Is there something I can do to force given Closure to be globally treated as Callable (e.g. in case of ExecutorService.submit())?


Marcin

--
http://blog.solidsoft.info/ - Working code is not enough

yihtserns | 26 Mar 20:02 2015
Picon

[groovy-user] Is it safe to use generic get/set method

 Hi.

In Groovy, there is something called generic get/set method:
```
def get(String name) {
    ...
}

def set(String name, value) {
    ...
}
```

Apart from this forum, there seems to be no mention of it anywhere else.

Is it safe to use?  And by safe, I mean will this feature be removed simply
because it is not documented anywhere? 

--
View this message in context: http://groovy.329449.n5.nabble.com/Is-it-safe-to-use-generic-get-set-method-tp5723284.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Søren Berg Glasius | 26 Mar 19:29 2015
Picon

Re: [groovy-user] Old documentation inaccessible in the new Site

If you need the documentation, why not clone the git repository and run 

mvn site

That will give you a local version of the latest documentation.

Perhaps it could even be hosted on github pages?


Best regards / Med venlig hilsen,
Søren Berg Glasius

40 Stevenson Ave, Berkeley, CA 94708
Mobile: (+1)510 984 8362, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

On 26 March 2015 at 11:22, Luis Miranda <lmiranda.mao-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Thank you for the archiev.org link.
It would be nice to have redirects to archiev.org or any other solution. There's a lot of references to those links on forums and blogs, and even google's search still pointing to those links

On Thu, Mar 26, 2015 at 1:26 PM, Cédric Champeau <cedric.champeau-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On 03/26/2015 05:54 PM, Paco Zarate wrote:
We can use http://www.archive.org  for retrieving some content while the apache servers are up.

Cedric, do you have a backup of codehaus documentation? do you need some help with that?

I have a few months old HTML export of the wiki, but in any case Codehaus said that they would try to export it or have a read-only version somewhere.


On Thu, Mar 26, 2015 at 10:46 AM, Cédric Champeau <cedric.champeau-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On 03/26/2015 05:31 PM, Thibault Kruse wrote:
I also looked for the page to set up a groovy dev environment for contributing:
http://groovy.codehaus.org/Setup+Groovy+Development+Environment

A redirect exists, but the content does not.
Yes. Note that we didn't want to have such a strong redirect, but Codehaus is down more often than up now so it was really not good for us. We decided to redirect all traffic so that instead of 404s users have a chance to find new documentation when available.

For pages like the dev environment setup, my plan was to migrate them to the Apache website of Groovy, once it's ready.


On Thu, Mar 26, 2015 at 5:20 PM, Adrian Wijasa <awijasa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hello,

Here is the archive link I got from Paco Zarate:
http://web.archive.org/web/20141003021203/http://groovy.codehaus.org/modules/http-builder/doc/index.html

The GitHub link for HTTP Builder I received from Pascal Schumacher is
https://github.com/jgritman/httpbuilder

Thanks,

Adrian



On Mar 26, 2015, at 11:13 AM, Cédric Champeau <cedric.champeau-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:

On 03/26/2015 04:57 PM, Luis Miranda wrote:

Is old documentation still available? I trying access some links like
http://groovy.codehaus.org/HTTP+Builder , but they are broken, and i cant
find equivalent documentation in the new Site.

HTTPBuilder is a community project independent of Groovy itself so
documentation has not been migrated. AFAIK there were plans to migrate the
docs for it to GitHub pages.

--
Cédric Champeau
Groovy language developer
http://twitter.com/CedricChampeau
http://melix.github.io/blog

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

     http://xircles.codehaus.org/manage_email






--
Cédric Champeau
Groovy language developer
http://twitter.com/CedricChampeau
http://melix.github.io/blog


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





-- Cédric Champeau Groovy language developer http://twitter.com/CedricChampeau http://melix.github.io/blog


Luis Miranda | 26 Mar 16:57 2015
Picon

[groovy-user] Old documentation inaccessible in the new Site

Is old documentation still available? I trying access some links like http://groovy.codehaus.org/HTTP+Builder , but they are broken, and i cant find equivalent documentation in the new Site.
Marcin Zajączkowski | 26 Mar 00:03 2015
Picon

[groovy-user] How to pass multiple Closure parameters to another Closure?

Hi, I have a closure (A) which should call another closure (B) with all its (A) parameters. The number of parameters passed to A is equal to a number of parameters accepted by B, but I don’’t know what closure would be passed as B (and with how many parameters). I have implemented it for one parameter, but don’t know how to get number of parameters and pass all of them. The following implementation: static <T> Closure<T> wrapClosureWithId(Closure<T> block) { //simplified return { Object arg -> return block(arg) } } works fine for a single parameter: def "should propagate single named parameter into nested closure"() { expect: ["1"].each CorrelationIdUpdater.wrapClosureWithId { String elem -> elem == "1" } } but fails for many: def "should propagate multiple parameters into nested closure"() { expect: ["e1"].eachWithIndex CorrelationIdUpdater.wrapClosureWithId { String entry, int i -> entry == "e1" i == 0 } } With: groovy.lang.MissingMethodException: No signature of method: CorrelationIdUpdater$_wrapClosureWithId_closure1.doCall() is applicable for argument types: (java.lang.String, java.lang.Integer) values: [e1, 0] Possible solutions: doCall(java.lang.Object), findAll(), findAll() When I change `Object arg` to `Object... args` both tests fail. I know about `Closure.getMaximumNumberOfParameters()`, but I don’t know how to take it. The final question is: *How to pass all parameters of one closure to a subsequent closure?* Marcin P.S. Mentioned implementation is simplified. In production I use it in micro-infra-spring <https://github.com/4finance/micro-infra-spring/blob/0ef8d1636af0b7bcf5de73bb999e3c76e717a5c7/micro-infra-spring-base/src/main/groovy/com/ofg/infrastructure/correlationid/CorrelationIdUpdater.groovy#L74-L85> to propagate correlation id into a closure which is executed by an another thread (e.g. with `GPars' eachParallel{}`). ​
-- http://blog.solidsoft.info/ - Working code is not enough
Keith Suderman | 25 Mar 20:05 2015

Re: [groovy-user] Collection#map() as an alias for Collection#collect()

It is also easy to add the methods with an extension module.  See http://javazquez.com/juan/2013/02/05/add-map-reduce-and-filter-to-groovy-with-groovy-extension-modules/

Keith
On Mar 25, 2015, at 2:37 PM, Søren Berg Glasius <soeren-Kc6N1ySXURF/SzgSGea1oA@public.gmane.org> wrote:

Hi Pascal,

I think it would be fairly easy to create a pull request with this feature and see if the Groovy core team accepts it.


Best regards / Med venlig hilsen,
Søren Berg Glasius

40 Stevenson Ave, Berkeley, CA 94708
Mobile: (+1)510 984 8362, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.

On 25 March 2015 at 09:11, Pascal Schumacher <pascalschumacher-hi6Y0CQ0nG0@public.gmane.org> wrote:
Hello everybody,

I'm sure this has been discussed before, but this talk: http://www.infoq.com/presentations/groovy-tips-tricks?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row3 reminded me that it can be confusing that the "map" method is called "collect" in Groovy.

How about adding "map" as an alias for "collect"?

-Pascal

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




------------------------------
Research Associate
Department of Computer Science
Vassar College
Poughkeepsie, NY


Pascal Schumacher | 25 Mar 17:11 2015
Picon
Picon

[groovy-user] Collection#map() as an alias for Collection#collect()

Hello everybody,

I'm sure this has been discussed before, but this talk:

http://www.infoq.com/presentations/groovy-tips-tricks?utm_source=infoq&utm_medium=videos_homepage&utm_campaign=videos_row3 
reminded me that it can be confusing that the "map" method is called 
"collect" in Groovy.

How about adding "map" as an alias for "collect"?

-Pascal

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

awijasa | 25 Mar 17:04 2015
Picon

[groovy-user] Groovy HTTP-Builder new link

Hello,

What is the new link to the Groovy HTTP-Builder project? It used to be
http://groovy.codehaus.org/modules/http-builder/download.html as of
yesterday. It has stopped working today.

I can't find Groovy HTTP-Builder on groovy-lang.org > Download, Community,
and Ecosystem either.

Thanks,

Adrian

--
View this message in context: http://groovy.329449.n5.nabble.com/Groovy-HTTP-Builder-new-link-tp5723262.html
Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Michael Thome | 25 Mar 14:58 2015
Picon

[groovy-user] Regression? JsonSlurper vs Immutable

Hi folks - I'm looking for suggestions to deal with what I think is a 
bug in DefaultTypeTransformation that is preventing porting some code 
from Groovy 1.8 to 2.x.  The basic problem is that the map returned by 
JsonSlurper.parseText() is not coercable to an Immutable class.

In Groovy 2.4.3:
groovy:000>  <at> groovy.transform.Immutable class Thing { String word }
===> true
groovy:000> new groovy.json.JsonSlurper().parseText('{"word":"a"}') as Thing
Cannot coerce a map to class Thing because it is a final class
// but:
groovy:000> (new groovy.json.JsonSlurper().parseText('{"word":"a"}') as 
HashMap) as Thing
===> Thing(a)

In Groovy 1.8.6:
groovy:000>  <at> groovy.transform.Immutable class Thing { String word }
===> true
groovy:000> new groovy.json.JsonSlurper().parseText('{"word":"a"}') as Thing
===> Thing(a)

Recommendations are welcome.
Thanks,
     Michael

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Russel Winder | 25 Mar 10:29 2015
Picon

[groovy-user] Novel list


http://hammerprinciple.com/therighttool/statements/this-language-is-best-for-very-large-projects

--

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder <at> ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@...
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Gmane