about this book

Griffon in Action is a comprehensive introduction to the Griffon framework that covers the basic building blocks such as MVC groups, binding, threading, services, plugins, and addons. But don’t let this quick summary fool you into thinking the topics are covered lightly. The book provides deep dives into the topics at hand, following a practical approach to get you started as quickly as possible.

Who should read this book

This book is for anyone interested in writing desktop applications for the Java virtual machine (JVM). Whether you’re a seasoned Java developer or just starting on your way, Griffon in Action will give you the knowledge to get started writing desktop applications in a productive manner and—why not?—have some fun while you’re at it.

Some experience with Java Swing is assumed. Previous experience with Grails is an advantage, but we take the time to explain the crucial concepts where we think a common base should be explicitly stated. If you’re coming from another language background (such as Ruby or Python), you should find that using the Groovy language comes naturally.


Griffon in Action gives a quick, accessible, no-fluff introduction to writing desktop applications in the Java universe.

The book is divided into four parts:

We cover what Griffon is in chapter 1: where did it come from, and why was such a development platform needed in the first place? This chapter presents theory along with a good deal of practical advice and code—we want you to get a quick start right off the bat.

In chapter 2, we explain the configuration options for an application both at compile time and runtime. The command-line tools are discussed extensively.

In part 2 of the book, we go deep into the Griffon’s lair and explore the MVC components found in every Griffon application. Our first stop is modeling data and establishing automatic updates via binding. We hope that by the end of chapter 3, you’ll agree that binding makes life much easier that manually wiring up triggers; and event listeners will be a task you cross off your list permanently.

Walking further into the den of the beast in chapter 4, we’ll discuss several techniques for building a UI. Declarative programming is certainly within your reach, and the fact that Griffon uses Groovy—a real programming language—makes things much sweeter. You’ll find that the relationships between the different components emerge naturally as you progress.

Closer to the nest, in chapter 5, are the components that form the logic of an application: controllers and services. They’re responsible for routing events and data, as well as responding to user events.

All the pieces will have fallen into place at this point, but you may have some unanswered questions regarding the relationships between components. Chapter 6 covers in great detail how the platform manages its components and the facilities it puts at your disposal to make the most out of them.

In part 3, we progress to more advanced topics. Building a responsive application can be a daunting task, but in chapter 7 we’ll show you a few options that will help you sort out multithreading obstacles with ease. Dealing with highly coupled components is equally intimidating; but, fortunately, Griffon lets you react to well-timed events depending on the application’s life cycle. You can even trigger your own events. And did we mention that the event system is also useful for the command line? Events are essential to building an application, and we’ll show you how to use them.

Chapter 8 offers complete coverage of notifications. Then, we’ll move to an often-neglected aspect of desktop applications: proper testing, involving the UI. Griffon simplifies that task as well, as we’ll explain in chapter 9.

Finally, we get into the subject of deployment in chapter 10. We cannot stress enough how important it is to package the application in a way that customers can start using it immediately. Griffon provides highly configurable options to gift-wrap that application, and you need only concern yourself with how you’ll ship it to your customers. The beast should be tamed by now and comfortably accepting your commands.

We’ll begin part 4 by flying the friendly skies of plugins and extensions. We’ll bank left to chart our way through chapter 11. Plugins, a key Griffon feature, let you as a developer customize further how applications are built and packaged, for example. In chapter 12, we’ll climb up to the highest clouds, close to the stars, where the imagination roams freely through the vast expanse of customized views.

Before we complete our journey and shoot for the stars, you’ll put all your newfound knowledge and training to the test in chapter 13. We’ll show you how to build a prototype application that spans both desktop and web spaces, thanks to friendly cooperation between Griffon and Grails.

You’ll want to keep your flying steed well nourished and in excellent condition. In chapter 14, we’ll look at the most common tools, such as editors and build tools, that you can use to maximize Griffon’s performance.

Code conventions

This book provides examples that demonstrate in a hands-on fashion how to use Griffon features. Source code in listings or in text appears in a fixed-width font like this to separate it from the ordinary text. In addition, class and method names, object properties, and other code-related terms and content in text are presented using the same fixed-width font.

Code and command-line input/output can be verbose. In some cases, the original source code (available online) has been reformatted; we’ve added line breaks and reworked indentation to accommodate the page space available in the book. In rare cases, when even this was not enough, line-continuation markers were added to show where longer lines had to be broken.

Code annotations accompany many of the listings, highlighting important concepts. In some cases, numbered cueballs link to additional explanations that follow the listing.

Source code downloads

You can access the source code for all examples in the book from the publisher’s website: www.manning.com/GriffoninAction. All source code for the book is hosted at GitHub (github.com), a commercial Git hosting firm. We’ll maintain the current URL via the publisher’s website, also mirrored at https://github.com/aalmiray/griffoninaction. To simplify finding your way, the source code is maintained by chapter.

Software requirements

All you need to get started is a working version of Oracle’s JDK6 (available from http://java.oracle.com) that matches your platform and operating system plus the latest stable Griffon release (from http://griffon.codehaus.org/download). Additional software may be required, such as plugins or tools; we’ll provide download instructions when applicable.

Staying up to date

We wrote the book as Griffon evolved, targeting 0.9.5 specifically, however subsequent Griffon versions may have been released by the time you read this. New Griffon versions bring new functionality, and although Griffon reached 1.0 status right about the time this book was finished, the Griffon team made sure to keep away from introducing breaking changes after 0.9.5 was released. This means all the knowledge you learn here is valid for future releases.

If portions of source code require modification for a future release, you’ll be able to find information on the Griffon in Action Author Online forum (www.manning.com/GriffoninAction).

You can also use the Author Online forum to make comments about the book, point out any errors that may have been missed, ask technical questions, and receive help from the authors and from other users.

About the authors

Andres Almiray is a Java/Groovy developer and Java Champion, with more than a decade of experience in software design and development. He has been involved in web and desktop application developments since the early days of Java. His current interests include Groovy and Swing. He is a true believer in open source and has participated in popular projects like Groovy, Grails, JMatter, and DbUnit, as well as starting his own projects. Andres is a founding member and current project lead of the Griffon framework. He blogs periodically at http://jroller.com/aalmiray and is a regular speaker at international conferences. You can find him on twitter as @aalmiray.

Danno Ferrin is a component lead engineer with experience in Java, Groovy, and Swing. He’s the cofounder of Griffon, an active committer to the Groovy language, and a former committer to both Tomcat and Ant.

James Shingler is the lead technical architect for Big Lots (a nationwide retailer base in Columbus, Ohio), a conference speaker, an open source advocate, and coauthor of Beginning Groovy and Grails (2008). The focus of his career has been using cutting-edge technology to develop IT solutions for the retail, insurance, financial services, and manufacturing industries. He has 14 years of large-scale Java experience and significant experience in distributed and relational technologies.