The Griffon BOF from the 2009 JavaOne conference.
- 1. Griffon in Depth BOF-5189 Danno Ferrin Intelligent Software
Solutions, Inc. James Williams Code Herd, LLC Speaker logo centered
below photo
2. What is Griffon? 3. What is Griffon? 4.
file:///C:/Users/danno.ferrin/Pictures/Griffons/Griffon%20the%20Band.jpg
What is Griffon? 5. What is Griffon? 6. What is Griffon? 7. What is
Griffon? 8. What is Griffon? 9. What is Griffon? 10. What is
Griffon?
-
- A Magical Beast
http://www.d20srd.org/srd/monsters/griffon.htm
11. What is Griffon?
-
- A Magical Beast
http://www.d20srd.org/srd/monsters/griffon.htm
-
- For Rich Internet Applications
-
- Written with Groovy http://griffon.codehaus.org/
12. The Rails Tenets
-
- Convention Over Configuration
-
- Fat Model/Skinny Controller
-
http://wiki.rubyonrails.org/getting-started/overview/tenets
13. The Rails Tenets
-
- Convention Over Configuration
-
- Fat Model/Skinny Controller
-
- RIAs have a different nature from Web Apps
-
http://wiki.rubyonrails.org/getting-started/overview/tenets
14. The Rails Tenets
-
- Convention Over Configuration - Yes!
-
- Don't Repeat Yourself - Yes!
-
- Fat Model/Skinny Controller
-
- RIAs have a different nature from Web Apps
-
http://wiki.rubyonrails.org/getting-started/overview/tenets
15. The Griffon Tenets
-
- Convention Over Configuration
-
- Its not just for Web Applications!
16. Agenda
-
- Convention Over Configuration
-
- Dynamic Language Features
17. Convention over configuration 18. Convention Over
Configuration
-
- Java Desktop Application Conventions are MIA
-
- Very few official examples
-
- No Blueprints (Like Java EE Blueprints)
-
- We have to create our own
-
- Following Grails Patterns
-
- Source Files Segregated by Role
- Standardize App Lifecycle (like JSR-296)
- Automated Packaging (App, WebStart , Applet)
19. File Layout
-
-
- models , views , controllers
20. How an App is Packaged
-
- Changed in griffon-app/config/Config.groovy via the
griffon.jars.destDirproperty
-
-
- i.e. you could target a dir in your grails app
-
- What goes in the Source Jar?
-
- Compiled Groovy/Java files
-
-
- src/main/**and griffon-app/*/**
-
-
-
- Some explicit exceptions ( griffon-app/conf/Config ,
assets)
-
- Assets in griffon-app/i18n/** and griffon-app/resources/**
21. How an App is Packaged
-
- The Groovy jar and griffon-rt jar
-
- Files from griffon-app/conf/webstart
-
-
- ant search and replace is done on jnlp and html files
-
- Files in /lib(but not sub-directories)
-
- Pack200 variants of all result jars
-
- Plugins may add and alter stuff via Eventing
22. Runtime Lifecycle Scripts
-
- Lifecycle Scripts are in griffon-app/lifecycle
-
- Lifecycle Events modeled after JSR-296
-
- Init called - before anything griffon setup
-
- Application.groovy Loaded
-
- Builder.groovy loaded - SwingBuilder and such
-
- Events.groovy loaded and linked (non-lifecycle events)
-
- Startup MVC Groups instantiated
23. Runtime Lifecycle Scripts Continued
-
- Startup called - after initial config
-
- The first app frame is made visible
-
- Ready called - called after the EDT calms down
-
- Shutdown called - manually or automatically
-
- Auto-shutdown can be disabled in Application.groovy
24. Dont Repeat Yourself 25. Dont Repeat Yourself
-
- How? Use a Dynamic Language!
-
- With terse property syntax myJTextArea.text = "Fires Property
Change"
-
- With terse eventing syntax button.actionPerformed = {println
'hi'}
-
- With Rich Annotation Support @Bindable String
aBoundProperty
-
- Most of this impacts the View Layer
-
- See JavaOne 2008 TS-5098 - Building Rich Applicaitons with
Groovy's SwingBuilder
26. Pervasive MVC 27. MVC and Swing
-
- But Swing Provides a Low Effort to Reward Ratio
-
- Language Level Support for Data Binding
-
- Framework Level Support for MVC Triads
28. MVC Groups Pervasive Reuse
- How many MVC Groups here?
29. MVC Groups Pervasive Reuse
- How many MVC Groups here?
-
- Greet The main Application
-
- UserPane The user details
-
- Two UserPanes (on each @ tab)
-
- Three TimelinePanes (one per tab)
30. MVC Groups How to use (Build time)
- Call create-mvcscript at build time
-
- Optional argument is the MVC type
-
-
- Will prompt if arg not provided
-
-
- Can be package qualified, but package is stripped from mvc type
name.
-
-
- com.example.Foohas mvc type of Foo
-
- Adds mvcGroupentry into Application.groovy
-
- Generates stub files in models / views / controllers
-
-
- Will be in package if name had a package
-
-
-
- com.example.FooModel com.example.FooContoller
com.example.FooView
31. MVC Groups Portion Instances
- Portions are Classes or Groovy Scripts
-
- After instantiation and injection mvcGroupInit(Map)is called if
present
-
-
- Map has named args from createMVCGroup()call
-
- No Mandatory Class Declarations
-
- Looks Like Free-Form Code
-
- Views may be classes in 0.2.x
32. MVC Groups Injection
- MVC Portions have values injected if available
-
- Scripts have values added to binding
-
- Classes data is injected into properties
-
- model, view, controller, builder
- Methods are also injected via Groovy MetaClass
-
- createMVCGroup()is always injected (curried with current app as
first parameter)
-
- On a per-portion basis in Builder.groovy
-
-
- edt , doLater , doOutsidefrom SwingBuilder
33. MVC Groups Creating New Groups
- Each portion is a script or a class
-
- Classes can have mvcGroupInit()method for post-injection
initialization
- Call createMVCGroup()at runtime
-
- Mandatory 1st arg: mvc type name
-
- Optional 2nd arg: tracking name
-
-
- Useful when you use a group multiple times
-
- Optional Named Params: passed into mvcGroupInitor in script
binding
-
- Returns a List of the instances of portions
34. MVC Groups createMVCGroup Flow
- Meta Class Injections of portion classes
- Instantiate Portions via no-args constructor
-
- Portions named controller listen to app events
- Call mvcGroupInit or execute script
-
- Scripts named view are executed in the EDT
- Everything portion is done in a fixed order
-
- Griffon 0.1 order is model controller view
-
- Griffon 0.2 order is the order of declaration
35. MVC Groups Coming in 0.2
- Ability to add arbitrary portions
-
- For example, actions portion for Action objects
- User Controlled Initialization order
-
- The order you declare is the init order
-
- Either calls mvcGroupInitor executes the script
- Named args to createMVCGroup()are injected into MVCGroup
portions
- Add support for mvcGroupPostInit Safe harbor warning: these are
forward looking statements.May change at any time without
notice.Offer void in Connecticut and Puerto Rico or where
prohibited by law. Offer applies with enrollment in triple
advantage.Do not taunt happy fun ball.
36. Write Good tests 37. Built-in Testing
- Griffon has built in support for testing
-
- create-mvcscript creates a test file in test/integration
-
-
- See JavaOne 2008 TS-5101 Boosting your Testing Productivity
with Groovy
-
-
- Griffon doesnt write the test for you
-
- test-appscript executes the tests for you
-
-
- Bootstraps the application for you
-
-
- Evereything up to instantiating MVC Groups
38. Testing Plugins
- Sometimes apps need more involved testing
-
-
- Fluent interface for functional swing testing
-
-
- Behavioral Driven Development
39. Automate Tasks 40. Scripts and Events
- Griffon runs most of its tasks from gant scripts
-
- Script file format is a Groovy Script
-
- Ant library is accessible via gant
- Griffon fires events as script steps happen
-
- Event Listeners are Closures
- Users can add scripts in scripts directory
-
- Events are added via an _Events.groovyscript
41. Plugins
- Griffon supports plugins a lot like Grails
- This is how most periphery functionality is added
- list-pluginsscript lists the plugins
- install-pluginscript adds the plugins
- Plugins are stored outside of project
42. Builder Plugins
- Plugins for common widget sets and APIs
- Adds the needed Builder.groovy config
- Adds the library jars as part of packaging
43. Other Plugins
- Plugins can add just about any periphery functionality
-
-
- Adds scripts to create a izPack installer for your app
-
-
- Adds scala interop with Griffon and Groovy
-
-
- Adds a splash screen durring init
44. Twittersphere
- Griffon Application integrating Nasa World Wind
- http://github.com/griffon/twittersphere/tree/master
45. Questions and Answers 46. Danno Ferrin @shemnon James
Williams @ecspike