16 Sep 20:36 2014

### [groovy-user] [ANN] Groovy Weekly #36

Hi all,

Groovy Weekly #36 is here, back from the SpringOne2GX conference in Dallas:
http://glaforge.appspot.com/article/groovy-weekly-36

--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

15 Sep 01:45 2014

### [groovy-user] Thread Safe Collection of Variables that can be passed around

Hi all,

I've needed to have a variable collection that can be passed to methods, can store closures and null values, and supports setters/getters.  Up to now, I've using Binding to serve this need.

But, now I need my code to be thread safe and continue to support null values.  I note that Groovy-4685 and the JavaDoc says that Binding is not thread-safe.  I've considering switching to using ConcurrentHashMap, but it does not support null values (or keys).  I've considered a wrapper class to overcome the storing of null values:

import java.util.concurrent.ConcurrentHashMap

public class MyConcurrentHashMap<K,V> extends ConcurrentHashMap
{
private enum Null { NULL }  // Workaround for inadmissible null values
V get(Object key) { def v = super.get(key); return v == MyConcurrentHashMap.Null.NULL ? null : v }
V put(K key, V value) { super.put(key, value == null ? MyConcurrentHashMap.Null.NULL : value) }
//... and so on

public static void setvars(MyConcurrentHashMap m)
{
Integer local = 21
m.with {
p = 42
r = null
c = { println "running q, p = $p, r =$r, local = $local" } } } public static void show(MyConcurrentHashMap m) { m.c() } public static void main(String[] args) { MyConcurrentHashMap t = new MyConcurrentHashMap<String, Object>() setvars(t) show(t) } } running q, p = 42, r = null, local = 21 This works, but I'm wondering if there is a better approach to this, or if I've missed any important concerns. Any thoughts? Thanks, Steve Amerige Principal Software Developer, Fraud and Compliance Solutions Development SAS Institute, 940 NW Cary Pkwy #129, Cary, NC 27513-2792 14 Sep 12:49 2014 ### [groovy-user] Web camera from GroovyLab Hi all, if found an interested project: https://github.com/sarxos/webcam-capture and I reorganized the material as a convenient GroovyLab toolbox, the webcam.jar: https://sourceforge.net/projects/groovylab/files/?source=navbar I hope that users of GroovyLab can work with Web cameras more easily than with the plain Java interface of the project. bye Stergios --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email  13 Sep 13:15 2014 ### [groovy-user] No suitable ClassLoader found for grab Hello, I'd like to build an app with groovy + mysql I've added the annotations: <at> Grapes([ <at> Grab(group='mysql', module='mysql-connector-java', version='5.1.13'), <at> GrabConfig(systemClassLoader = true) ]) but I still got an error "No suitable ClassLoader found for grab" Using print /ClassLoader.getSystemClassLoader().getClass().getName()/ tells me, the classloader is /sun.misc.Launcher$AppClassLoader/

I have same error in groovy 2.3.6 and 2.4.0-beta-3. My java version is
1.7.0_67.

What is wrong?

--
View this message in context: http://groovy.329449.n5.nabble.com/No-suitable-ClassLoader-found-for-grab-tp5721212.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


12 Sep 23:15 2014

### [groovy-user] field access (. <at> ) not working with super

Hi all!

The problem is exactly as it is stated in the subject: field access (. <at> ) not working with super variable. Here's an example:

class Foo {

int x

int getX() {
return x + 1
}

}

class Bar extends Foo {

void doJob() {
println super.x
println super. <at> x
}

}

Bar b = new Bar()
b.x = 1
b.doJob()

If you run this script, you'll get

2
2

It means that super. <at> x really does super.getX(). Is this a bug? If yes, should I raise it in JIRA? I'm ready to help with a patch, and if someone could point me to a class in sources that would be awesome.

If this is not a bug, then how can I achieve this behavior? I'm porting some java code to groovy and bumped into this.

Alexander
11 Sep 22:14 2014

### Re: [groovy-user] Quick question about Groovy Map of Arrays

To do that using a gstring template that looks like this:

def dat = ['NCC_TEST': [1234, 1345, 1232, 1133, 1100], 'NCC_TEST2': [9999,8765, 4321]]

println """update tablename set IsEnriched = 999 where ${ dat.collect { name, serials -> "ServerName = '$name' and ServerSerial in (\${serials.join(', ')})" }.join(" or ")
}"""

There are some SQL builders and such in Groovy but I haven't used any of them for a long while.

Jim

On Thu, Sep 11, 2014 at 11:58 AM, Greg Thorne wrote:
Hi, I'm new to Groovy, and am trying to figure out the best way of doing something:

So I have two values, ServerName and ServerSerial in a format like this:

['NCC_TEST': [1234, 1345, 1232, 1133, 1100], 'NCC_TEST2': [9999,8765, 4321]]

and I want to put them in a SQL query like this:

update tablename set IsEnriched = 999 where (ServerName = 'NCC_TEST' and ServerSerial in (1234, 1345, 1232, 1133, 1100)) or (ServerName = 'NCC_TEST2' and ServerSerial in (9999,8765, 4321))

I'm sure there's a way to do it without looping through and building the string one at a time.

11 Sep 20:58 2014

### [groovy-user] Quick question about Groovy Map of Arrays

Hi, I'm new to Groovy, and am trying to figure out the best way of doing something:

So I have two values, ServerName and ServerSerial in a format like this:

['NCC_TEST': [1234, 1345, 1232, 1133, 1100], 'NCC_TEST2': [9999,8765, 4321]]

and I want to put them in a SQL query like this:

update tablename set IsEnriched = 999 where (ServerName = 'NCC_TEST' and ServerSerial in (1234, 1345, 1232, 1133, 1100)) or (ServerName = 'NCC_TEST2' and ServerSerial in (9999,8765, 4321))

I'm sure there's a way to do it without looping through and building the string one at a time.
10 Sep 01:17 2014

### [groovy-user] [ANN] Groovy Weekly #34, live from SpringOne2GX

Hi all,

I'm at the SpringOne2GX conference, in Dallas, and it's still Tuesday here, so it's time for the new Groovy Weekly release!

--
Guillaume Laforge
Groovy Project Manager
Pivotal, Inc.

9 Sep 21:39 2014

### [groovy-user] RuntimeParserException when returning a value in void method

Hi all!

If I try to compile the following code a RuntimeParserException is thrown
instead of the usual Static Type Checking error that appears whenever there
is a syntax error:

<at> groovy.transform.TypeChecked
public class MyClass{

public void myMethod()
{
return "Hello World!"
}
}
def myClass = new MyClass()
myClass.myMethod()

I was wondering why this case isn't treated the same as when you try to
return a type that doesn't match the return type declared in the method and
would appreciate any pointers you can provide.

Regards,

Rodolfo

--
View this message in context: http://groovy.329449.n5.nabble.com/RuntimeParserException-when-returning-a-value-in-void-method-tp5721196.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


8 Sep 18:12 2014

### [groovy-user] problem with includes building asciidoc

Hi,

I'm trying to build the asciidoc like is shown on the groovy website, using
"gradle asciidocAll".  The problem is the includes are not working, it shows
as, eg in "core syntax":

I've tried adding safe: 'UNSAFE' to the asciidoctor task in
asciidoctor.gradle, but no joy. Maybe a windows thing?

BTW, the reason why I'm doing this is because I want to use ADOC to create a
static website... ideally I'd like something like readthedocs but that has
no support for ADOC. I would like to use something similar to the groovylang
approach, although I do think it's missing a higher-level TOC link when
looking at a specific doc, eg "syntax", and also an easier way of flipping
to view the page in some other version.

cheers, jamie

--
View this message in context: http://groovy.329449.n5.nabble.com/problem-with-includes-building-asciidoc-tp5721194.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


8 Sep 08:56 2014

### [groovy-user] Annotation processor for groovy

Hi,

I would like to process annotations in my groovy files. In java I already used an annotation processor. I can´t find a similar option on the groovy compiler, so would be an AST an alternative?

Thx,

Thilko

Gmane