Posts Tagged ‘Groovy’
SpringOne 2GX 2009 Day One
Day One Recap:
Attended a nice reception with beer and wine provided by the event sponsors. There were some nice cheeses and fruits and a whole mess of SpringSource employees wearing their yellow SpringSource shirts (I would like one). I got a great event t-shirt, an event binder and a USB drive with all the presentation material.
The venue, The Roosevelt Hotel New Orleans, LA is incredible. SpringSource/NFJS did a great job on getting an incredible hotel for the event.
Dinner was great. Salad, pasta, Cajun shrimp and jambalaya with a red velvet cupcake for dessert.
During the keynote, speaker Rod Johnson discussed where Spring has been and where Spring is headed. He stressed SpringSource’s goals of developer oriented simplicity and the support of the community. Rod then gave the floor to Spring project leads (Jeremey Grelle, Mark Fisher, Graeme Rocher and Jon Travis?) to demo Flex, Spring BlazeDS and Spring Integration, Grails with Spring Tools Suite and Spring Insight. Spring Insight looks incredible!
Java on Google App Engine
Google App Engine’s support of Java was a long awaited, highly demanded feature of the service back when I first started messing around with original, Python version a little over a year ago. The excitement that App Engine brought to developers was echoed by the overwhelming request for Java support. Over the past 10 days I have created a few sample applications locally to give it a test. I went the App Engine Eclipse plugin route to get things started. It is a really nice plugin that delivers what you would expect from Google. Once installed, you can create a project and have it running in under a minute.
Once I got familiar with what I was working with, I decided to turn this sample application into a simple Spring Web Flow 2 demo. That is where development stopped. Unfortunately, there are a lot of JVM features/classes that are not accessible on App Engine that Web Flow 2 (and 3rd party libraries) needs for binding and flow execution support. Nothing against Google or SpringSource, I just did not get what I wanted.
Fortunately, I created a new sample app that is based on Groovy’s Groovlet technology and things were moving forward again. Just configure the GroovyServlet in your web.xml file and away you go. My next experiment will be to work with Grails on App Engine via the Grails App Engine plugin.
Overall, App Engine is great. It is really easy to use and the application dashboard features are amazing. Access to application and admin log files in a nice HTML based presentation. Quota detail that explains bandwidth, CPU and datastore utilization along with access to different versions of your application. You can even grant access to other developers for collaboration efforts. All features you normally do not get from your company’s “Enterprise” admin group.
On a side note, Vladimir Vivien and I will be discussing Google App Engine at the Tampa JUG on August 25th, 2009.
Groovy Prime Numbers
The other day I wanted to prove the power of Groovy to a few more core Java developers. I sat down and played with a little script that I think proves the power, or ease of use, of Groovy while having fun with number theory. My goal was to have a Collection that contains Prime Numbers calculated from a given range of numbers x to y, or in Groovy syntax x..y. I am taking a few things for granted with this script. For example, I know that 2 is the lowest Prime Number (it helps simplify the algorithm) and that 1 is not a Prime Number. So here’s the script:
def t = 1..100
def v = []
t.each { n ->
(2..n).each { d ->
if(n % d == 0 && n != d)
v.add(n)
}
}
println t - v - 1
We have our range of numbers t and we are capturing the non-Prime numbers and adding them to our Collection v. The final line of the script is doing a lot of groovy work for us that would take a few more lines of code with plain Java syntax. What is it doing for us? It is taking our range of numbers t and subtracting (removing) our non-Prime numbers collected in v. This line is also removing the number 1 because we know that 1 is not a Prime Number. Finally, it is printing the result like so:
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Very cool stuff. Now, I know that many of us are rarely building a Collection of Prime Numbers and I know this script does not do things in a timely manner with a range like 1..10000 (it took a couple of minutes), but I am sure this feature of Collections in Groovy can be utilized in many ways in my development.
Spring’s Dynamic Language Support Presentation
On March 31st, 2009 I discussed Spring’s dynamic language support with a focus on Groovy and JRuby at the Tampa JUG. There were quite a few people in attendance who were interested in leveraging the power and simplicity of Spring and Groovy. The presentation material can be found here and the demo Web application can be found here. Thanks to all who attended, the Tampa JUG’s sponsors GCA and Hudson and Vladimir Vivien.