Chariot Training Classes

Training Courses

I run Chariot's training and mentoring services. We provide training in AngularJS, HTML5, Spring, Hibernate, Maven, Scala, and more.

Chariot Education Services


Chariot Emerging Tech

Learn about upcoming technologies and trends from my colleagues at Chariot Solutions.


Chariot Conferences


Entries in grails (17)


Flying Koalas, Culture Breaks, and 10 Minute Features!

Day #2 of the Groovy/Grails Experience 2008 included some rather in-depth sessions. My only regret is in not dividing and conquering the sessions with another person.

First, I attended the Racing with Rhinos talk, which was a good introduction to using Groovy within Spring, as well as using Grails to serve RESTful web services. The speaker, John Carnell, uses Groovy where he can in his financial institution, and the samples were very thorough.

Next, Jason Rudolph hit us hard and fast with the Going Further With Grails talk. A very thorough "next steps" lecture, he covered how to work with Groovy Server Pages, introduced us to the acegi security plugin, showed us templates, email, and a lot more. A great speaker, he was entertaining but kept the talk technical at the same time--a tough balancing act.

Grame Rocher gave a talk in the afternoon on GORM that included a great overview of static mappings, which can modify the Hibernate defaults for column and table names, datatypes, versioning, etc. He talked about query techniques, including the dynamic finder methods where you can issue statements like this:

def list =
("NorthEast", "Checking")

or, with criteria, this:

Date now = new Date()
def list = Account.withCriteria {
between("createDate", now - 30, now )
eq("category", "Checking")

I'm not doing the talk justice, but I can tell you that I'm not even scratching the surface of those features. Of course, like everything else, you should truly know your domain (and database design) if you are going to call methods like that. In the end, GORM is simply generating SQL queries.

Flying Koalas

But the funniest part of the evening was Glen Smith's talk. He's Austrailian, and gave a talk called "The Whole 9 Yards: Things You Can Do in 10 Minutes" which was basically a set of recipes for quick projects in Groovy and Grails. His talk was not only very informative, but hysterical, as he brought six little Koala bears in, and tossed them to people who asked him questions. He also took a "Culture Exchange" break, talking about Kangaroos and how they are not nice, cuddly little creatures.

Along the way we learned how to create graphs with JFreeChart and Google Charts, generate PDF files, using EHCache for storing things beyond Hibernate data (pre-rendered graphic thumbnails, for example), generating and consuming RSS feeds, using Textile markup language for a simple blogging engine, and some Scriptaculous javascript effects. (I'm missing a few).

So far, the message I got from the the conference is that there is a ground swell of community support for Groovy and Grails. The event was well attended, if very ambitious. We started this morning at 9 AM, and stopped close to 10 PM. That's with only a few breaks for lunch, dinner, and stretching.

More about the third day tomorrow. On deck: a series called "Refactorium" where Jason Rudolph takes us through the Grails source code and attempts to make us all Grails open source contributors...


Greetings from the Groovy/Grails Experience

I'm sitting here in my hotel room thinking about just how far we have come in terms of productivity as developers over the last decade. In 1998, I was working on a very new Java platform, doing command-line work and primitive (if any) web servlets. It took forever and a day to write those applications, and since Java was so new, nobody knew how to tune them.

Spin forward 10 years, and here we are, experiencing the dawning of the dynamic language era. Most programming languages are statically typed, meaning that variables and methods must obey strict data type conventions. Also, traditional language semantics are locked down, so that if you don't like how a given language or framework functions, you have to figure out an elaborate set of workarounds to correct it.

Developers are becoming aware of dynamic languages like Ruby and its' web framework, Rails. They are investigating domain specific languages as well. These languages create a syntax to allow business and development teams to work closely together and express what they want to do in the form of almost english syntax.

Trouble in Paradise...

But the number of languages available to programmers is mind-numbing. We can't use Java, that's behind us. How about Ruby? JPython? JavaScript? ActionScript? Scala? Haskell? Obviously I'm just listing names here, but you get the picture. Although each language has its' strengths and uses, there happen to be a dizzying array of them to choose from.

Ok, let's stick with Java. If we do, we now have another set of choices to make:

  • What web application server do I run? Apache Tomcat? JBoss? Jetty? Weblogic?

  • What web framework do I configure? Struts? Stripes? Spring MVC? Wicket? Seam? JSF? Ed's bag o' webware?

  • Ok, what component framework? EJB and JEE? Spring? Pico or Nano Containers?

  • Hmm... I need a relational database mapping tool. Do I use Hibernate, or jump right to JPA? What if I dislike configuring mappings with annotations? What about Toplink, Kodo, and other tools?

  • Finally, let's put together a build process that pulls all of these open source frameworks together. Give me a few weeks to figure that one out!

Whew, I'm exhausted just thinking about it.

What if there was a better way?

What if you could keep those Java developers working in a language that was familar to them? With the same runtime. With a rich set of additional, dynamic and robust features that, once mastered, make that language much more powerful? What if we could harness tools like Hibernate and Spring without creating complex configuration files? What if we wanted to use an already popular charting library, or integration framework? What if we could just be productive and agile but not throw away all of the good tools and libraries we've put to use over the years?

Groovy is just such a language. It supports dynamic language semantics, including the ability to modify a class to weave in a definition:

// Use Expando Metaclass to
// add a method dynamically
String.metaClass.getLength = {
-> delegate.size()

// now, use this method
// in any String
print "Hello there".length
> 11

Didn't you just hate the fact that Java didn't have a getLength method on java.lang.String? That two-line setup fixed it. But I digress...

Groovy lets you get rid of getters and setters, constructors, equals and hashcode methods. Any variables you define are automatically given dynamically created setters and getters, when called from within Java. Oh, did I mention you can call Java from Groovy, and Groovy from Java? In fact, renaming a class as a .groovy file, and removing all of the constructors, getters and setters can actually increase your code coverage!

This means that Groovy allows you to become ultra-productive, but from within a language and runtime you've already worked with for years.

Grails -- A rapid application development platform with tools you know...

Remember that list of things to consider in building a Java web application framework? Well, Grails is a Groovy and Java-based application delivery platform that makes some choices up front based on industry adopted tools. When you create a grails app (I will pause while you jump ship and google "creating a grails application") you are generating an application that is based on some strongly adopted building blocks:

  • The Java language and runtime, 1.4 and above

  • The Spring Framework (including IoC and WebFlow)

  • Hibernate 3 (the GORM framework executes Hibernate behind the scenes)

  • Sitemesh templates

  • Quartz job scheduling

  • Ant (there is a really great DSL for Ant called Gant)

  • And much more...

Grails supports scaffolding (the ability to dynamically generate the web site views while focusing on getting the database mapping elements called Domain Objects right). Grails also supports easy unit testing with a GroovyTestCase class. The Groovy Server Pages are easy to pick up, and a tag library build process is as easy as grails create-tag-library and editing your tag in the resultant file.

In my next post, we'll talk more about Grails, and discuss the G2One Groovy Grails show itself. I'll provide some links to tutorials and samples, and discuss some specific news coming out of the conference itself.

Page 1 ... 1 2 3 4