Friday, October 19, 2012

SpringOne 2GX - Conference Summary

Here is a high level summary of the key themes and take-aways that I got from the SpringOne 2GX 2012 conference.

First of all, the name of the conference can be parsed as follows:
  • SpringOne is analogous to JavaOne (but the focus is on the Spring framework instead of the entire Java ecosystem)
  • 2G = Groovy & Grails
  • X = other stuff in the Groovy/Grails ecosystem (Gradle, Geb, GORM, etc.)
This was a big conference. I don't have an exact head count but I'd say that there were over 500 people there. The conference was divided into two separate parts (Spring and Groovy/Grails); the sessions were even held on different floors of the hotel. I only went to the Groovy/Grails sessions.

The final session that I attended, Grails and the World of Tomorrow by Peter Ledbrook, provided a good summary of the major trends in web system architecture these days:
  • moving applications to "the cloud" for horizontal scalabiltiy, efficient resource utilization, and reducing IT infrastructure costs
  • moving page processing off of the server and into the browser using one (or more) of the many javascript frameworks that are becoming available. One example of this is the "single page" web app.
  • use of NoSQL data stores (redis, mongoDB, cassandra, Neo4j, etc.) to allow applications to scale better horizontally
  • social integration (Facebook, twitter, Linked-In, Google+, etc.)

Groovy take-aways

I learned a few new and interesting things about Groovy at this conference.

I knew that Groovy 2.x supported static type checking and compilation but I thought that using it meant having to use Java 1.7. Groovy 2.x can use Java 1.5, 1.6, or 1.7. I am now much more eager to start using Groovy 2.

I learned more about closures in groovy. I had assumed that they were essentially the same as closures/lambda-expressions in other languages. Groovy, being object oriented, represents closures as a class with some properties that I wasn't aware of. Every closure has (potentially) three properties: delegate, this, and owner. These affect how free variables in the closure are resolved.

I learned a bit about metaprogramming in groovy too, including how to write modules that can add methods to ordinary existing java classes at run time.


Gradle looks very promising as a new general purpose build framework (not just for java and groovy). I want to take some of our Imake rules and create gradle plugins for them.

Geb functional testing framework

I went to a session on geb and learned a lot about what is going on with it. Here is an architecture diagram for geb from that presentation:

The Selenium project has migrated to the Google-supported and soon to be W3C standard WebDriver mechanism for controlling different web browsers via their native interfaces.
The target release date for Geb 1.0 is Q1 2013. I'm putting together a presentation on web functional testing using Geb so I won't go on about it here.


I went to a few sessions on Grails. The Grails 2 Update session gave an overview of things that have changed between Grails 1.x and 2.x but I knew most of this because Grails 2 has been out for almost a year. Burt Beckwith's session on Spring Security in Grails was interesting. My take-away was to not try to implement this stuff yourself; use the things that folks like Burt provide.

Thursday, October 18, 2012

SpringOne 2GX - Grails and the World of Tomorrow

Presenter: Peter Ledbrook
12:45pm 10/18/2012

Grails has Cache plugin to address general caching.
For HTTP sessions, Database Session plugin (MongoDB or Cookie)

CQRS - Command Query Responsibility Segregation

Separate databases for updates and queries. Updates are saved as deltas which are communicated to the query database as events. Access to objects requires that the object be reconstructed (re-hydrated) based on the deltas.

SpringOne 2GX - Grails Clustering with Terracotta

Presenter: Ryan Vanderwerf
10:15am 10/18/2012

Terracotta is free for many usages. Full-fledged commercial use is licensed for $$.

There are different reasons for using clustering:
  • improving performance (not necessarily capacity)
  • scalability
  • high-availability
Terracotta is the company that created Quartz and Ehcache

Primary use cases for Terracotta

  • distributed HTTP sessions
  • Ehcache
  • Quartz scheduling

Configuring Terracotta

Just need to create a configuration file and reference it from each web app and terracota server (web.xml).

SpringOne 2GX - Groovy Modules

Presenter: Paul King
8:30am 10/18/2012

As part of the Groovy 2 release, groovy-all-x.y.z.jar was modularized (decomposed into multiple jars). This is somewhat more complicated than it sounds. The GDK includes extensions to Java classes.

It is possible to create a groovy extension module from an existing Java class library by simply creating a nearly empty .jar file that just contains some metadata. Methods must be written in a certain form to do this (e.g., commons lang).

Wednesday, October 17, 2012

SpringOne 2GX - Advanced Metaprogramming With Groovy

Presenter: Jeff Brown
4:30pm 10/17/2012

What is Metaprogramming?

In this context we mean the ability to change the behavior of a program at runtime.

Dynamic Dispatch

Ability to intercept and modify method/property access at runtime.
MOP = Meta Object Protocol

Metaprogramming Hooks

  • void setProperty(String name, value) { } - called whenever a property is set
  • def getProperty(String name) { } - called whenever a property is retrieved
  • def methodMissing(String methodName, args) { } - called when a method that does not exist is invoked
  • def propertyMissing(String name, value) { }
  • def propertyMissing(String name) { }

Closures and Delegates

Every closure has delegate, owner and resolveStrategy properties.
Every class has a meta Class: className.metaClass to which you can assign properties/methods.



SpringOne 2GX - Grails & Async

Presenter: Colin Harrington
2:45pm 10/17/2012

I'm afraid that much of this was above my head. Suffice it to say that if you have long-running tasks in your Grails web application, you can execute them in threads other than the request thread.

SpringOne 2GX - Hacking the Grails Spring Security Plugins

Presenter: Burt Beckwith
12:45pm 10/17/2012

The Spring Security grails plugins allow you to make use of any of a number of "pre-baked" security schemes in a grails app.

Security is complicated. You should use things like this instead of trying to roll your own.

SpringOne 2GX - Standardizing Enterprise Build Systems

Presenter: Luke Daley
10:30am 10/17/2012

Possible to implement rules, such as:
  • no project can depend on Hibernate
  • all projects must include a test task 
  • use JUnit 4.10 for tests
  • integration tests will be their own source set and task
  • dependencies always come from ur corporate repository
  • source code must be Java 1.5 compatible
You can use init scripts to apply global conventions to all builds (company wide, project wide, user wide).

SpringOne 2GX - Grails 2 Update

Presenter: Jeff Brown
8:30am 10/17/2012

Grails shell

The grails shell is the new preferred way to use grails (overcomes JVM startup time).

Better Unit Test results HTML output.

Documentation engine that is bundled with Grails is available to grails apps (and externally). "grails doc" to generate documentation.

Default database now H2

Grails also now includes a database console app (http://localhost:8080/app/dbconsole) (available in development only!). The console app works for other relational databases too.

Upgrades to underlying software

As part of Grails 2 underlying software (tomcat, Spring, groovy, etc.) were upgraded.

New automatic reloading is much better than in Grails 1.x

Controller actions are now declared as public methods:
// some controller ...
def save(String name, int age) {
form parameters are automatically bound to method arguments. (e.g., .../foo/save?name=Dan&age=10)
To convert a parameter to a date use:
def myDate ='myDate', 'dd-MM-yyyy')

HTML5 scaffolding

Scaffolding updated to use HTML5. grails install-templates will make the templates available to be viewed/modified.

New Page Rendering API available.

 One application of this would be to create an email body using a gsp template

New Link Generator API available.

"grails install-plugin foo" is deprecated. Should modify BuildConfig.groovy to explicitly list the dependency on the plugin.

jQuery is the default javascript framework in Grails 2.

GORM can now use other underlying persistence mechanisms

Grails Object-Relational Mapping (GORM) now does not have to use Hibernate as the underlying mechanism (other mechanisms include: mongoDB, Cassandra, redis, riak, neo4j)

Where queries

def query = Person.where { age < 20 }
def people = query.list(params)
def cnt = query.count()
The where method accepts a closure that defines the "where" clause in ordinary groovy syntax (not SQL...). The closure is translated into SQL behind the scenes (using an AST transformation).

Improved database migration

New database migration plugin facilitates updating schemas once application is in production.

Tuesday, October 16, 2012

SpringOne 2GX - Grooovy Domain-Specific Languages

Presenters: Andrew Eisenberg, Paul King, and Guillaume Laforge
4:30pm 10/16/2012

Guillaume's blog:

DSLs can be used in a wide range of applications from science to the insurance industry. Allow domain experts to express business rules without having to understand a general purpose computer language. They avoid cluttering business logic with boilerplate technical code.

Mars Rover DSL

See the presentation here:

SpringOne 2GX - Design Patterns in Groovy

Presenter: Venkat Subramaniam
2:45pm 10/16/2012

This was an informative and entertaining presentation about how design patterns can be implemented in groovy. The bottom line is that most design patterns are much easier to implement in groovy because of its dynamic language capabilities.

code samples at

SpringOne 2GX - Geb, Very Groovy Browser Automation

Presenter: Luke Daley (Geb project creator)
12:45pm 10/16/2012

Some Uses for Geb
  • web application functionality/acceptance tessting
  • automating web web sites (e.g., data entry)
  • screen scraping
Geb is not itself a testing framework but integrates with the major ones (spock, junit, testng, etc.)

Uses Selenium WebDriver (successor to Selenium sponsored by Google). Becoming a W3C standard (

Provides cross-browser support (firefox, chrome, htmlunit, ie, ...)

Supports Remote Browsers (e.g., driving an IE browser on some other host). SauceLabs offers remote web browsers that Geb can use (this costs $$).

selenium-server-standalone-2.25.0.jar (to drive a browser remotely).

I'm sorry for not writing more about this session but I was listening too intently to take detailed notes. This was a good session.

SpringOne 2GX - Modern Application Architectures with Grails and Spring

Presenter: Brian Jimerson - Avantia
10:15am 10/16/2012

Modern Design Patterns

  • idemponent services
    • services are safe to be invoked multiple times from different instances/locations  (e.g., credit card processing shouldn't cause multiple charges to be applied)
    • services are not stateful
  • scalability
    • horizontally (new instances)
    • vertically (partitioning)
    • application zones provide isolation (not sure what this means :-)
  • graceful degradation
    • unavailability of one service shouldn't cause total failure of application
  • asynchronous messsaging
    • promotes loose coupling
    • very important in logically/geographically distributed systems

Grails/Spring vs. J2EE Containers

Grails/Spring applications are lighter-weight than corresponding J2EE apps because they don't depend on a heavy J2EE container to provide services.

Presenter's company uses the OpenUP development process ( This looks interesting.

Separation of Concerns

Grails is a web framework
  • best suited for web, mobile and REST API interfaces
  • data driven
  • best suited for enterprise integration, batch and custom functionality

SpringOne 2GX - What's New in Groovy 2.0

Presenter: Guillaume Laforge
8:30am 10/16

Groovy 1.8 stuff:

Now bundle the GPars library in the groovy distribution. This library is for implementing various kinds of parallel processing. You can use GPars from pure Java, as well.

Enhancements to syntax for method chanining (less dots and parentheses).

Can use closures in @annotations

Memoization of closures

Built-in JSON support

def payload = new URL("http://github.../json/commits/...").text
def slurper = new JsonSlurper()
def doc = slurper.parseText(payload)
doc.commits.message.each { println it}
or to create JSON:
import groovy.json.*

def json = new JsonBuilder()
json.person {
  name "Guillaume"
  age 35
  pets "Isabella", "Sage", "Tigger"

Lots of new annotations

@Log, @Log4j, @Commons, @Slf4j - logging injection
@ThreadInterrupt import goovy.transform.ThreadInterrupt - annotation can be added at the beginning of any block or closure
@InheritConstructors - annotation added to derived class that causes all of its parent's constructors to be inherited (useful for exception classes)

Groovy 2.0

Groovy 2.0.0 released in June. Currently at 2.0.5.
Three main themes: modularity, Java 7 alignment, static type checking and compilation (big!)


groovy-all.jar has been decomposed into smaller modules (although groovy-all.jar is still available)

Add ability for user to define extension methods (methods available to ordinary Java classes).

package foo
class StringExtension {
  static introduces(String self, String name) {
    "Hi ${name}, I'm ${self}"


[Need to add descriptor to META-INF/services/org.codehaus.groovy.runtime.ExtensionModule]

Java 7 alignment

  • binary literals (0b010101)
  •  can use _ in numeric literals (1_000_000, 999_99_9999, 9999_9999_9999_9999)
  • multicatch try { ... } catch ( Exception1 | Exception2 e ) { }
  • InvokeDynamic - better runtime performance (requires compiler flag to enable compiling against JDK 7)
  • works with java 1.5, 1.6, 1.7 

Static Type Checking

Goal: make the Groovy compiler "grumpy":
  • complain about method/variable name typos
  • complain about assignments of incorrect types
  • infer types of variables
  • GDK methods are type-checked by default
Don't always need dynamic features (e.g., dynamic methods)

import groovy.transform.TypeChecked
@TypeChecked (annotation can be made on class or method)

Static Compilation

Use @CompileStatic annotation on class to request.

  • can generate same byte code as javac (big performance gain!)
  • lose dynamic language features (e.g., builders, metaclass changes, categories)

Monday, October 15, 2012

SpringOne2GX - e^pi*i - Monday Evening Keynote

The keynote was by hosted by Adrian Colyer, CTO of SpringSource and presented by Juergen Hoeller, Graeme Rocher, and 

Mark Pollack - Spring Data
 Interesting take on changing paradigms for storing/accessing huge datasets.

Neo4j - graph database.

 O'Reilly Book on Spring Data (free w/ conference)

 Graeme Rocher (Grails creator) - new Grails 2.1 grails web site.
platform-core plugin includes an eventing model

Graeme showed a demo app that used the event push capability to dynamically update a single-page webapp. 

Thursday, February 03, 2011

Testing ScribeFire

I'm checking out a new Firefox plugin that I just installed called ScribeFire.

Here is an image:

Monday, June 28, 2010

Okinawa trip - June/July 2010

I'm headed to Okinawa Japan for karate training tomorrow. I'm going with Donna Wieting (from my dojo in Washington) and Frank Gorman (my teacher Bob Kaiser's teacher, from Florida) and seven other people I haven't met yet. I'm hoping to update this blog daily while I'm in Okinawa but I'm not sure if our hotel/motel has wireless internet.