Re: Maven coordinates going forward

2017-03-27 Thread Gerald Wiltse
I am not sure if I agree or not yet ( I think I do.)  But I think Jason's
point is that the situation with Python is perhaps as undesirable as one
could imagine for an ecosystem, so trying to learn as much from that
situation as possible might be wise.

Specifically, reaching out to the Python maintainers for guidance.  In
hindsight, someone deeply involved usually has a very clear vision of "What
we should have done instead was...".  It would be a major missed
opportunity if nobody pursues that avenue.

Gerald R. Wiltse
jerrywil...@gmail.com


On Mon, Mar 27, 2017 at 12:16 PM, Daniel Sun 
wrote:

>
> > The two are independent. I suggest changing both at the same time would
> be the right thing to do.
>
> Agreed!
>
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/Maven-coordinates-going-forward-tp5739395p5739409.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
>


Re: [VOTE] new operator ?=

2016-11-23 Thread Gerald Wiltse
+1

Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Nov 23, 2016 at 12:28 PM, Winnebeck, Jason <
jason.winneb...@windstream.com> wrote:

> At first I was going to vote 0, because I feel like a = a ?: b is clear
> (and I compare it to a = a || b from JS). However, looking at the dev list,
> I definitely see a nice case for it:
>
> person.name.last = person.name.last ?: "unknown"
>
> When you have a non-trivial assignment expression, I see the benefit:
>
> person.name.last ?= "unknown"
>
> However, I feel like it is not intuitive or clear. But, I don't think the
> operator hurts, and it's certainly not any less intuitive than <=> for
> example or even ?: when seen for the very first time. It's an easy look up
> in Groovy docs, and if you don't know it and don't use it, it's not a huge
> loss. So it doesn't hurt to add it, and while not instantly readable, it's
> a trivial docs lookup when someone is reading the code.
>
> So, I vote +1. But, honestly, I don't see myself using it very often as
> I'd normally use Elvis at time of initial assignment. I wouldn't put it
> very high on a prioritized backlog of things to improve for Groovy.
>
> Jason
>
> -Original Message-
> From: Daniel Sun [mailto:realblue...@hotmail.com]
> Sent: Wednesday, November 23, 2016 10:59 AM
> To: us...@groovy.incubator.apache.org
> Subject: [VOTE] new operator ?=
>
> Hi all,
>
>  If the new operator ?=  (e.g. a ?= 'foo'  is equivalent of  a = a ?:
> 'foo') were to be added to Groovy programming language, do you like it?
> (Yes: +1; No: -1; Not bad: 0)
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/VOTE-new-operator-tp5736931.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
>
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>


Re: Looping through a hashmap & removing elements

2016-06-06 Thread Gerald Wiltse
Guy,

Please note that removeAll can have dramatic negative impact on your
application if run on a large scale.  We recently found that it was the
cause of CPU spikes on most of our JVM's.  We had to replace all uses of
"removeAll()" with "findAll()" or "retainAll()"

These do create new list which uses more RAM.  However, in many cases these
days, the RAM is less of an issue than the CPU.

Gerald R. Wiltse
jerrywil...@gmail.com


On Thu, Jun 2, 2016 at 2:56 PM, Guy Matz  wrote:

> Ahh!!  I only saw this removeAll:
> public boolean *removeAll*(Object[]
> 
> items)
>
> !!  Thanks!!!
>
> On Thu, Jun 2, 2016 at 2:27 PM, Winnebeck, Jason <
> jason.winneb...@windstream.com> wrote:
>
>> If you want to actually edit the original map:
>>
>>
>>
>> def uidMap = [
>>
>>   a: 123,
>>
>>   b: 456,
>>
>>   c: 789
>>
>> ]
>>
>>
>>
>> uidMap.entrySet().removeAll { it.key.startsWith('a') }
>>
>>
>>
>> If you want a new map, emmanuel’s solution using findAll is best.
>>
>>
>>
>> Jason
>>
>>
>>
>> *From:* Guy Matz [mailto:guym...@gmail.com]
>> *Sent:* Thursday, June 02, 2016 2:18 PM
>> *To:* users@groovy.apache.org
>> *Subject:* Looping through a hashmap & removing elements
>>
>>
>>
>> Hi!  I want to loop through a hashmap and delete some elements based on
>> some criteria . . .  I thought there would be some slick groovy method - in
>> the spirit of findAll, etc. - to do this, but couldn't find it . . .  my
>> java developer workmate suggested:
>>
>>
>>
>> iter = uidMap.entrySet().iterator()
>> *while *(iter.hasNext()) {
>> entry = iter.next()
>> key = entry.key
>> value = entry.value
>>
>> if (bla, blah, blah) {
>>
>> iter.remove()
>>
>> }
>>
>>
>>
>> Is there a groovier way?
>>
>>
>>
>> Thanks!
>>
>> Guy
>>
>> --
>> This email message and any attachments are for the sole use of the
>> intended recipient(s). Any unauthorized review, use, disclosure or
>> distribution is prohibited. If you are not the intended recipient, please
>> contact the sender by reply email and destroy all copies of the original
>> message and any attachments.
>>
>
>


Re: Methods for Creating Ranges

2016-04-20 Thread Gerald Wiltse
I re-arranged it as follows.  Does this seem preferable from a performance
perspective?.There will be about an 8:1 ratio... (8 matches of this[tmpKey]
= v to every 1 exception which hits the catch which needs to be parsed.

try {
this[tmpKey] = v
} catch (GroovyCastException e) {
this[tmpKey] = new GroovyShell().parse(v).run()
}

Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Apr 20, 2016 at 9:26 AM, Gerald Wiltse <jerrywil...@gmail.com>
wrote:

> The code will be executed about once every 10 seconds at a maximum, so the
> load is not extremely high.
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> On Wed, Apr 20, 2016 at 3:32 AM, Guillaume Laforge <glafo...@gmail.com>
> wrote:
>
>> Eval.x(v) should just work as well.
>>
>> Regarding resources / performance, it means spinning the parser and
>> compiler, so it's not for free. Doing your own string parsing logic might
>> be more efficient.
>> Depends on how frequently you have to do that.
>> Le 20 avr. 2016 07:57, "Gerald Wiltse" <jerrywil...@gmail.com> a écrit :
>>
>>> Wow, i just wrote that exact code basically... and started responding to
>>> your email, but there were various drawbacks to this approach as I don't
>>> want to have to define handling of every property by name...  Then... it
>>> hit me...
>>>
>>> def v = '1..10'
>>> assert new GroovyShell().parse(v).run() == [1,2,3,4,5]
>>>
>>> It works!!!
>>>
>>> Something about the Eval works just a little bit differently than
>>> GroovyShell i guess.  Perhaps Dierk  can explain.
>>>
>>> Last question, how expensive is this invocation of groovyshell and parse
>>> and all that (resources wise)?  So-so?
>>>
>>>
>>> Gerald R. Wiltse
>>> jerrywil...@gmail.com
>>>
>>>
>>> On Wed, Apr 20, 2016 at 1:48 AM, Guillaume Laforge <glafo...@gmail.com>
>>> wrote:
>>>
>>>> If you know it's a range when parsing that string, you can do this,
>>>> with the toInteger() method:
>>>>
>>>>def rangeString = "123..455"
>>>>def (String min, String max) = rangeString.tokenize("..")
>>>>def range = min.toInteger()..max.toInteger()
>>>>
>>>> On Wed, Apr 20, 2016 at 7:26 AM, Gerald Wiltse <jerrywil...@gmail.com>
>>>> wrote:
>>>>
>>>>> I don't see how that works in my case, maybe i'm missing something.
>>>>>
>>>>> I will clarify:
>>>>>
>>>>> I define a variable in web to represent the range:   14502..14520
>>>>>
>>>>> The web converts this to a string, and passes it into my code.
>>>>>
>>>>> My code then has to receive this string, and then construct a list
>>>>> from it.
>>>>>
>>>>> I could do:
>>>>>
>>>>> String rangeString = passedInVar
>>>>> (String min, String max) = rangeString.tokenize("..")
>>>>> Range range = min..max
>>>>>
>>>>> But i was hoping for a universal "caster" loop which can detect and
>>>>> cast the common types from strings:
>>>>> Integers, lists, ranges, maps, booleans..
>>>>>
>>>>> 12345
>>>>> ["this", "is", "Sample", "List"]
>>>>> 14502..14520
>>>>> ["key":"value","for":"maps"]
>>>>> true
>>>>>
>>>>> I think eval works for all but ranges.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Gerald R. Wiltse
>>>>> jerrywil...@gmail.com
>>>>>
>>>>>
>>>>> On Wed, Apr 20, 2016 at 1:15 AM, Guillaume Laforge <glafo...@gmail.com
>>>>> > wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> You can just replace the bounds with variables.
>>>>>>
>>>>>> def a = 1
>>>>>> def b = 10
>>>>>> def r = a..b
>>>>>>
>>>>>> Isn't that what you're looking for?
>>>>>>
>>>>>> Guillaume
>>>>>>
>>>>>>
>>>>>> Le mercredi 20 avril 2016, Gera

Re: Methods for Creating Ranges

2016-04-20 Thread Gerald Wiltse
Scratch the part about the side effect... i forgot to remove that line
after adding the exception handling.

Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Apr 20, 2016 at 2:31 AM, Gerald Wiltse <jerrywil...@gmail.com>
wrote:

> For posterity, here's the working form of very short loop for accepting a
> bunch of values in a map which are all in string form.  The goal is to try
> to parsing them to their groovy types, and then assign them to the
> variables on the current object if those variables exist.  This loop will
> be in the constructor for various objects that get "instantiated" from this
> source application.  The exception is needed for plain old string values.
>
> taskProps.each {String k,String v ->
> if (this.hasProperty(tmpKey)) {
> try{
> this[tmpKey] =  new GroovyShell().parse(v).run()
> }catch(MissingPropertyException e){
> this[tmpKey] = v
> }
> }
> }
>
> Groovy really is amazing.
>
>
> It seems the one side-effect is that all string properties will now have
> to be enclosed in quotes, whereas before they did not.
>
> Here are the proofs... Maybe mrhaki can post these examples on his blog.
>
> def r = "1..5"
> assert new GroovyShell().parse("return $r").run() == [1, 2, 3, 4, 5]
>
> def b = "true"
> assert new GroovyShell().parse("return $b").run() == true
>
> def l = "['str1','str2']"
> assert new GroovyShell().parse("return $l").run() == ['str1', 'str2']
>
> def s = "'mystring'"
> assert new GroovyShell().parse("return $s").run() == "mystring"
>
> ​def m = "['key1':'value1','key2':'value2']"
> assert new GroovyShell().parse("return $m").run()​ ==
> ['key1':'value1','key2':'value2']​
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> On Wed, Apr 20, 2016 at 1:57 AM, Gerald Wiltse <jerrywil...@gmail.com>
> wrote:
>
>> Also, thank you so very much for the response!
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>> On Wed, Apr 20, 2016 at 1:57 AM, Gerald Wiltse <jerrywil...@gmail.com>
>> wrote:
>>
>>> Wow, i just wrote that exact code basically... and started responding to
>>> your email, but there were various drawbacks to this approach as I don't
>>> want to have to define handling of every property by name...  Then... it
>>> hit me...
>>>
>>> def v = '1..10'
>>> assert new GroovyShell().parse(v).run() == [1,2,3,4,5]
>>>
>>> It works!!!
>>>
>>> Something about the Eval works just a little bit differently than
>>> GroovyShell i guess.  Perhaps Dierk  can explain.
>>>
>>> Last question, how expensive is this invocation of groovyshell and parse
>>> and all that (resources wise)?  So-so?
>>>
>>>
>>> Gerald R. Wiltse
>>> jerrywil...@gmail.com
>>>
>>>
>>> On Wed, Apr 20, 2016 at 1:48 AM, Guillaume Laforge <glafo...@gmail.com>
>>> wrote:
>>>
>>>> If you know it's a range when parsing that string, you can do this,
>>>> with the toInteger() method:
>>>>
>>>>def rangeString = "123..455"
>>>>def (String min, String max) = rangeString.tokenize("..")
>>>>def range = min.toInteger()..max.toInteger()
>>>>
>>>> On Wed, Apr 20, 2016 at 7:26 AM, Gerald Wiltse <jerrywil...@gmail.com>
>>>> wrote:
>>>>
>>>>> I don't see how that works in my case, maybe i'm missing something.
>>>>>
>>>>> I will clarify:
>>>>>
>>>>> I define a variable in web to represent the range:   14502..14520
>>>>>
>>>>> The web converts this to a string, and passes it into my code.
>>>>>
>>>>> My code then has to receive this string, and then construct a list
>>>>> from it.
>>>>>
>>>>> I could do:
>>>>>
>>>>> String rangeString = passedInVar
>>>>> (String min, String max) = rangeString.tokenize("..")
>>>>> Range range = min..max
>>>>>
>>>>> But i was hoping for a universal "caster" loop which can detect and
>>>>> cast the common types from strings:
>>>>> Integers, lists, ranges, maps, booleans..
>>>>>
>>>>> 12345
>>>>> ["this", "is", "Sample", "List"]
>>>>&g

Re: Methods for Creating Ranges

2016-04-20 Thread Gerald Wiltse
For posterity, here's the working form of very short loop for accepting a
bunch of values in a map which are all in string form.  The goal is to try
to parsing them to their groovy types, and then assign them to the
variables on the current object if those variables exist.  This loop will
be in the constructor for various objects that get "instantiated" from this
source application.  The exception is needed for plain old string values.

taskProps.each {String k,String v ->
if (this.hasProperty(tmpKey)) {
try{
this[tmpKey] =  new GroovyShell().parse(v).run()
}catch(MissingPropertyException e){
this[tmpKey] = v
}
}
}

Groovy really is amazing.


It seems the one side-effect is that all string properties will now have to
be enclosed in quotes, whereas before they did not.

Here are the proofs... Maybe mrhaki can post these examples on his blog.

def r = "1..5"
assert new GroovyShell().parse("return $r").run() == [1, 2, 3, 4, 5]

def b = "true"
assert new GroovyShell().parse("return $b").run() == true

def l = "['str1','str2']"
assert new GroovyShell().parse("return $l").run() == ['str1', 'str2']

def s = "'mystring'"
assert new GroovyShell().parse("return $s").run() == "mystring"

​def m = "['key1':'value1','key2':'value2']"
assert new GroovyShell().parse("return $m").run()​ ==
['key1':'value1','key2':'value2']​

Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Apr 20, 2016 at 1:57 AM, Gerald Wiltse <jerrywil...@gmail.com>
wrote:

> Also, thank you so very much for the response!
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> On Wed, Apr 20, 2016 at 1:57 AM, Gerald Wiltse <jerrywil...@gmail.com>
> wrote:
>
>> Wow, i just wrote that exact code basically... and started responding to
>> your email, but there were various drawbacks to this approach as I don't
>> want to have to define handling of every property by name...  Then... it
>> hit me...
>>
>> def v = '1..10'
>> assert new GroovyShell().parse(v).run() == [1,2,3,4,5]
>>
>> It works!!!
>>
>> Something about the Eval works just a little bit differently than
>> GroovyShell i guess.  Perhaps Dierk  can explain.
>>
>> Last question, how expensive is this invocation of groovyshell and parse
>> and all that (resources wise)?  So-so?
>>
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>> On Wed, Apr 20, 2016 at 1:48 AM, Guillaume Laforge <glafo...@gmail.com>
>> wrote:
>>
>>> If you know it's a range when parsing that string, you can do this, with
>>> the toInteger() method:
>>>
>>>def rangeString = "123..455"
>>>def (String min, String max) = rangeString.tokenize("..")
>>>def range = min.toInteger()..max.toInteger()
>>>
>>> On Wed, Apr 20, 2016 at 7:26 AM, Gerald Wiltse <jerrywil...@gmail.com>
>>> wrote:
>>>
>>>> I don't see how that works in my case, maybe i'm missing something.
>>>>
>>>> I will clarify:
>>>>
>>>> I define a variable in web to represent the range:   14502..14520
>>>>
>>>> The web converts this to a string, and passes it into my code.
>>>>
>>>> My code then has to receive this string, and then construct a list from
>>>> it.
>>>>
>>>> I could do:
>>>>
>>>> String rangeString = passedInVar
>>>> (String min, String max) = rangeString.tokenize("..")
>>>> Range range = min..max
>>>>
>>>> But i was hoping for a universal "caster" loop which can detect and
>>>> cast the common types from strings:
>>>> Integers, lists, ranges, maps, booleans..
>>>>
>>>> 12345
>>>> ["this", "is", "Sample", "List"]
>>>> 14502..14520
>>>> ["key":"value","for":"maps"]
>>>> true
>>>>
>>>> I think eval works for all but ranges.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Gerald R. Wiltse
>>>> jerrywil...@gmail.com
>>>>
>>>>
>>>> On Wed, Apr 20, 2016 at 1:15 AM, Guillaume Laforge <glafo...@gmail.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> You can just replace the bounds with variables.
>>>>>
>>>>> def a = 1
>>>>> de

Re: Methods for Creating Ranges

2016-04-19 Thread Gerald Wiltse
I don't see how that works in my case, maybe i'm missing something.

I will clarify:

I define a variable in web to represent the range:   14502..14520

The web converts this to a string, and passes it into my code.

My code then has to receive this string, and then construct a list from it.

I could do:

String rangeString = passedInVar
(String min, String max) = rangeString.tokenize("..")
Range range = min..max

But i was hoping for a universal "caster" loop which can detect and cast
the common types from strings:
Integers, lists, ranges, maps, booleans..

12345
["this", "is", "Sample", "List"]
14502..14520
["key":"value","for":"maps"]
true

I think eval works for all but ranges.






Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Apr 20, 2016 at 1:15 AM, Guillaume Laforge <glafo...@gmail.com>
wrote:

> Hi,
>
> You can just replace the bounds with variables.
>
> def a = 1
> def b = 10
> def r = a..b
>
> Isn't that what you're looking for?
>
> Guillaume
>
>
> Le mercredi 20 avril 2016, Gerald Wiltse <jerrywil...@gmail.com> a écrit :
>
>> I can find no examples of different ways to create a range.  There's a
>> plethora of examples on what you can do when you start by creating a range
>> like so:  "1..10"
>>
>> But, how does one create a range when the min and max values are stored
>> in variables?  There's no range constructor.  I see that it's a form of a
>> list, but I see no helper methods for dynamically creating ranges given a
>> min and max value.
>>
>> I even tried to get really fancy, but this evaluates to a string.
>>
>> def v = "10..15"
>> assert Eval.x(v, "return x")​.getClass()​.name ==
>> "​​​java.lang.String"​
>>
>> My use case is this.  I populate a bunch of form fields with variable
>> definitions... but they all get passed to my code as strings. But I want to
>> pass port ranges and lists and maps. So, the Eval() method is exactly what
>> I needed.. it just isn't working for ranges.
>>
>> Regards,
>> Jerry
>>
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Product Ninja & Advocate at Restlet <http://restlet.com>
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>
>


Classloader Won't Load Some Classes

2016-04-18 Thread Gerald Wiltse
I have a bunch of classes in different packages called "Datasources" which
are all very similar. They extend an abstract base class, they have quite a
few dependencies and implement some traits.  They also use
@InheritConstructors annotation.

I am unable to load any of them using newInstance() :

import com.gsi.monitor.loader.CustomLoader
URLClassLoader loader = CustomLoader.getCustomLoader("master")
Datasource dsi =
loader.loadClass("com.gsi.monitor.updater.global.Datasource").newInstance()
dsi.run()
println dsi.output

Error:unable to resolve class Datasource


What I find interesting, is that several other classes load as expected,
and that the error is "unable to resolve".   The other classes I've tested
are simpler classes, so I'm wondering what it is about the "Datasource"
classes that us causing them to fail.  Could it be the annotations, or
dependencies, etc?

Note: These are running inside the script engine of Logicmonitor monitoring
platform.   It has groovy-all-2.3.0 library.

Any ideas?



Gerald R. Wiltse
jerrywil...@gmail.com


Re: ServerSocket , Chunked data , and BufferedReader

2016-04-12 Thread Gerald Wiltse
For what it's worth, your blog, and your presentations have kept me very
motivated about learning Groovy. I still refer to them often. Also, I can
say the same about many of the contributors and people on this list as
well. I am grateful to all.

Gerald R. Wiltse
jerrywil...@gmail.com


On Tue, Apr 12, 2016 at 2:14 PM, Guillaume Laforge <glafo...@gmail.com>
wrote:

> Ah ah, yes, it's been such a long time, and I've got such a huge backlog
> :-O
> I'd need to automate that process, because it's quite time consuming, and
> perhaps even gather a team of a handful of us to collaborate, collect and
> curate all those news items!
> Resurrecting has been on my long todo list for a while!
>
> Guillaume
>
> On Tue, Apr 12, 2016 at 7:59 PM, Gerald Wiltse <jerrywil...@gmail.com>
> wrote:
>
>> Also, looking forward to a fresh post soon... will you have time to do
>> one?
>>
>> http://glaforge.appspot.com/
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>> On Tue, Apr 12, 2016 at 12:58 PM, Gerald Wiltse <jerrywil...@gmail.com>
>> wrote:
>>
>>> Yes you are right about the readLine().  I remember now that my problem
>>> was actually that the inputStream created by withStreams has "readLines()"
>>> method but not a "readLine()" method. Then I could process each line
>>> directly from the intputStream wouldn't even need the reader.
>>>
>>> Gerald R. Wiltse
>>> jerrywil...@gmail.com
>>>
>>>
>>> On Tue, Apr 12, 2016 at 12:40 PM, Guillaume Laforge <glafo...@gmail.com>
>>> wrote:
>>>
>>>> Oh and actually, when you do input.withReader { reader -> ... }
>>>> this is actually a BufferedReader that Groovy gives you.
>>>> So you can use BufferedReader's readLine() method!
>>>>
>>>> On Tue, Apr 12, 2016 at 6:39 PM, Guillaume Laforge <glafo...@gmail.com>
>>>> wrote:
>>>>
>>>>> Ah good point.
>>>>> Well, it's possible to break out of the eachLine call... by throwing
>>>>> an exception, although it makes the code a little less elegant obviously.
>>>>>
>>>>> On Tue, Apr 12, 2016 at 6:27 PM, Gerald Wiltse <jerrywil...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Thank you for the response!
>>>>>>
>>>>>> I had it that way when I started.  The problem with using
>>>>>> reader.eachLine{}  is there is no way to break out after a specific 
>>>>>> number
>>>>>> of lines have been received (other than using a GroovyRuntimeException,
>>>>>> which is undesirable).
>>>>>>
>>>>>>Ref:
>>>>>> http://stackoverflow.com/questions/9916261/groovy-inputstream-reading-closure-hanging
>>>>>> )
>>>>>>
>>>>>> I was sad to discover that there's an eachLine{} method,  but not a
>>>>>> readLine() method on the reader.  In my case (and perhaps many others)
>>>>>> readLine() would cut out the need for the construction of the
>>>>>> BufferedReader and InputStreamReader.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Gerald R. Wiltse
>>>>>> jerrywil...@gmail.com
>>>>>>
>>>>>>
>>>>>> On Tue, Apr 12, 2016 at 12:19 PM, Guillaume Laforge <
>>>>>> glafo...@gmail.com> wrote:
>>>>>>
>>>>>>> You can do an input.withReader { reader -> ... } to have a buffered
>>>>>>> reader on the input stream.
>>>>>>> And with that reader, you can do reader.eachLine { String s -> ... }
>>>>>>> to iterate over all the lines.
>>>>>>> Last interesting nugget, there's also the class
>>>>>>> groovy.io.LineColumnReader potentially, if you're interested in keeping
>>>>>>> track of the position (column and line number) in the file.
>>>>>>>
>>>>>>> Guillaume
>>>>>>>
>>>>>>> On Tue, Apr 12, 2016 at 5:53 PM, Gerald Wiltse <
>>>>>>> jerrywil...@gmail.com> wrote:
>>>>>>>
>>>>>>>> I'm trying to use a "ServerSocket" to receive HTTP messages from a
>>>>>>>> client which is POSTing them as chunked.  I just want to capture the 
>>>>

Re: ServerSocket , Chunked data , and BufferedReader

2016-04-12 Thread Gerald Wiltse
Also, looking forward to a fresh post soon... will you have time to do one?

http://glaforge.appspot.com/

Gerald R. Wiltse
jerrywil...@gmail.com


On Tue, Apr 12, 2016 at 12:58 PM, Gerald Wiltse <jerrywil...@gmail.com>
wrote:

> Yes you are right about the readLine().  I remember now that my problem
> was actually that the inputStream created by withStreams has "readLines()"
> method but not a "readLine()" method. Then I could process each line
> directly from the intputStream wouldn't even need the reader.
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> On Tue, Apr 12, 2016 at 12:40 PM, Guillaume Laforge <glafo...@gmail.com>
> wrote:
>
>> Oh and actually, when you do input.withReader { reader -> ... }
>> this is actually a BufferedReader that Groovy gives you.
>> So you can use BufferedReader's readLine() method!
>>
>> On Tue, Apr 12, 2016 at 6:39 PM, Guillaume Laforge <glafo...@gmail.com>
>> wrote:
>>
>>> Ah good point.
>>> Well, it's possible to break out of the eachLine call... by throwing an
>>> exception, although it makes the code a little less elegant obviously.
>>>
>>> On Tue, Apr 12, 2016 at 6:27 PM, Gerald Wiltse <jerrywil...@gmail.com>
>>> wrote:
>>>
>>>> Thank you for the response!
>>>>
>>>> I had it that way when I started.  The problem with using
>>>> reader.eachLine{}  is there is no way to break out after a specific number
>>>> of lines have been received (other than using a GroovyRuntimeException,
>>>> which is undesirable).
>>>>
>>>>Ref:
>>>> http://stackoverflow.com/questions/9916261/groovy-inputstream-reading-closure-hanging
>>>> )
>>>>
>>>> I was sad to discover that there's an eachLine{} method,  but not a
>>>> readLine() method on the reader.  In my case (and perhaps many others)
>>>> readLine() would cut out the need for the construction of the
>>>> BufferedReader and InputStreamReader.
>>>>
>>>>
>>>>
>>>> Gerald R. Wiltse
>>>> jerrywil...@gmail.com
>>>>
>>>>
>>>> On Tue, Apr 12, 2016 at 12:19 PM, Guillaume Laforge <glafo...@gmail.com
>>>> > wrote:
>>>>
>>>>> You can do an input.withReader { reader -> ... } to have a buffered
>>>>> reader on the input stream.
>>>>> And with that reader, you can do reader.eachLine { String s -> ... }
>>>>> to iterate over all the lines.
>>>>> Last interesting nugget, there's also the class
>>>>> groovy.io.LineColumnReader potentially, if you're interested in keeping
>>>>> track of the position (column and line number) in the file.
>>>>>
>>>>> Guillaume
>>>>>
>>>>> On Tue, Apr 12, 2016 at 5:53 PM, Gerald Wiltse <jerrywil...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> I'm trying to use a "ServerSocket" to receive HTTP messages from a
>>>>>> client which is POSTing them as chunked.  I just want to capture the text
>>>>>> content being posted (plain text).  Any input on how to do this better
>>>>>> would be welcomed.
>>>>>>
>>>>>> Here is my existing and very not-elegant solution.  When dealing with
>>>>>> ServerSocket, one has to handle the headers and chunk barriers manually,
>>>>>> and this is what I came up with.  I looked at filterline method on the
>>>>>> reader, maybe that's part of a solution, i'm not sure.
>>>>>>
>>>>>>
>>>>>> socket.withStreams { input, output ->
>>>>>> BufferedReader reader = new BufferedReader(new
>>>>>> InputStreamReader(input))
>>>>>> while (currentLineCount < processor.newLineCount) {
>>>>>> line = reader.readLine()
>>>>>>
>>>>>> if (line && line.size() > 3) {
>>>>>> processor.processFormats(line)
>>>>>> }
>>>>>> currentLineCount++
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Caveats:
>>>>>>
>>>>>> 1.  I have been trying to process line by line to minimize memory
>>>>>> impact, rather than buffering the whole collection. I'd like to keep it
>>>>>> that way.
>>>

Re: ServerSocket , Chunked data , and BufferedReader

2016-04-12 Thread Gerald Wiltse
Thank you for the response!

I had it that way when I started.  The problem with using reader.eachLine{}
 is there is no way to break out after a specific number of lines have been
received (other than using a GroovyRuntimeException, which is undesirable).

   Ref:
http://stackoverflow.com/questions/9916261/groovy-inputstream-reading-closure-hanging
)

I was sad to discover that there's an eachLine{} method,  but not a
readLine() method on the reader.  In my case (and perhaps many others)
readLine() would cut out the need for the construction of the
BufferedReader and InputStreamReader.



Gerald R. Wiltse
jerrywil...@gmail.com


On Tue, Apr 12, 2016 at 12:19 PM, Guillaume Laforge <glafo...@gmail.com>
wrote:

> You can do an input.withReader { reader -> ... } to have a buffered reader
> on the input stream.
> And with that reader, you can do reader.eachLine { String s -> ... } to
> iterate over all the lines.
> Last interesting nugget, there's also the class groovy.io.LineColumnReader
> potentially, if you're interested in keeping track of the position (column
> and line number) in the file.
>
> Guillaume
>
> On Tue, Apr 12, 2016 at 5:53 PM, Gerald Wiltse <jerrywil...@gmail.com>
> wrote:
>
>> I'm trying to use a "ServerSocket" to receive HTTP messages from a client
>> which is POSTing them as chunked.  I just want to capture the text content
>> being posted (plain text).  Any input on how to do this better would be
>> welcomed.
>>
>> Here is my existing and very not-elegant solution.  When dealing with
>> ServerSocket, one has to handle the headers and chunk barriers manually,
>> and this is what I came up with.  I looked at filterline method on the
>> reader, maybe that's part of a solution, i'm not sure.
>>
>>
>> socket.withStreams { input, output ->
>> BufferedReader reader = new BufferedReader(new InputStreamReader(input))
>> while (currentLineCount < processor.newLineCount) {
>> line = reader.readLine()
>>
>> if (line && line.size() > 3) {
>> processor.processFormats(line)
>> }
>> currentLineCount++
>> }
>> }
>>
>>
>> Caveats:
>>
>> 1.  I have been trying to process line by line to minimize memory impact,
>> rather than buffering the whole collection. I'd like to keep it that way.
>>
>>
>> 2.  These 4 Jetty libraries are available on the classpath, so I could
>> leverage them, but can't add other libraries.
>>
>> compile 'org.eclipse.jetty:jetty-server:8.1.2.v20120308'
>> compile 'org.eclipse.jetty:jetty-continuation:8.1.2.v20120308'
>> compile 'org.eclipse.jetty:jetty-io:8.1.2.v20120308'
>> compile 'org.eclipse.jetty:jetty-util:8.1.2.v20120308'
>>
>> I would make the Service and Handler in Jetty, but I can't find any good
>> examples that fit my situation.
>>
>>
>>
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Product Ninja & Advocate at Restlet <http://restlet.com>
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>


BountySource Salt For Groovy Project

2016-04-06 Thread Gerald Wiltse
https://salt.bountysource.com/

I have no experience with this service, and have not researched it deeply,
but on the surface it seems like it might something relevant to the Groovy
Language.  I discovered it just now and wanted to share it with this group.


Regards,
Jerry

Gerald R. Wiltse
jerrywil...@gmail.com


Re: Groovy Certifications

2016-03-31 Thread Gerald Wiltse
Thanks to you both for responding!

Gerald R. Wiltse
jerrywil...@gmail.com


On Thu, Mar 31, 2016 at 1:03 AM, Guillaume Laforge <glafo...@gmail.com>
wrote:

> Indeed no certifications that I'm aware of.
>
> Guillaume
>
>
> Le jeudi 31 mars 2016, Gerald Wiltse <jerrywil...@gmail.com> a écrit :
>
>> I did not receive any response to this.  Can anyone please confirm that
>> there are no known certifications for Groovy?
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>> On Fri, Mar 25, 2016 at 12:13 PM, Gerald Wiltse <jerrywil...@gmail.com>
>> wrote:
>>
>>> Hello,
>>>
>>> Are there any known certification tracks one can pursue specific to
>>> groovy development?
>>>
>>> Gerald R. Wiltse
>>> jerrywil...@gmail.com
>>>
>>>
>>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Product Ninja & Advocate at Restlet <http://restlet.com>
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>
>


Groovy Certifications

2016-03-25 Thread Gerald Wiltse
Hello,

Are there any known certification tracks one can pursue specific to groovy
development?

Gerald R. Wiltse
jerrywil...@gmail.com


Groovy MBean to JsonBuilder

2016-03-21 Thread Gerald Wiltse
I'm working with some MBeans from an Oracle application.  In summary, it
seems that JsonBuilder can process an mbean, but not a GroovyMBean.  Is
this expected behavior?  It might not even be worth doing, it was just a
surprise.

The following

println new JsonBuilder(mbean).toPrettyString()
println new JsonBuilder(new GroovyMBean(mbserver,
mbean)).toPrettyString()


Results in the following:

{
"propertyPattern": false,
"canonicalKeyPropertyListString":
"instanceName=PD80,targetType=webserver",
"keyPropertyList": {
"instanceName": "PD80",
"targetType": "webserver"
},
"serializedNameString": "jde:targetType=webserver,instanceName=PD80",
"propertyValuePattern": false,
"propertyListPattern": false,
"canonicalName": "jde:instanceName=PD80,targetType=webserver",
"domain": "jde",
"domainPattern": false,
"keyPropertyListString": "targetType=webserver,instanceName=PD80",
"pattern": false
}
{

}



Gerald R. Wiltse
jerrywil...@gmail.com


Casting GroovyMbean as custom class

2016-03-20 Thread Gerald Wiltse
Hello,

I'm gathering a number of GroovyMBeans from remote servers over JMX, and I
have them each modeled with a custom classes.  I was hoping to be able to
simply cast the MBean as the other object type but get this error:

 with class 'groovy.util.GroovyMBean' to class
'com.dev.core.JdeInstanceBean'"

Is my goal even possible?

I think groovy would make it easy to do manually copy all the applicable
attributes/values from the GroovyMbean to a new instance of my class, but I
wanted to avoid that if possible.



Gerald R. Wiltse
jerrywil...@gmail.com


Re: Expando as a Trait?

2016-03-19 Thread Gerald Wiltse
Yes indeed.   Just as Tim posted here, the basics of this functionality can
be manually.

http://stackoverflow.com/questions/7078855/groovy-dynamically-add-properties-to-groovy-classes-from-inside-class-methods

However, his comment points out the fact that groovy expando is a nicely
polished and mature implementation of a dynamic object.

https://github.com/apache/groovy/blob/master/src/main/groovy/util/Expando.java

It just seems undesirable to manually add this boilerplate code into every
object I create in the future (where i want dynamic), when traits are so
nice in groovy.


Gerald R. Wiltse
jerrywil...@gmail.com


On Fri, Mar 18, 2016 at 12:03 PM, Cédric Champeau <cedric.champ...@gmail.com
> wrote:

> I think what you are suggesting is close to this example in the docs:
> http://groovy-lang.org/objectorientation.html#_dynamic_methods_in_a_trait
>
> Am I right?
>
> 2016-03-18 16:51 GMT+01:00 Gerald Wiltse <jerrywil...@gmail.com>:
>
>> Expando is a pretty cool object. And if we extend it, we get it's really
>> nice "behavior". Unfortunately, as extending = inheritance, thus extending
>> expando precludes us from extending our true parent classes. This is why
>> implementing interfaces and traits is often a better choice than
>> inheriting, especially when one just wants to compose behaviors such as
>> those offered by expando.
>>
>> Which leads me to ask the question: is it crazy to suggest that the body
>> of Expando would actually make a good Trait?   Has this been discussed
>> before?
>>
>> I'm novice so there could be obvious reasons not to do this which I'm not
>> aware of.
>>
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>


Expando as a Trait?

2016-03-19 Thread Gerald Wiltse
Expando is a pretty cool object. And if we extend it, we get it's really
nice "behavior". Unfortunately, as extending = inheritance, thus extending
expando precludes us from extending our true parent classes. This is why
implementing interfaces and traits is often a better choice than
inheriting, especially when one just wants to compose behaviors such as
those offered by expando.

Which leads me to ask the question: is it crazy to suggest that the body of
Expando would actually make a good Trait?   Has this been discussed before?

I'm novice so there could be obvious reasons not to do this which I'm not
aware of.


Gerald R. Wiltse
jerrywil...@gmail.com


Re: building a jar from groovy script with gradle

2016-03-08 Thread Gerald Wiltse
I have a similar situation I am about to tackle, building an installer that
executes Groovy code. This will be going to clients and run on windows, so
it really has to be an EXE.

Anybody have good experience with JAR-to-EXE packers or something?

Gerald R. Wiltse
jerrywil...@gmail.com


On Tue, Mar 8, 2016 at 8:42 AM, Winnebeck, Jason <
jason.winneb...@windstream.com> wrote:

> I've "deployed" some scripts to other users in my organization where Java
> but not Groovy is installed through the GroovyWrapper script. I got it from
> Codehaus and I can't find the original copy anywhere but I found a fork of
> it at https://github.com/sdanzan/groovy-wrapper that appears to have more
> features than the original. The original I have basically just uses the Ant
> inside of the Groovy distribution to compile a single Groovy file and merge
> that file, embeddable groovy JAR and some of the Groovy libs into a single
> jar you can run with java -jar.
>
> Looking at the code it appears the main difference in that updated script
> is that it supports adding @Grab'd dependencies into the single JAR,
> presumably to prevent users from having to download them.
>
> Jason
>
> -Original Message-
> From: Jim Northrop [mailto:james.b.north...@googlemail.com]
> Sent: Tuesday, March 08, 2016 8:19 AM
> To: users@groovy.apache.org
> Subject: Re: building a jar from groovy script with gradle
>
> Out of interest, what is the typical deployment strategy for a runnable
> Groovy class w/main method? I have been trying to make a user executable
> jar but as 2 diff.jars. One jar is only my code, no support jars and 2nd is
> mystuff-all-v1.0.jar as a bundle w/all dependency jars included hence
> runnable. End user can choose jar.
>
>  Are there other strategies to package code 4 deployment?
> Thx.
>
> Sent from my iPad
>
> > On 8 Mar 2016, at 11:45, Schalk Cronjé  wrote:
> >
> > I can spot a number of issues in your Gradle script, howver I need to
> understand context.
> >
> > [1] Are you trying to put a single Groovy script + required Groovy JARs
> into a JAR?
> >
> > OR
> >
> > [2] Are you trying to build a proper Groovy application consisting of a
> coouple of class files en dependent JARs?
> >
> >> On 08/03/2016 10:33, Raphael Bauduin wrote:
> >>
> >> Hi,
> >>
> >> I'm trying to package a groovy script as a jar with the help of
> >> gradle, I use this gradle config: http://pastebin.com/RFEhzMCp
> >>
> >> it builds fine, but when I try to run it with java -jar path_to.jar I
> >> get this error:
> >> Error: A JNI error has occurred, please check your installation and
> >> try again Exception in thread "main" java.lang.SecurityException:
> >> Invalid signature file digest for Manifest main attributes
> >>
> >> The only suggestions I found online applied when people repackaged
> jars, which is not my case.
> >> Any suggestion?
> >>
> >> Thanks
> >>
> >> Rb
> >
> >
> > --
> > Schalk W. Cronjé
> > Twitter / Ello / Toeter : @ysb33r
> >
>
> --
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>


Examples of Pure Groovy Libraries for REST Services

2016-03-07 Thread Gerald Wiltse
I'm a novice developer, working on developing my first wrapper library for
a REST API.  I want it to be robust, flexible, and repeatable for future
REST API's.  I am looking for examples of wrapper libraries for different
web api's written in pure Groovy (not Java). The more complicated the API,
the better. Also, I would prefer those that use
groovyx.net.http.RESTClient, since that's what I'm using.

I want to see different ways of modeling the objects and the API's, since
there are truly an infinite number of ways to approach it.

Thanks in advance.

Regards,
Jerry

Gerald R. Wiltse
jerrywil...@gmail.com


Re: JSONBuilder Option to Only Include NonNull values

2016-03-06 Thread Gerald Wiltse
Sorry, was on my list today. I hope this year to be able to start
contributing consistently.

Gerald R. Wiltse
jerrywil...@gmail.com


On Sun, Mar 6, 2016 at 1:56 PM, Pascal Schumacher <pascalschumac...@gmx.net>
wrote:

> Hi Gerald,
>
> thanks for the kind words. :)
>
> As I did not find any issue for this I created one myself:
> https://issues.apache.org/jira/browse/GROOVY-7780
>
> Cheers,
> Pascal
>
>
> Am 05.03.2016 um 16:37 schrieb Gerald Wiltse:
>
> You got it, thanks for all your hard work on the project!
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> On Sat, Mar 5, 2016 at 4:41 AM, Pascal Schumacher <
> pascalschumac...@gmx.net> wrote:
>
>> Hi Gerald,
>>
>> please create an enhancement request for the groovy JSON component at
>> https://issues.apache.org/jira/browse/GROOVY/component/12326643/ to
>> request a feature.
>>
>> Thanks,
>> Pascal
>>
>>
>> Am 04.03.2016 um 20:51 schrieb Gerald Wiltse:
>>
>> I just found this article which describes the problem perfectly and there
>> are several good workarounds.
>>
>>
>> http://stackoverflow.com/questions/14749817/exclude-null-values-using-jsonbuilder-in-groovy
>>
>> Apparently, it's a native feature of Jackson, which makes me think it's
>> probably available in lots of JSON API's.
>>
>> Any chance this feature could get on the roadmap for JSON Builder (and
>> slurper for that matter)?
>>
>>
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>>
>
>


Re: Groovy Hash Calculations

2016-03-04 Thread Gerald Wiltse
Thank you very much Jason, that helps a lot.

Gerald R. Wiltse
jerrywil...@gmail.com


On Fri, Mar 4, 2016 at 11:30 AM, Winnebeck, Jason <
jason.winneb...@windstream.com> wrote:

> Only the “short” solution I wrote involved buffering to memory. The “long”
> solution I wrote involves no buffering. The DigestInputStream is not
> related to whether or not there is buffering, all it does is it lets you
> read the stream and get a digest at the same time. If you are just throwing
> out the data, there’s no need for the DigestInputStream. DigestInputStream
> just takes the result of every read call and sends the bytes to
> MessageDigest#update before returning the data. DigestInputStream makes
> sense if you were, for example, passing that input stream to another method
> that wrote the content to a file then you wanted to get the digest after
> the file write was complete.
>
>
>
> Jason
>
>
>
> *From:* Gerald Wiltse [mailto:jerrywil...@gmail.com]
> *Sent:* Friday, March 04, 2016 10:08 AM
> *To:* users@groovy.apache.org
> *Subject:* Re: Groovy Hash Calculations
>
>
>
> I'm trying to verify the sha1 hash on a file download without saving it to
> disk, and without buffering the whole thing.  I think this solution might
> buffer all the data into "content" before going into the eachByte loop. I
> thought that was the reason for the DigestInputStream.  Do you know if this
> is correct?
>
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
>
>
>
> On Fri, Mar 4, 2016 at 9:40 AM, Winnebeck, Jason <
> jason.winneb...@windstream.com> wrote:
>
> Here is how I would do it. I provide both a “short” solution and a “long”
> one. I would use the “short” solution if I was making for example a
> developer only tool and I knew I was only hashing small things for example
> a configuration file in a build script and want a one-liner. Otherwise I’d
> use the “long” version.
>
>
>
> //If the content is guaranteed to be short:
>
> def content = new ByteArrayInputStream("Here be dragons".bytes)
>
> println MessageDigest.getInstance("SHA1").digest(content.bytes).encodeHex()
>
>
>
> //If the content might be arbitrarily long:
>
> content = new ByteArrayInputStream("Here be dragons".bytes)
>
> def digest = MessageDigest.getInstance("SHA1")
>
> content.eachByte(4096) { bytes, len ->
>
>   digest.update(bytes, 0, len)
>
> }
>
> println digest.digest().encodeHex()
>
>
>
> Jason
>
>
>
> *From:* Gerald Wiltse [mailto:jerrywil...@gmail.com]
> *Sent:* Friday, March 04, 2016 9:18 AM
> *To:* users@groovy.apache.org
> *Subject:* Groovy Hash Calculations
>
>
>
> Hello All,
>
>
>
> I have this block, it's pretty compressed, just wondering if there is a
> more groovy way to handle reading the buffer and computing the hash.
>
>
>
> def messageDigest = MessageDigest.getInstance("SHA1")
>
> def dis = new DigestInputStream(content, messageDigest)
>
> byte[] buffer = new byte[1024];
>
> while (dis.read(buffer) != -1) {}
>
> def sha1Hex = new BigInteger(1,
> messageDigest.digest()).toString(16).padLeft(40, '0')
>
>
>
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> --
>
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>
>
>


Re: Groovy Hash Calculations

2016-03-04 Thread Gerald Wiltse
I'm trying to verify the sha1 hash on a file download without saving it to
disk, and without buffering the whole thing.  I think this solution might
buffer all the data into "content" before going into the eachByte loop. I
thought that was the reason for the DigestInputStream.  Do you know if this
is correct?

Gerald R. Wiltse
jerrywil...@gmail.com


On Fri, Mar 4, 2016 at 9:40 AM, Winnebeck, Jason <
jason.winneb...@windstream.com> wrote:

> Here is how I would do it. I provide both a “short” solution and a “long”
> one. I would use the “short” solution if I was making for example a
> developer only tool and I knew I was only hashing small things for example
> a configuration file in a build script and want a one-liner. Otherwise I’d
> use the “long” version.
>
>
>
> //If the content is guaranteed to be short:
>
> def content = new ByteArrayInputStream("Here be dragons".bytes)
>
> println MessageDigest.getInstance("SHA1").digest(content.bytes).encodeHex()
>
>
>
> //If the content might be arbitrarily long:
>
> content = new ByteArrayInputStream("Here be dragons".bytes)
>
> def digest = MessageDigest.getInstance("SHA1")
>
> content.eachByte(4096) { bytes, len ->
>
>   digest.update(bytes, 0, len)
>
> }
>
> println digest.digest().encodeHex()
>
>
>
> Jason
>
>
>
> *From:* Gerald Wiltse [mailto:jerrywil...@gmail.com]
> *Sent:* Friday, March 04, 2016 9:18 AM
> *To:* users@groovy.apache.org
> *Subject:* Groovy Hash Calculations
>
>
>
> Hello All,
>
>
>
> I have this block, it's pretty compressed, just wondering if there is a
> more groovy way to handle reading the buffer and computing the hash.
>
>
>
> def messageDigest = MessageDigest.getInstance("SHA1")
>
> def dis = new DigestInputStream(content, messageDigest)
>
> byte[] buffer = new byte[1024];
>
> while (dis.read(buffer) != -1) {}
>
> def sha1Hex = new BigInteger(1,
> messageDigest.digest()).toString(16).padLeft(40, '0')
>
>
>
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
> --
> This email message and any attachments are for the sole use of the
> intended recipient(s). Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the intended recipient, please
> contact the sender by reply email and destroy all copies of the original
> message and any attachments.
>


Groovy Hash Calculations

2016-03-04 Thread Gerald Wiltse
Hello All,

I have this block, it's pretty compressed, just wondering if there is a
more groovy way to handle reading the buffer and computing the hash.

def messageDigest = MessageDigest.getInstance("SHA1")
def dis = new DigestInputStream(content, messageDigest)
byte[] buffer = new byte[1024];
while (dis.read(buffer) != -1) {}
def sha1Hex = new BigInteger(1,
messageDigest.digest()).toString(16).padLeft(40, '0')


Gerald R. Wiltse
jerrywil...@gmail.com


Groovy Wrapper for Bintray API

2016-02-29 Thread Gerald Wiltse
I don't suppose anyone has created a groovy wrapper "library" for bintray
have they?  Just hoping to get lucky.  As I set out to write my third such
a wrapper for a popular REST API in 2 months, i keep thinking "haven't 100
people already done this work?".

I checked, and Bintray hasn't done the swagger thing yet.  They have a
bintray java library which is great, but there's no documentation other
than the test cases, and I could not make sense of it. I even emailed them
for assistance but they said "Just use the API".


Regards,
Jerry


Gerald R. Wiltse
jerrywil...@gmail.com


Re: Confirming getProperties() works differently (inside vs outside)

2016-02-29 Thread Gerald Wiltse
Ok, so it's a symptom of calling withTraits dynamically, now it makes
sense. That's much less common of a use case than standard trait
implementation.

While I would think a "groovy reflection" feature to capture these types of
properties would make a lot of sense, I can see this being very difficult
if not impossible, since it would require someone to override "this"
keyword, and replace it with new reflection logic.  I guess if someone
decided to try to such a feature, it would be better to use a different
keyword like thisMeta or something. The workaround from dinko is extremely
easy considering the problem. Thanks both of you.

Gerald R. Wiltse
jerrywil...@gmail.com


On Mon, Feb 29, 2016 at 8:17 AM, Jochen Theodorou <blackd...@gmx.org> wrote:

>
>
> On 29.02.2016 03:23, Gerald Wiltse wrote:
>
>> Is there a way for the Chameleon class to ever see that it has a
>> "lastColor" property?
>>
>> class Chameleon{
>>  String color = "green"
>>
>>  void printAllMyProperties(){
>>   this.properties.each{println it}
>>  }
>>
>> }
>>
>> trait ColorChanging {
>>  String lastColor
>>  def changeColor = {newcolor ->
>>  lastColor = this.color
>>  this.color = newcolor
>>  }
>> }
>>
>
> in case of Chameleon implements ColorChanging the answer is yes. In case of
>
> def mylizard = new Chameleon().withTraits(ColorChanging)
>>
>> mylizard.changeColor(blue)
>>
>> mylizard.printAllMyProperties()
>> mylizard.properties.each{println it}
>>
>
> ... no. Here Chameleon does not know anything about the trait and the
> trait isused like a facade around the object. For the same reason mylizard
> is an instance of ColorChanging, but not of Chameleon anymore
>
> It could probably made possible, if you change the meta class used for the
> Chameleon object you proxy with the trait. But there is no such
> implementation right now
>
> bye Jochen
>


Re: [ANN] Geb 0.13.1 released

2016-02-25 Thread Gerald Wiltse
Thank you for following up. Sadly, real drivers and xvfb are not available
in the restrictions of my environment.  I agree about GhostDriver, i have
been looking for alternatives for several months.  It's sad to me, since it
got so far and then just died on the vine. I guess these things happen in
OSS world.  Rather than 25 people contributing effort to one robust
project maturing project, we have 25 "somethingJS" projects, all of which
are 85% the same, with 15% uniqueness. Maybe it's a healthy thing, but it
doesn't feel that way from my point of view.

I was looking at jBrowserDriver just this week, and will be testing it
next. Alternatively, I will try launching phantomjs using cli rather than
the java library, since that will tell me the PID.

Anyway, thanks for all your hard work on GEB, i'm sure i'll be using it
eventually.

If possible, try to think about the use case of constant web server
monitoring in future design.  It can already be used that way (for those
who get around the driver problem).  However, maybe there are things you
might do differently in the future keeping the monitoring scenarios in
mind. Maybe things that selenium doesn't do, because they don't generally
seem to be aware of the monitoring use case either (despite the fact that
new relic is built on selenium).

Regards,
Jerry

Gerald R. Wiltse
jerrywil...@gmail.com


On Thu, Feb 25, 2016 at 4:41 PM, Marcin Erdmann <marcin.erdm...@proxerd.pl>
wrote:

> Gerald,
>
> Geb is a wrapper around Selenium so if you have issues with the WebDriver
> implementation you're using then unfortunately there isn't much that Geb
> can do for you.
>
> I would advise against using GhostDriver given that it is unmaintained at
> the moment: https://github.com/detro/ghostdriver#help-needed. I found
> that using a real browser like Firefox or Chrome and running it on a
> headless server in a virtual display (Xvfb) is way more reliable than using
> headless drivers. This is for example the setup I'm using to run functional
> tests in SnapCI on my current project. I have never tried using
> jBrowserDriver though, maybe it's worth trying out:
> https://github.com/MachinePublishers/jBrowserDriver. Feels like it's
> worth trying to run Geb's suite using it -
> https://github.com/geb/issues/issues/426.
>
> Marcin
>
> On Tue, Feb 23, 2016 at 1:17 PM, Gerald Wiltse <jerrywil...@gmail.com>
> wrote:
>
>> Marcin,
>>
>> I've been using selenium and phantomjs/ghostdriver in Groovy to do
>> headless monitoring of a web application for a while now.  We'll probably
>> switch to GEB, but our biggest issue is that PhantomJS keeps leaving hung
>> processes due to unknown conditions, and because we cannot retrieve the PID
>> of the phantomJS process upon instantiation, we don't have an effective way
>> to forcibly terminate it.  Based on your experience, do you think it's
>> possible to solve our issue under GEB?
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com
>>
>>
>> On Mon, Feb 22, 2016 at 4:42 PM, Marcin Erdmann <
>> marcin.erdm...@proxerd.pl> wrote:
>>
>>> Version 0.13.1 of Geb is now available from Maven Central.
>>>
>>> The 0.13.1 version is released to address a regression discovered in the
>>> 0.13.0 release (https://github.com/geb/issues/issues/422) as well as
>>> two concurrency related issues (https://github.com/geb/issues/issues/421
>>> , https://github.com/geb/issues/issues/423).
>>>
>>> Thanks,
>>> Marcin
>>>
>>
>>
>


Re: Groovy Extension Method - Collection or GroovyMbean

2016-02-18 Thread Gerald Wiltse
I really like the GPath idea, sadly, i have many other math functions
besides sum that i need to use, so I'll put it on LIST and not arraylist.
Thank you!

Gerald R. Wiltse
jerrywil...@gmail.com


On Thu, Feb 18, 2016 at 2:28 PM, Alexander Klein <i...@aklein.org> wrote:

> If your calculations need the List, put it to List, not the ArrayList, but
> check inside if all elements are of type GroovyMbeans.
> If you can go with GPath like e.g. list.doIt().sum() that returns a List
> with all the results of doIt and then sums it, then put it to GroovyMbeans
> directly.
>
> Regards,
> Sascha
>
>
> Am 18.02.2016 um 18:26 schrieb Gerald Wiltse:
>
> I want to do a bunch of calculations and combinations around collections
> of GroovyMbeans.  I want to add these "Functions/Formulas" as methods.
> Would it be wiser to add these to the ArrayList class, or to GroovyMbean
> class?
>
> Regards,
> Jerry
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
>


Re: Behavior of .with() inside Trait

2016-02-11 Thread Gerald Wiltse
Thanks for the input Schalk,

Can anyone else indicate if this looks like a bug, or an intended
behavior?  If so, I can submit the bug.

Gerald R. Wiltse
jerrywil...@gmail.com


On Wed, Feb 10, 2016 at 11:04 AM, Schalk Cronjé <ysb...@gmail.com> wrote:

> The interesting thing about this for me is that for
>
>   binding.with {
> println cow
>   }
>
> the generated code is
>
> public static java.lang.Object action(Foo $self) {
> return $self .binding.with({
> return $self.println( $self .cow)
> }.rehydrate($self, $self, $self))
> }
>
> but for
>
>   println binding.cow
>
> the generated code is
>
>public static java.lang.Object action(Foo $self) {
> return $self.println( $self .binding.cow)
>
> }
>
>
> On 10/02/2016 16:52, Gerald Wiltse wrote:
>
> This example returns the error inside the with closure:
>
>   "No such property: cow for class:Bar"
>
> It seems .with() in a trait does not resolve the way it "normally" does.
>
>
> trait Foo {
> def action() {
> println binding.cow
> binding.with {
> println cow
> }
> }
> }
>
> class Bar implements Foo {
>   Binding binding = new Binding()
> }
>
>
> def myBar = new Bar()
> myBar.binding.cow = "says moo"
> myBar.action()
>
>
> If anyone has any insight, it would be helpful.
>
>
> Gerald R. Wiltse
> jerrywil...@gmail.com
>
>
>
> --
> Schalk W. Cronjé
> Twitter / Ello / Toeter : @ysb33r
>
>


Expert Groovy Consulting

2016-01-13 Thread Gerald Wiltse
All,

We are looking for someone who is familiar with all the latest and most
powerful features of Groovy to help us re-write our existing codebase for
monitoring using these features.  Does anyone on this list teach or do
freelance groovy development like this?  We want to do the best "top-down
re-architecture" the best way possible (given the current situation).

I'm in the middle of redoing some plumbing, and I can't get over the
frustrating notion that we are doing things the old school Java way, and
not taking advantage of all the efficiencies of Groovy.  More importantly,
we're not learning and evolving the way we should be. We're just trying to
use old concepts in a new language.

Any advice or guidance would be helpful.


Gerald R. Wiltse
jerrywil...@gmail.com


Re: Community Support for Novices

2016-01-08 Thread Gerald Wiltse
Ok, you guys got it :)

Gerald R. Wiltse
jerrywil...@gmail.com
248-893-9110 (c)
888-248-7095 (p)
888-272-6046 (f)

On Fri, Jan 8, 2016 at 1:45 PM, Jochen Theodorou <blackd...@gmx.org> wrote:

> I confirm what Pascal said.$
> I give you my perspective on SO:
> I do try to answer as many question over at SO as possible... of the few
> Tim does leave me ;) But recently I had not so much time and the wrong
> setup to do these things, so I was not very active there... and even then
> it is easy to oversee an question at SO for me.
>
> bye blackdrag
>
>
> Am 08.01.2016 um 16:37 schrieb Pascal Schumacher:
>
>> Hi Jerry,
>>
>> I think it is perfectly fine to send novice questions to the mailing
>> list. There were a lot of these on the old user list at codehaus.
>>
>> Cheers,
>> Pascal
>>
>> Am 8. Januar 2016 16:02:58 MEZ, schrieb Gerald Wiltse
>> <jerrywil...@gmail.com>:
>>
>> I don't feel right posting novice level questions to the user group
>> because it seems it should be more for language-level discussion.
>>
>> At the same time, I'm stuck when I don't get any responses to
>> Groovy-related questions on StackOverflow:
>>
>>
>> http://stackoverflow.com/questions/34574498/groovy-log-to-file-log-annotation
>>
>> Is there any novice level Groovy-Specific forum, IRC Room, or
>> otherwise, where such questions would be appropriate?
>>
>> It's also hard because so many solutions on the internet are for
>> Grails or Gradle, and as a novice who does not use those, I'm just
>> not sure how many of those things translate to my use cases.
>>
>> Also, FYI, Thanks to everyone who does post answers to questions on
>> Stackoverflow/exchange/etc (special mention to Tim Yates, who's
>> posts are always amazing).
>>
>> Regards,
>> Jerry
>>
>> Gerald R. Wiltse
>> jerrywil...@gmail.com <mailto:jerrywil...@gmail.com>
>>
>>


Re: Exciting Use Case for Groovy - Log Analytics

2015-12-30 Thread Gerald Wiltse
Thanks for your response, it's great to have interest!

Indeed the goal is not to create a Groovy-based log analytic tool/platform
and release it as a contender to anything.  I do not see the future there,
as the market is saturated with really good solutions (as you point out).

The question we're really touching on here is:  "How many Groovy developers
would actually do more with logs within their existing Groovy projects if a
new log/data stream library for Groovy was released (besides me). I guess
that's a key question, and one I would love to hear feedback on.  Does it
rate high enough on anybody's chart for attention? I don't know.

Obviously we would, but that's because of a very niche combination of
factors for us. We were 90% there with Logicmonitor + Groovy for
monitoring.  With the need to just add good (but not amazing) log analysis
and alerting, it makes perfect sense.  Still, even in our best case
scenario, we would have to turn to other data analytics platforms for
anything beyond the "IT Operations" type log work we're intending to do.

Having said that (and after reading a lot about building DSL's with
groovy), I believe there's a good argument for the existence of a Groovy
library that provides a bunch of new power and sugar for working with log
files, and querying streams of data.  Although it's pure speculation, I
would even dare to say that a lot of people would make heavy use of such a
library.  What I'm not sure about, is whether there's a good enough
argument for anyone to spend the time to build such a thing. That seems
like a hard argument to make for anything these days with everyone buried
under backlogs.

Regards,
Jerry


Gerald R. Wiltse
jerrywil...@gmail.com
248-893-9110 (c)
888-248-7095 (p)
888-272-6046 (f)

On Wed, Dec 30, 2015 at 8:56 PM, Aristedes Maniatis <a...@ish.com.au> wrote:

> On 31/12/2015 8:46am, Gerald Wiltse wrote:
> > We are going to use Groovy for more-than-trivial log-parsing and
> analytics.  The groovy language native functionality seems fairly-well
> suited for this, but probably far from purpose-built Query Languages.
>
> I'm interested in the work you are doing here, but how will your solution
> differ from the elasticsearch + logstash + kibana system which already
> might do a lot of what you are wanting? Don't get me wrong, I'd love to see
> a groovy log parser over the jruby implementation of logstash, but what is
> the value-add in the project you are contemplating compared to what is
> already available?
>
> Happy new year!
> Ari
>
>
> --
> -->
> Aristedes Maniatis
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>


Re: Question about GroovyClassLoader, Imoprt, and ContentAssist

2015-12-30 Thread Gerald Wiltse
Thanks for your help Jochen.  I wanted to close the loop on this thread and
state that the problem was that they were not in the correct location
according to the package structure. I also had other problems resulting in
my symptoms, but I got them cleared up.

Gerald R. Wiltse
jerrywil...@gmail.com
248-893-9110 (c)
888-248-7095 (p)
888-272-6046 (f)

On Sat, Dec 19, 2015 at 3:49 AM, Jochen Theodorou <blackd...@gmx.org> wrote:

> On 18.12.2015 20:12, Gerald Wiltse wrote:
> [...]
>
>> Problem, This appears to be possible using GroovyClassLoader() (and
>> several people have posted how-tos). However, the problem I have that
>> nobody else seems to reference is that this strategy means that content
>> assist will never be able to identify your classes and methods, and your
>> code will be full of underlines, and receive no error checking. (eclipse
>> and otherwise i would think).
>>
>
> if the scripts are available to the IDE and in the right position (eclipse
> needs them to be in the right folders according to the package structure),
> then it should work
>
> [...]
>
>> As I was building my project, I was creating the scripts and the classes
>> in the package just like normal a program. When I add my import
>> statements for my custom classes, Eclipse recognizes everything and
>> content assist is happy. However, despite content assist being
>> satisfied, it hits a snag when I try to execute a script because eclipse
>> returns: unable to resolve class (presumably because it's still only a
>> groovy file, and not compiled to a class file).
>>
>
> if eclipse tries to execute the class directly, then it won't work, yes.
> You can use GroovyMain#main and the script as first argument for this
> though... I did that all the time. The JVM needs some kind of starter for
> the groovy scripts, since it does not understand groovy sciprts. If that is
> GroovyMain, or something you wrote, which uses GroovyClassLoader does not
> really matter. Eclipse does imho a compilation and then uses the class to
> run the program. The setup with GroovyMain is something I always do
> manually.
>
> So, I looked around and it looks like I have to comment out the import
>> statement, and then use groovyclassloader to parse the groovy file
>> instead. However, this has the negative side effect of breaking content
>> assist.
>>
>
> well, it is a bit unclear to me how you actually start the program now.
>
> Question: Are my conclusions above all basically correct?
>>
>> Suggestion: Is there any known way to have content-assist work
>> along-side with GroovyClassLoader? Maybe some way to tell it to ignore
>> failed imports or something?
>>
>
> failed imports cannot be ignored, no. But I think it is really more a
> problem of your setup. Maybe you should describe the following things:
> (1) how exactly do you start the groovy program?
> (2) what is your file structure?
>
> After that we can maybe help.
>
> bye Jochen
>
>


Question about GroovyClassLoader, Imoprt, and ContentAssist

2015-12-18 Thread Gerald Wiltse
This is my first post to the list. If it's inappropriate for questions like
this, please let me know.

Goal: I want to define groovy classes in .groovy files as part of a
package, but without ever needing to compile them. Then, I want to define
groovy scripts in the same package, import the class definitions from the
nearby .groovy files, and execute the script... all without compilation (of
the other groovy files with classes).

Problem, This appears to be possible using GroovyClassLoader() (and several
people have posted how-tos). However, the problem I have that nobody else
seems to reference is that this strategy means that content assist will
never be able to identify your classes and methods, and your code will be
full of underlines, and receive no error checking. (eclipse and otherwise i
would think).

You might say "Thats just a side effect of using such a dynamic feature,
how would eclipse be able to know?", but consider the following:

As I was building my project, I was creating the scripts and the classes in
the package just like normal a program. When I add my import statements for
my custom classes, Eclipse recognizes everything and content assist is
happy. However, despite content assist being satisfied, it hits a snag when
I try to execute a script because eclipse returns: unable to resolve class
(presumably because it's still only a groovy file, and not compiled to a
class file).

So, I looked around and it looks like I have to comment out the import
statement, and then use groovyclassloader to parse the groovy file instead.
However, this has the negative side effect of breaking content assist.

Question: Are my conclusions above all basically correct?

Suggestion: Is there any known way to have content-assist work along-side
with GroovyClassLoader? Maybe some way to tell it to ignore failed imports
or something?


Gerald R. Wiltse
jerrywil...@gmail.com
248-893-9110 (c)
888-248-7095 (p)
888-272-6046 (f)