Groovy Monkey http://groovy.codehaus.org/Groovy+Monkey
About Me <ul><li>Java Developer since 1999 </li></ul><ul><li>Eclipse Plugin Developer since 2002 </li></ul><ul><li>Groovy ...
About Me “ I am not just the author of Groovy Monkey,  I'm a user...”  -- paraphrased from the founder of “Hair Club for M...
Agenda <ul><li>Why Groovy Monkey? </li></ul><ul><li>What is Groovy Monkey? </li></ul><ul><li>I'm from Missouri, Show Me......
Why Groovy Monkey? <ul><li>To be more productive with Eclipse, thats why. </li></ul>
Why Groovy Monkey? <ul><li>Wanted a tool to facilitate the following: </li></ul><ul><ul><li>Eclipse API Exploration </li><...
Why Groovy Monkey? <ul><li>Found Eclipse Monkey but it was too limiting: </li></ul><ul><ul><li>Could only write scripts in...
Why Groovy Monkey? <ul><li>I am a power Eclipse User and Plugin developer and I want my life to be easier: </li></ul><ul><...
What is Groovy Monkey? <ul><li>Groovy Monkey is a branch/port of the Eclipse Monkey tool based on:  </li></ul><ul><ul><li>...
What is Groovy Monkey? <ul><li>Bean Scripting framework  </li></ul><ul><ul><li>http://jakarta.apache.org/bsf/ </li></ul></...
What is Groovy Monkey? <ul><li>The Eclipse Jobs API is the native Eclipse platform support for threading.  Allows for thre...
What is Groovy Monkey? <ul><li>The OSGi framework packages components in bundles, which are uniquely identified.  Groovy M...
 
Show me: How to install <ul><li>If not included in your Eclipse distribution, goto the update site: </li></ul><ul><ul><li>...
Show Me: A Script <ul><li>A script has two parts, the metadata and then the script body. </li></ul><ul><li>/* </li></ul><u...
Show Me: A Script: Results <ul><li>The amazing results of this script is: </li></ul><ul><ul><li>Drum Roll please...... </l...
Anatomy of a Script <ul><li>Script is composed of two parts: </li></ul><ul><li>Script Metadata Header </li></ul><ul><ul><l...
Script Anatomy: Tags <ul><li>Menu </li></ul><ul><ul><li>Determines where in the Monkey Menu the script can be invoked/edit...
Script Anatomy: Tags <ul><li>'Lang'  </li></ul><ul><ul><li>The first tag I added to Monkey </li></ul></ul><ul><ul><li>By d...
Script Anatomy: Tags <ul><li>Lang cont'd: </li></ul><ul><ul><li>Maps to a BSFEngine implementation that is wrapped in an e...
Script Anatomy: Tags <ul><li>Job </li></ul><ul><ul><li>The most important part of Groovy Monkey over Eclipse Monkey, runni...
Script Anatomy: Tags <ul><li>Job cont'd </li></ul><ul><ul><li>Allows us to bind (more on this under DOMs) a progress monit...
Script Anatomy: Tags <ul><li>Exec-Mode tag: </li></ul><ul><ul><li>Complementary to the Job tag </li></ul></ul><ul><ul><li>...
Script Anatomy: Tags <ul><li>Include </li></ul><ul><ul><li>Allows you to include elements in the workspace in the classloa...
Script Anatomy: Tags <ul><li>Include-Bundle </li></ul><ul><ul><li>This is what makes Eclipse API exploration and plugin ra...
Script Anatomy: Tags <ul><li>DOM </li></ul><ul><ul><li>net.sf.groovyMonkey.dom </li></ul></ul><ul><ul><li>An extension pro...
“ Batteries Included” <ul><li>Groovy Monkey includes several things to hopefully simplify script writing: </li></ul><ul><l...
“ Batteries Included” <ul><li>Default DOM(s): </li></ul>
“ Batteries Included” <ul><li>DOM(s) included by default: </li></ul><ul><li>bsf: maps to org.apache.bsf.util.BSFFunctions ...
“ Batteries Included” <ul><li>DOM(s) included by default cont'd: </li></ul><ul><li>monitor: Access to the IProgressMonitor...
“ Batteries Included” <ul><li>Default Include-Bundles: </li></ul>
“ Batteries Included” <ul><li>Groovy Monkey Editor: Code Completion </li></ul>
“ Batteries Included” <ul><li>Groovy Monkey Editor: Popup commands </li></ul>
“ Batteries Included” <ul><li>Groovy Monkey Outline View </li></ul>
“ Batteries Included” <ul><li>Sharing </li></ul><ul><ul><li>“ A script that is kept to yourself is only useful to you.” --...
Future Plans <ul><li>Add Jython engine with support for Include and Include-Bundle keywords </li></ul><ul><li>Add Glimmer ...
Monkey Resources <ul><li>http://iacobus.blogspot.com/ </li></ul><ul><li>http://groovy.codehaus.org/Groovy+Monkey </li></ul...
Questions?
Upcoming SlideShare
Loading in …5
×

Introduction to Groovy Monkey

5,872 views

Published on

Introduction to the Eclipse scripting tool Groovy Monkey. Groovy Monkey allows for you to engage in API exploration, Task Automation, Plugin prototyping and collaboration in a lightweight and simple way.

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
  • Is version 0.4 the latest available version. Or do I have the wrong download URL?

    http://sourceforge.net/project/showfiles.php?group_id=168501
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
5,872
On SlideShare
0
From Embeds
0
Number of Embeds
1,599
Actions
Shares
0
Downloads
56
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide
  • Introduction to Groovy Monkey

    1. 1. Groovy Monkey http://groovy.codehaus.org/Groovy+Monkey
    2. 2. About Me <ul><li>Java Developer since 1999 </li></ul><ul><li>Eclipse Plugin Developer since 2002 </li></ul><ul><li>Groovy Eclipse committer since 2005 </li></ul><ul><li>Author of Groovy Monkey </li></ul>
    3. 3. About Me “ I am not just the author of Groovy Monkey, I'm a user...” -- paraphrased from the founder of “Hair Club for Men” -- James E. Ervin
    4. 4. Agenda <ul><li>Why Groovy Monkey? </li></ul><ul><li>What is Groovy Monkey? </li></ul><ul><li>I'm from Missouri, Show Me.... </li></ul><ul><li>Anatomy of a script </li></ul><ul><li>Script Examples </li></ul><ul><li>...Batteries Included </li></ul><ul><li>Future plans </li></ul><ul><li>Monkey Resources </li></ul><ul><li>Q&A </li></ul>
    5. 5. Why Groovy Monkey? <ul><li>To be more productive with Eclipse, thats why. </li></ul>
    6. 6. Why Groovy Monkey? <ul><li>Wanted a tool to facilitate the following: </li></ul><ul><ul><li>Eclipse API Exploration </li></ul></ul><ul><ul><ul><li>Self hosting is too slow and cumbersome </li></ul></ul></ul><ul><ul><ul><li>Plugin creation is too much overhead for exploration </li></ul></ul></ul><ul><ul><ul><li>The Eclipse API is complex </li></ul></ul></ul><ul><ul><li>Task Automation </li></ul></ul><ul><ul><ul><li>To add functionality too small to be a plugin </li></ul></ul></ul><ul><ul><li>Rapid prototyping with path to a plugin </li></ul></ul><ul><ul><ul><li>In case the small grows big </li></ul></ul></ul>
    7. 7. Why Groovy Monkey? <ul><li>Found Eclipse Monkey but it was too limiting: </li></ul><ul><ul><li>Could only write scripts in ECMAScript (JavaScript)‏ </li></ul></ul><ul><ul><ul><li>There is a nice library called Bean Scripting Framework, so why not let everyone play? </li></ul></ul></ul><ul><ul><li>Everything runs in the UI Thread </li></ul></ul><ul><ul><ul><li>Why not use the Eclipse Jobs API? </li></ul></ul></ul><ul><ul><li>Could only invoke code exposed through a DOM </li></ul></ul><ul><ul><ul><li>What about installed bundles? </li></ul></ul></ul><ul><ul><ul><li>How about adding library jars? </li></ul></ul></ul>
    8. 8. Why Groovy Monkey? <ul><li>I am a power Eclipse User and Plugin developer and I want my life to be easier: </li></ul><ul><ul><li>I want to be able to quickly try parts of the Eclipse API without the overhead of a plugin </li></ul></ul><ul><ul><li>I want to be able to write quick/reusable functionality (i.e. task automation) to make my life with Eclipse easier </li></ul></ul><ul><ul><li>I want to be able to translate the quick and dirty work eventually into a proper plugin </li></ul></ul>
    9. 9. What is Groovy Monkey? <ul><li>Groovy Monkey is a branch/port of the Eclipse Monkey tool based on: </li></ul><ul><ul><li>Apache Bean Scripting Framework </li></ul></ul><ul><ul><li>The Eclipse Jobs API </li></ul></ul><ul><ul><li>OSGi framework </li></ul></ul>
    10. 10. What is Groovy Monkey? <ul><li>Bean Scripting framework </li></ul><ul><ul><li>http://jakarta.apache.org/bsf/ </li></ul></ul><ul><ul><li>Open source project that predates javax.script in Java 6.0 </li></ul></ul><ul><ul><li>Provides scripting engines for the most used scripting languages </li></ul></ul><ul><ul><li>Allows Groovy Monkey scripts to be written in Groovy, Beanshell and Ruby (soon hopefully Python as well)‏ </li></ul></ul>
    11. 11. What is Groovy Monkey? <ul><li>The Eclipse Jobs API is the native Eclipse platform support for threading. Allows for three types: </li></ul><ul><ul><li>Job: Ordinary job thread, provides a progress monitor and status in the progress view </li></ul></ul><ul><ul><li>WorkspaceJob: Batches updates to resource listeners until after the job is complete </li></ul></ul><ul><ul><li>UIJob: Runs in the SWT UI Thread </li></ul></ul>
    12. 12. What is Groovy Monkey? <ul><li>The OSGi framework packages components in bundles, which are uniquely identified. Groovy Monkey leverages the OSGi container by: </li></ul><ul><ul><li>Groovy Monkey can add the classloader of any bundle on the workbench to a script's classloader </li></ul></ul><ul><ul><li>Allows Groovy Monkey to do white box introspection of running bundles/plugins </li></ul></ul>
    13. 14. Show me: How to install <ul><li>If not included in your Eclipse distribution, goto the update site: </li></ul><ul><ul><li>http://groovy-monkey.sourceforge.net/update </li></ul></ul>
    14. 15. Show Me: A Script <ul><li>A script has two parts, the metadata and then the script body. </li></ul><ul><li>/* </li></ul><ul><li>* Menu: Open Dialog > Groovy </li></ul><ul><li>* Script-Path: /EclipseMonkeyScripts/monkey/OpenDialog_Groovy.gm </li></ul><ul><li>* Kudos: ervinja </li></ul><ul><li>* License: EPL 1.0 </li></ul><ul><li>* Job: UIJob </li></ul><ul><li>*/ </li></ul><ul><li>org.eclipse.jface.dialogs.MessageDialog.openInformation( window.getShell(), </li></ul><ul><li>'Monkey Dialog', </li></ul><ul><li> 'Hello World from Groovy' )‏ </li></ul><ul><li>Right click to run the script from within Eclipse </li></ul>
    15. 16. Show Me: A Script: Results <ul><li>The amazing results of this script is: </li></ul><ul><ul><li>Drum Roll please...... </li></ul></ul><ul><li>Note: Wait for enthusiastic applause from audience </li></ul>
    16. 17. Anatomy of a Script <ul><li>Script is composed of two parts: </li></ul><ul><li>Script Metadata Header </li></ul><ul><ul><li>This is the portion that is specific to monkey </li></ul></ul><ul><ul><li>Tags serve to setup classloader and configure script </li></ul></ul><ul><li>Script Body </li></ul><ul><ul><li>Vital obviously, but Monkey delegates this to the BSFEngine for the given language. </li></ul></ul>
    17. 18. Script Anatomy: Tags <ul><li>Menu </li></ul><ul><ul><li>Determines where in the Monkey Menu the script can be invoked/edited </li></ul></ul>
    18. 19. Script Anatomy: Tags <ul><li>'Lang' </li></ul><ul><ul><li>The first tag I added to Monkey </li></ul></ul><ul><ul><li>By default is set to 'Groovy' </li></ul></ul><ul><ul><li>Valid entries are: </li></ul></ul><ul><ul><ul><li>Groovy *(default)‏ </li></ul></ul></ul><ul><ul><ul><li>Beanshell </li></ul></ul></ul><ul><ul><ul><li>Ruby </li></ul></ul></ul><ul><ul><ul><li>Python** </li></ul></ul></ul>
    19. 20. Script Anatomy: Tags <ul><li>Lang cont'd: </li></ul><ul><ul><li>Maps to a BSFEngine implementation that is wrapped in an extension point: </li></ul></ul><ul><ul><ul><li>net.sf.groovyMonkey.lang </li></ul></ul></ul><ul><ul><ul><li>List of supported languages is not hardcoded </li></ul></ul></ul><ul><ul><ul><li>Additional language support can be easily plugged in if the BSFEngine implementation can be found. </li></ul></ul></ul>
    20. 21. Script Anatomy: Tags <ul><li>Job </li></ul><ul><ul><li>The most important part of Groovy Monkey over Eclipse Monkey, running scripts in separate threads. </li></ul></ul><ul><ul><li>By default a script is run inside an Eclipse 'Job' </li></ul></ul><ul><ul><li>Valid Entries: </li></ul></ul><ul><ul><ul><li>Job* (default) – org.eclipse.core.runtime.Job </li></ul></ul></ul><ul><ul><ul><li>WorkspaceJob – org.eclipse.core.resources.WorkspaceJob </li></ul></ul></ul><ul><ul><ul><li>UIJob - org.eclipse.ui.progress.UIJob </li></ul></ul></ul>
    21. 22. Script Anatomy: Tags <ul><li>Job cont'd </li></ul><ul><ul><li>Allows us to bind (more on this under DOMs) a progress monitor to the script </li></ul></ul><ul><ul><li>Script writer can provide progress and allow cancellation </li></ul></ul><ul><ul><li>Scripts become Eclipse Jobs, which means that they can be monitored in the progress view. </li></ul></ul><ul><ul><li>One gotcha, UIJob is provided as a convenience, it is best to use it sparingly </li></ul></ul>
    22. 23. Script Anatomy: Tags <ul><li>Exec-Mode tag: </li></ul><ul><ul><li>Complementary to the Job tag </li></ul></ul><ul><ul><li>Allows jobs to be run the the foreground or in the background </li></ul></ul><ul><ul><li>Valid values: </li></ul></ul><ul><ul><ul><li>background* (default) </li></ul></ul></ul><ul><ul><ul><li>foreground – Eclipse pops up a modal dialog box to show the progress of the script. </li></ul></ul></ul>
    23. 24. Script Anatomy: Tags <ul><li>Include </li></ul><ul><ul><li>Allows you to include elements in the workspace in the classloader of the script. </li></ul></ul><ul><ul><li>Allows you to try new third party jars immediately and makes Groovy Monkey a more general scripting tool </li></ul></ul><ul><ul><li>Can add a jar in the workspace or a class folder </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>* Include: /MonkeyScripts/commons-http-client.jar </li></ul></ul></ul>
    24. 25. Script Anatomy: Tags <ul><li>Include-Bundle </li></ul><ul><ul><li>This is what makes Eclipse API exploration and plugin rapid prototyping possible. </li></ul></ul><ul><ul><li>You specify the bundle identifier for a bundle loaded in the workbench and its classloader is added to the classloader of the script. </li></ul></ul><ul><ul><li>There are a number of bundles included by default* </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>* Include-Bundle: org.eclipse.ui.ide </li></ul></ul></ul>
    25. 26. Script Anatomy: Tags <ul><li>DOM </li></ul><ul><ul><li>net.sf.groovyMonkey.dom </li></ul></ul><ul><ul><li>An extension provided by a bundle, that provides an API for script writers </li></ul></ul><ul><ul><li>They get bound to variable names in the script at runtime. </li></ul></ul><ul><ul><li>First step from script to full blown bundle. </li></ul></ul><ul><ul><li>There are a set of DOM(s) included by default </li></ul></ul><ul><ul><li>Syntax: </li></ul></ul><ul><ul><ul><li>* DOM: net.sf.groovyMonkey.dom.console </li></ul></ul></ul>
    26. 27. “ Batteries Included” <ul><li>Groovy Monkey includes several things to hopefully simplify script writing: </li></ul><ul><li>Default DOM(s)‏ </li></ul><ul><li>Default Bundles </li></ul><ul><li>Editor </li></ul><ul><li>Outline View </li></ul><ul><li>Sharing </li></ul>
    27. 28. “ Batteries Included” <ul><li>Default DOM(s): </li></ul>
    28. 29. “ Batteries Included” <ul><li>DOM(s) included by default: </li></ul><ul><li>bsf: maps to org.apache.bsf.util.BSFFunctions </li></ul><ul><li>bundleDOM: Access to the bundle and bundles installed in the workbench </li></ul><ul><li>bundlerDOM: Utility DOM to allow you to build/package plugins from your workspace </li></ul><ul><li>jface: Access to the SWTBuilder in groovy for UI work </li></ul><ul><li>metadata: Access to the ScriptMetadata instance that contains the information defined in the metadata header of the script </li></ul>
    29. 30. “ Batteries Included” <ul><li>DOM(s) included by default cont'd: </li></ul><ul><li>monitor: Access to the IProgressMonitor the Script's Job is using. </li></ul><ul><li>project: Legacy DOM </li></ul><ul><li>resources: Legacy DOM </li></ul><ul><li>runnerDOM: Cool DOM that allows you to invoke other scripts in the workspace. </li></ul><ul><li>window: Access to the IWorkspaceWindow in the current Eclipse workbench. </li></ul><ul><li>workspace: Access to the IWorkspace instance representing the current Eclipse workspace. </li></ul>
    30. 31. “ Batteries Included” <ul><li>Default Include-Bundles: </li></ul>
    31. 32. “ Batteries Included” <ul><li>Groovy Monkey Editor: Code Completion </li></ul>
    32. 33. “ Batteries Included” <ul><li>Groovy Monkey Editor: Popup commands </li></ul>
    33. 34. “ Batteries Included” <ul><li>Groovy Monkey Outline View </li></ul>
    34. 35. “ Batteries Included” <ul><li>Sharing </li></ul><ul><ul><li>“ A script that is kept to yourself is only useful to you.” -- James E. Ervin from this presentation </li></ul></ul>
    35. 36. Future Plans <ul><li>Add Jython engine with support for Include and Include-Bundle keywords </li></ul><ul><li>Add Glimmer library for GUI work in Ruby </li></ul><ul><li>Integrate with the new Plugin Spy coming in Eclipse 3.4 </li></ul><ul><li>Allow scripts to be packaged in bundles </li></ul>
    36. 37. Monkey Resources <ul><li>http://iacobus.blogspot.com/ </li></ul><ul><li>http://groovy.codehaus.org/Groovy+Monkey </li></ul><ul><li>http://sourceforge.net/projects/groovy-monkey </li></ul><ul><li>http://eclipse.dzone.com/news/introduction-scripting-eclipse </li></ul><ul><li>http://jakarta.apache.org/bsf/ </li></ul>
    37. 38. Questions?

    ×