(Quick Reference)

1 Introduction - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

1 Introduction

Developing desktop/RIA applications on the JVM is a hard task. You have to make choices upfront during application design that might complicate the implementation, compromising the user experience; not to mention the amount of configuration needed.

RCP solutions like Eclipse RCP and NetBeans RCP are great for developing desktop applications, not so much for RIAs and applets. Griffon is a framework inspired by Grails, whose aim is to overcome the problems you may encounter while developing all these types of applications. It brings along popular concepts like

  • Convention over Configuration
  • Don't Repeat Yourself (DRY)
  • Pervasive MVC
  • Task automation
  • Testing supported "out of the box"

Griffon relies on the power of the Groovy language to glue all things together, though additional JVM languages can be used as well. The framework is quite extensible via plugins.

This documentation will take you through getting started with Griffon and building desktop/RIA applications with the Griffon framework.

Credits and Acknowledgements

This guide is heavily influenced by the Grails Guide. It simply would not have been possible without the great efforts made by: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown and their sponsor: SpringSource. The Griffon team would like to thank them all (and the Grails community too!) for making such a great framework and bringing the fun back to programming applications.

1.1 What's new in Griffon 1.2.0?

This section covers the new features that are present in 1.2.0 and is broken down into sections covering the build system and core APIs. Note there are many more small enhancements and improvements, these sections just cover some of the highlights.

1.1.1 Buildtime

New Commands

list-templates

This command lists all artifact templates available to the current project. Here's for example, the output generated by this command after an application has been created

--------------------------------------------------------------------------------
Location                 Name                          FileType
--------------------------------------------------------------------------------
application              <none>
-- Plugins ---------------------------------------------------------------------
swing-1.1.0              Controller                    groovy, java
                         DialogController              groovy, java
                         DialogModel                   groovy, java
                         DialogView                    groovy, java
                         Model                         groovy, java
                         View                          groovy, java
-- Archetypes ------------------------------------------------------------------
default                  GriffonAddon                  groovy, java
                         IntegrationTests              groovy, java
                         Model                         groovy, java
                         Script                        groovy
                         ScriptTests                   groovy
                         Service                       groovy, java
                         ShellCommand                  java
                         ShellHelp                     txt
                         Tests                         groovy, java

upload-release

Release packages may be downloaded from Remote Artifact Repositories, however there was no option for upload a release package to a particular repository until now. This command can upload a release package to any repository supported by the Griffon buildtime.

wrapper

This command generates or updates the files required by the Griffon wrapper in order to run. These files were previously created during the initialization of a project or an upgrade sequence.

Toolkit Aware Plugin Install

Griffon supports several UI toolkits for which many plugins may exist. Some of these plugins provide the same behavior but targeting a different UI toolkit, for example miglayout (swing) vs. miglayout-javafx (javafx). Now, every Griffon application has a default UI toolkit specified in its metadata; this fact makes it possible to simplify plugin installation by only specifying the common plugin name, that is, the following command

griffon install-plugin miglayout

will install miglayout-javafx if the application has javafx defined as its UI toolkit. On the other hand, it will install miglayout if the UI toolkit is swing.

Griffon Usage Tracking

An opt-in usage tracking system has been put into place in order to monitor the development of the Griffon community and help drive the roadmap for future features. All information is anonymized; usage tracking can be disabled/enabled at any time. Verifying the current status of usage tracking is done by invoking this command

griffon usage-stats

Enabling or disabling usage tracking is done with

griffon usage-stats --enabled=[true|false]

Usage tracking is turned off automatically if running in offline mode.

Intellij IDEA DSL Support

The Swing GDSL provided by the swing plugin has been updated to support named parameters for all nodes.

Eclipse STS DSLD Support

The Swing DSLD provided by the swing plugin has been upgraded and is now compatible with the latest definitions provided by STS.

Platform Specific Packaging

Until now, calling `griffon package` create platform specific packages depending on the currently running platform. Thus, if additional packages were needed developers had to run Griffon on different platforms. The `package` command accepts a new flag that defines the target platform to use. For example, packaging for Windows64 when running on OSX is done by invoking the following command

griffon package --platform=windows64

Be advised that previously built packages will be cleared when this command is issued. This is to assert no artifacts leak from previous builds.

Enhanced Plugin/Archetype info command

Both plugin-info and archetype-info will display full plugin/archetype description by default. You may specify a --skip-description flag if you do not want to see the artifact's description.

1.1.2 Runtime

Service LifeCycle

Services now have their own life-cycle methods, similarly to their MVC counterparts. See the section Service LifeCycle for more information.

Service Configuration DSL

Services properties may now be configured externally to the service class, using a simple DSL. Refer to the Service Configuration DSL section to learn more.

External Configuration

Applications now have the ability to specify alternate locations for configuration files and scripts. Simply configure griffon.config.locations in Config.groovy, for example

griffon.config.locations = [
    "classpath:${appName}-config.properties",
    "classpath:${appName}-config.groovy",
    "file:${userHome}/.griffon/${appName}-config.properties",
    "file:${userHome}/.griffon/${appName}-config.groovy"]

Section External Configuration Support covers this feature in more detail.

New Application Events

Instances managed by the application (such as MVC members) will now trigger a DestroyInstance event when the instance is no longer needed. This event is the counterpart of NewInstance.

EventRouter Factory

It's now possible to instantiate custom instances of EventRouter by defining a custom EventRouterFactory.

LogManager Factory

Developers now have the choice to plug in custom LogManager instances, by defining their own LogManagerFactory. The default implementation relies on Log4j.

Remove MVC Configurations

MVC Configurations can now be removed from the application's MVCGroupManager. This paves the way for application plugins that may be turned on/off at runtime.

Vetoable Models

In the past GriffonModel implemented the griffon.core.Observable. With this release they got upgraded to griffon.core.Vetoable.

Skip Lifecycle Script/Handlers

Applications now have the choice of skipping the execution of lifecycle scripts at their discretion. Specify the following flag in Config.groovy to skip them

app.lifecycle.handler.disable = true

1.1.3 Compatibility

Groovy 2.0 Support

Griffon 1.2.0 has upgraded to Groovy 2.0, which for most part is binary compatible with Groovy 1.8.x. Be advised the Groovy 2.x compiler is stricter than previous versions, you may experience some trouble with particular sources, for which solutions are not that difficult to find.

Upgraded dependencies

Griffon has upgraded some of its dependencies. The following list specify which ones exactly

  • slf4j-api 1.7.2
  • slf4j-log4j12 1.7.2
  • jcl-over-slf4j 1.7.2
  • jul-to-slf4j 1.7.2
  • org.springframework.beans 3.2.0.RELEASE
  • org.springframework.context 3.2.0.RELEASE
  • org.springframework.context.support 3.2.0.RELEASE
  • org.springframework.core 3.2.0.RELEASE

Removals

Applications no longer trigger an Log4jConfigStart event when bootstrapping. The GriffonApplication.Event.LOG4J_CONFIG_START constant value has been removed@.