• Feeds

    Get updates delivered to your reader or your email in-box: Subscribe to RSS or .

  • About Me

    I am a Java, Groovy and Grails consultant and software architect. I have worked with Java for many years, but recently I have taken an interest in new languages for the Java Platform - such as Groovy!   read more

  • Find Me

Thoughts From the First Philly Groovy and Grails Meet-up

I can’t begin to thank Scott Davis and Venkat Subramaniam enough for giving us a great start to the Philadelphia Groovy and Grails meet-up. It was great to see two seasoned speakers “on stage” at once, but even better two good friends that made the evening both interactive and informative. It was simply awesome.

It was great to have an active crowd as well, and I hope that everyone that attended was able to take away something from the evening. Scott and Venkat started with an agenda for the evening, but we quickly pulled them off track and wandered. I’m working from memory, but we roughly covered the following:

  • Groovy is Java, except when it isn’t! Search for “Groovy the blue pill” or “Groovy the red pill” to see what that means.
  • We saw several perfectly valid Java classes become elegantly simple Groovy classes
  • Examples of Groovy metaprogramming and AST transformations (@Immutable, @Delegate and @Newify)
  • What tools and IDEs might be considered for Groovy and Grails programming
  • We learned that Venkat only uses a web browser that works with EMACS-like commands (it is Conkeror in case you are wondering)
  • We were reminded of the evil lurking in Java with precision issues in double and float, and how Groovy avoided this issue

There were many more little bits of information, but suffice to say we covered a lot of ground. Thanks again to Scott and Venkat, and thanks to all that attended our first meet-up.

Please watch the meet-up group site for more information about our next meet-up.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Philadelphia Groovy and Grails User Group Kickoff

On April 8, 2010 – just three short days from now – we will be kicking off the Philadelphia Groovy and Grails User Group (GGUG). This will be part of the evening events at the Philadelphia Emerging Technology conference. The conference is sold out, however a conference entrance pass is not required to attend the evening event. I’d love to see a packed room, so feel free to stop by and say hello.

I also want to be sure that everyone goes to the Philly GGUG official site at http://www.phillygroovy.org and join the email list so that you can be a part of our future events. I am hoping to have Philly GGUG meet-ups every two months, so look for another meet-up in June.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Grails Tip: Using failOnError When Saving Domain Instances

Calling the save method on a Grails domain class will return a null if there was an error in validation. This is handy when doing something like the following.

if( !book.save() ) {
   book.errors.each {
        println it
   }
}

In Grails 1.2 a feature was added to allow the option of forcing save to throw a grails.validation.ValidationException by using the failOnError argument.

try {
     book.save(failOnError:true)
} catch(ValidationException e) {
   // handle
}

If you prefer to make failing on validation errors the default, you can update Config.groovy in your Grails project to set the following property.

grails.gorm.failOnError=true

Thanks to Jeff Brown for reminding me of this when replying to a recent thread on the Grails user email list.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Grails Tip: Using Schema Export

Ever wonder what the DDL would look like that Grails generates to create or update your database? Well, no need to wonder any longer. Grails is packed full with little things to make your life simpler, and one that you may not have heard of yet is the Grails ’schema-export’ command line option. Under the covers this handy utility delegates to Hibernate’s SchemaExport. The output can either go to a file or to standard out.

Examples:

  • ‘grails schema-export’ : generates the DDL for the development environment into the default file ddl.sql
  • ‘grails prod schema-export’ : generates the DDL for the production environment to the default file ddl.sql
  • ‘grails schema-export export’ : generates the export DDL (drop then create)
  • ‘grails schema-export stdout’ : generates the DDL and sends it to starndard out
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Building Grails applications with PostgreSQL

I’ll be presenting a tutorial “Building Grails applications with PostgreSQL” along with my fellow Chariot Solutions colleague Ken Rimple at the PostgreSQL East 2010 conference in Philadelphia, PA. We are scheduled to present on March 25, 2010 at 11:00 AM.

This will be a 90 minute tutorial targeted at beginners of Grails. We plan to cover the following:

1. Overview of Grails

2. GORM

  • Properties and Validation
  • Associations and Composition

3. Configuring Grails with PostgreSQL

  • Environments: Dev, Test, and Production
  • Using DataSource.groovy

If you happen to be at the talk, be sure to introduce yourself and say hello!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Grails 1.2.1 is Released

Great news for all Grails developers, it appears that the core Grails team is still hard at work. Today it was announced that Grails 1.2.1 is ready. A quick look at the release notes and I see that there aren’t any major new features, but there are a lot of bug fixes. While this alone is encouraging, when I looked at the Grails Roadmap I see issues cued up for 1.2.2 and a release date of 1.3 is still listed as March 30. So far I’m liking the first quarter of 2010!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Defining and Testing Constraints on Grails Domain Classes

Defining constraints in Grails domain classes is achieved quite simply with a static property defined directly in the domain class. For example, I can define a User domain class and its constraints as follows:

class User {
  String login
  String password
  String email
  Integer age

  static constraints = {
    login(size:5..15, blank:false, unique:true)
    password(size:5..15, blank:false)
    email(email:true, blank:false)
    age(min:18, nullable:false)
  }
}

Constraints are syntactically formatted as method calls with the name of the method matching the name of the property the constraint is to be associated with. The method parameters are named parameters specifying the constraint. On User we have defined a constraint for each property. This was my decision to constrain each property, there is not a requirement to name a constraint for all properties in a domain class.

So far so good, but now I want to verify my constraints work the way I expect. The easiest way to test constraints is as part of a unit test. Grails provides mocking support in unit tests, so to setup a mock domain class for constraint testing I would create the following test class.

import grails.test.*

class UserTests extends GrailsUnitTestCase {

  protected void setUp() {
    super.setUp()
    mockForConstraintsTests(User)
  }

  protected void tearDown() {
    super.tearDown()
  }

  void testValidation() {
    def user = new User(login:'jdoe', password:'passw0rd',email:'jdoe@foo.com',age:32)
    assertTrue user.validate()
  }
}

That is it. One item of note, I recently found out that it is possible to pass a list of property names to the valdiate() method indicating that the validation should only be run on those properties. For example, if I only want to validate the login and password properties on an instance of User then I would do the following.

user.validate(['login','password'])

This trick, however, does not work in unit tests as it appears the validate method provided by the mock does not accept any parameters. Still, this will come in handy when I know that I don’t have a fully populated domain POGO, but want to validate what I have. Say, for example, in a UI wizard where each step sets a partial set of properties on the domain class.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

DevNews Podcast Episode #2

In case you are not already a follower of the Chariot TechCast, you may have missed the fact that TechCast host, Ken Rimple, and I posted the second edition of the new DevNews podcast. We plan for this to be a short, weekly podcast that covers some quick news items from the week. In DevNews episode #2 we cover:

  • Google news including GDrive and a primer on Google Go
  • Maven’s switch to Guice and a demo of Maven POM files in Groovy
  • Dependency injection annotations JSR-330 and JSR-299 released with JavaEE 6
  • Flex, OSGi, and Gremlin

If you have suggestions on topics we should cover in the future, you can tag related news items on Delicious with the tag devnewsideas and we will consider your story for the podcast.

While you are checking out the DevNews, be sure to catch podcasts with Venkat Subramaniam and Jeremy Grelle. Both of these guests will be speakers at the Emerging Technologies for the Enterprise Conference being held in Philadelphia on April 8-9, 2010. In the interest of full disclosure, this conference is hosted and presented by Chariot Solutions – my employer. This is the 5th year this conference will be presented, and it just keeps getting better. We have a great list of speakers and topics lined up, so check it out and be sure to register soon to get the early bird discount.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Spring, Groovy, and Grails Closing 2009 With a Bang

It appears that the folks at SpringSouce have been hard at work, and are giving Groovy and Grails folks a lot to look forward to in 2010. Let me give you a quick recap of the past week or so and just highlight some of the recent events.

It started last week with two Groovy related announcements. First, we were treated to Groovy 1.7 RC2 and found out that we have every reason to expect Groovy 1.7 GA before Christmas.

See: Groovy 1.7-RC-2 out there

Also, last week the Groovy-Eclipse team quietly released 2.0M2 of the Groovy Eclipse plug-in. They claim to have addressed over 100 issues, which includes a better inference engine, better refactoring support, task tag support, and content assist in GStrings. All in all, it looks like some nice improvements.

See: Groovy-Eclipse 2.0.0M2 New and Noteworthy

Then today there was an explosion of news all starting with the release of Spring Framework 3.0. There is a lot of good new stuff in there, and I’ll leave it to Juergen Hoeller to lay it all out for you.

See: Spring Framework 3.0 goes GA

This was followed very closely with the release of Grails 1.2 RC2 which includes the new Spring Framework 3.0 GA.

See: Grails 1.2-RC2 Release Notes

Finally, Guillaume Laforge posted an update on the modularity work that is being done as part of the Groovy 1.8 effort. This gist of this is to modularize Groovy into smaller pieces rather than having one, large groovy-all.jar distribution. Part of this effort will include replacing the current Ant based build with Gradle. This is a nice feather in the cap for Gradle.

See: Groovy 1.8 modularization

I am very excited to see what is to come in 2010 for the Groovy and Grails community. Judging by the activities of just the past month, there is a lot to be excited about for the year to come.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

LIVESTRONG Challenge Registration is Open

lsc_logo.gifToday, December 1, marks the opening for participants to register for the 2010 LIVESTRONG Challenge events. As a bonus, for one day the registration fee has been reduced to $35. You can register right now by going to the Team LIVESTRONG site. The dates and locations for the 2010 LIVESTRONG Challenge events are:

  • Seattle, WA: June 20, 2010
  • San Jose, CA: July 11, 2010
  • Philly, PA: August 21–22, 2010
  • Austin, TX: October 23–24, 2010

By the time you read this post, the promotion may very well be over. Even if you have missed the promotion, please consider registering right now to walk, run, or ride – and join the fight against cancer.

I will be riding again in 2010. This will be my 4th year in a row riding with Team Margaritaville or Bust (or TMOB for short), which is the official cycling team for the Salt Shaker Foundation. If you are in the greater Philly area and would like to join a team, please consider joining TMOB. We would love to have you ride, walk, or run with us!

This past year, cancer has continued to impact my extended family. My fight against cancer will continue as I ride, and wear a yellow wristband to remind myself every day to live strong. Cancer sucks – join the fight!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)