0
Griffon in Depth BOF-5189 Danno Ferrin Intelligent Software Solutions, Inc. James Williams Code Herd, LLC Speaker logo cen...
What is Griffon?
What is Griffon?
file:///C:/Users/danno.ferrin/Pictures/Griffons/Griffon%20the%20Band.jpg What is Griffon?
What is Griffon?
What is Griffon?
What is Griffon?
What is Griffon?
What is Griffon?
What is Griffon? <ul><ul><li>Mythological Creature </li></ul></ul><ul><ul><li>Part Lion </li></ul></ul><ul><ul><li>Part Ea...
What is Griffon? <ul><ul><li>Mythological Creature </li></ul></ul><ul><ul><li>Part Lion </li></ul></ul><ul><ul><li>Part Ea...
The Rails Tenets <ul><ul><li>Convention Over Configuration </li></ul></ul><ul><ul><li>Don't Repeat Yourself </li></ul></ul...
The Rails Tenets <ul><ul><li>Convention Over Configuration </li></ul></ul><ul><ul><li>Don't Repeat Yourself </li></ul></ul...
The Rails Tenets <ul><ul><li>Convention Over Configuration - Yes! </li></ul></ul><ul><ul><li>Don't Repeat Yourself - Yes! ...
The Griffon Tenets <ul><ul><li>Convention Over Configuration </li></ul></ul><ul><ul><li>Don't Repeat Yourself </li></ul></...
Agenda <ul><ul><li>Convention Over Configuration </li></ul></ul><ul><ul><li>File Layout </li></ul></ul><ul><ul><li>How an ...
Convention over configuration
Convention Over Configuration <ul><ul><li>Java Desktop Application Conventions are MIA </li></ul></ul><ul><ul><li>Very few...
File Layout <ul><li>Source code in </li></ul><ul><ul><li>griffon-app </li></ul></ul><ul><ul><ul><li>models , views , contr...
How an App is Packaged <ul><ul><li>Results go into <root>/staging </li></ul></ul><ul><ul><li>Changed in griffon-app/config...
How an App is Packaged <ul><ul><li>Results include: </li></ul></ul><ul><ul><li>The jar from source code </li></ul></ul><ul...
Runtime Lifecycle Scripts <ul><ul><li>Lifecycle Scripts are in griffon-app/lifecycle   </li></ul></ul><ul><ul><li>Lifecycl...
Runtime Lifecycle Scripts Continued <ul><ul><li>Startup called - after initial config </li></ul></ul><ul><ul><li>The first...
Don’t Repeat Yourself
Don’t Repeat Yourself <ul><ul><li>How?  Use a Dynamic Language! </li></ul></ul><ul><ul><li>With Closures/Blocks </li></ul>...
Pervasive MVC
MVC and Swing <ul><li>The MVC Pattern is Great… </li></ul><ul><ul><li>But Swing Provides a Low Effort to Reward Ratio </li...
MVC Groups – Pervasive Reuse <ul><li>How many MVC Groups here? </li></ul>
MVC Groups – Pervasive Reuse <ul><li>How many MVC Groups here? </li></ul><ul><li>Three Types </li></ul><ul><ul><li>Greet –...
MVC Groups – How to use (Build time) <ul><li>Call create-mvc  script at build time </li></ul><ul><ul><li>Optional argument...
MVC Groups – Portion Instances <ul><li>Portions are Classes or Groovy Scripts </li></ul><ul><ul><li>After instantiation an...
MVC Groups – Injection <ul><li>MVC Portions have values injected if available </li></ul><ul><ul><li>Scripts have values ad...
MVC Groups – Creating New Groups <ul><li>Each portion is a script or a class </li></ul><ul><ul><li>Classes can have mvcGro...
MVC Groups – createMVCGroup Flow <ul><li>Meta Class Injections of portion classes </li></ul><ul><li>Instantiate Portions v...
MVC Groups – Coming in 0.2 <ul><li>Ability to add arbitrary portions </li></ul><ul><ul><li>For example, actions portion fo...
Write Good tests
Built-in Testing <ul><li>Griffon has built in support for testing </li></ul><ul><ul><li>create-mvc  script creates a test ...
Testing Plugins <ul><li>Sometimes apps need more involved testing </li></ul><ul><ul><li>fest </li></ul></ul><ul><ul><ul><l...
Automate Tasks
Scripts and Events <ul><li>Griffon runs most of it’s tasks from gant scripts </li></ul><ul><ul><li>Script file format is a...
Plugins <ul><li>Griffon supports plugins a lot like Grails </li></ul><ul><li>This is how most periphery functionality is a...
Builder Plugins <ul><li>Plugins for common widget sets and APIs </li></ul><ul><ul><li>swingx-builder </li></ul></ul><ul><u...
Other Plugins <ul><li>Plugins can add just about any periphery functionality </li></ul><ul><ul><li>installer </li></ul></u...
Twittersphere <ul><li>Griffon Application integrating Nasa World Wind </li></ul><ul><li>http://github.com/griffon/twitters...
Questions and Answers
Danno Ferrin @shemnon James Williams @ecspike
Upcoming SlideShare
Loading in...5
×

JavaOne 2009 BOF-5189 Griffon In Depth

1,575

Published on

The Griffon BOF from the 2009 JavaOne conference.

Published in: Technology, Education
1 Comment
4 Likes
Statistics
Notes
  • Typo in the slides:
    it's = it is or it has
    its = possessive
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
1,575
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
86
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide
  • Transcript of "JavaOne 2009 BOF-5189 Griffon In Depth"

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

      Clipping is a handy way to collect important slides you want to go back to later.

    ×