What’s new in Groovy 1.6 Guillaume Laforge SpringSource Groovy Project Manager
Guillaume Laforge Groovy Project Manager — SpringSource <ul><li>Working on Groovy since 2003 </li></ul><ul><li>JSR-241 Spe...
What’s new in Groovy 1.6? Article Published by InfoQ <ul><li>This presentation was prepared with the examples I’ve used in...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
Groovy in a Nutshell Simplify the Life of Java Developers <ul><li>Groovy is a  dynamic language  for the Java Virtual Mach...
Features at a Glance Lots More Than This! <ul><li>Fully Object-Oriented </li></ul><ul><li>Joint compiler : seamless Java i...
A Taste of Groovy — Take 1 A Normal Java Program <ul><li>public class HelloWorld {   private String name;   public void se...
A Taste of Groovy — Take 2 A Valid Groovy Program <ul><li>public class HelloWorld {   private String name;   public void s...
A Taste of Groovy — Take 3 A Groovier Program! <ul><li>class HelloWorld {   String name   String greet() { &quot;Hello $na...
The Groovy Web Console A Groovy Playground <ul><li>Groovy works nicely on  Google App Engine </li></ul><ul><ul><li>You can...
The Groovy Web Console A Screenshot
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
Performance Improvements Both Runtime & Compile-Time <ul><li>The Groovyc compiler is  3x to 5x faster </li></ul><ul><ul><l...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
Multiple Assignment Assign Multiple Variables at Once <ul><li>Newly defined variables </li></ul><ul><ul><li>def (a, b) = [...
More Optional Return In if/else and try/catch Blocks <ul><li>The  return  keyword is optional for the last expression of a...
Annotation Definition The Missing Bit of Java 5 Support <ul><li>Groovy support for Java 5 features is now complete with th...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
Meta-What? Meta-Programming <ul><li>The ability of a language to modify itself </li></ul><ul><li>Groovy 1.6 introduces  AS...
AST Transformations in Groovy 1.6 Implement Patterns through Transformations <ul><li>Several transformations finds their w...
@Singleton (Anti-)Pattern Revisited <ul><li>The evil Java singleton </li></ul><ul><ul><li>public class Evil {   public sta...
@Immutable The Immutable… Boiler-Plate Code <ul><li>To properly implement immutable classes </li></ul><ul><ul><li>No mutat...
@Lazy Not Just for Lazy Dudes! <ul><li>When you need to lazy evaluate / instantiate complex data structures for class fiel...
@Delegate Not Just for Managers!  <ul><li>You can delegate to fields of your class </li></ul><ul><ul><li>Think multiple in...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
Grab a Grape Groovy Advanced Packaging Engine <ul><li>Helps you distribute scripts without dependencies </li></ul><ul><li>...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
@Bindable (1/2) Event-Driven Made Easy <ul><li>Speaking of boiler-plate code… property change listeners </li></ul><ul><li>...
@Bindable (2/2) Event-Driven Made Easy <ul><li>Groovy’s solution </li></ul><ul><ul><li>class MyBean {   @Bindable String p...
Griffon The Swing MVC Framework <ul><li>Leverages Groovy’s SwingBuilder  and Grails’ infrastructure </li></ul><ul><ul><li>...
Swing Console Improvements <ul><li>The console can be run as an applet </li></ul><ul><li>Code indentation support </li></u...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
ExpandoMetaClass DSL Less Repetition <ul><li>EMC is a way to change the behavior of types at runtime </li></ul><ul><li>Bef...
Runtime Mixins Inject New Behavior to Types at Runtime <ul><li>class FlyingAbility {   def fly() { &quot;I'm ${name} and I...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
javax.script.* Scripting APIs Groovy Scripting Engine Built-In <ul><li>In Groovy 1.6, the JSR-223 / javax.script. * script...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
JMX Builder (1/2) Domain-Specific Language for JMX <ul><li>Simplify JMX handling with a Builder pattern approach </li></ul...
JMX Builder (2/2) Examples <ul><li>Create a connector server </li></ul><ul><ul><li>def jmx = new JmxBuilder() jmx.connecto...
Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul>...
OSGi Readiness <ul><li>The Groovy JAR contains OSGi metadata </li></ul><ul><ul><li>Can be reused in OSGi containers out-of...
Summary
Summary Just Remember that Groovy Rocks! :-) <ul><li>Groovy 1.6 provides </li></ul><ul><ul><li>Important performance gains...
Guillaume Laforge [email_address]
Upcoming SlideShare
Loading in...5
×

What's New in Groovy 1.6?

1,419

Published on

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,419
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
42
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

What's New in Groovy 1.6?

  1. 1. What’s new in Groovy 1.6 Guillaume Laforge SpringSource Groovy Project Manager
  2. 2. Guillaume Laforge Groovy Project Manager — SpringSource <ul><li>Working on Groovy since 2003 </li></ul><ul><li>JSR-241 Spec Lead </li></ul><ul><li>Initiator of the Grails web framework </li></ul><ul><li>Co-author of Groovy in Action </li></ul><ul><li>Speaker: JavaOne, QCon, JavaPolis/Devoxx, JavaZone, Sun Tech Days, SpringOne/The Spring Experience, JAX, DSL DevCon, and more… </li></ul>
  3. 3. What’s new in Groovy 1.6? Article Published by InfoQ <ul><li>This presentation was prepared with the examples I’ve used in my article written for InfoQ </li></ul><ul><li>http://www. infoq . com/articles/groovy-1-6 </li></ul><ul><li>Read this article for more detailed explanations of all the new features in Groovy 1.6 </li></ul>
  4. 4. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  5. 5. Groovy in a Nutshell Simplify the Life of Java Developers <ul><li>Groovy is a dynamic language for the Java Virtual Machine </li></ul><ul><ul><li>With a Meta-Object Protocol </li></ul></ul><ul><ul><li>Compiles down to bytecode </li></ul></ul><ul><li>Open Source Apache licensed project </li></ul><ul><li>Relaxed grammar derived from the Java 5 grammar </li></ul><ul><ul><li>Borrowed some good ideas from Smalltalk/Python/Ruby </li></ul></ul><ul><ul><li>Java 5 features out of the box: annotations , generics , static imports, enums… </li></ul></ul><ul><ul><li>Flat learning curve </li></ul></ul>
  6. 6. Features at a Glance Lots More Than This! <ul><li>Fully Object-Oriented </li></ul><ul><li>Joint compiler : seamless Java integration </li></ul><ul><li>Closures : reusable blocks of code / anon functions </li></ul><ul><li>Properties : forget about getters and setters </li></ul><ul><li>Optional typing: your choice! </li></ul><ul><li>BigDecimal arithmetic by default for floating point </li></ul><ul><li>Handy APIs </li></ul><ul><ul><li>XML, JDBC, JMX, template engine, Swing UIs </li></ul></ul><ul><li>Strong ability for authoring Domain-Specific Languages </li></ul><ul><ul><li>Syntax-level “builders” </li></ul></ul><ul><ul><li>Adding properties to numbers: 10.dollars </li></ul></ul><ul><ul><li>Operator overloading: 10.meters + 20.kilometers </li></ul></ul>
  7. 7. A Taste of Groovy — Take 1 A Normal Java Program <ul><li>public class HelloWorld { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } public String greet() { return &quot;Hello &quot; + name; } public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setName(&quot;Groovy&quot;); System.out.println( helloWorld.greet() ); } } </li></ul>
  8. 8. A Taste of Groovy — Take 2 A Valid Groovy Program <ul><li>public class HelloWorld { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } public String greet() { return &quot;Hello &quot; + name; } public static void main(String[] args) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setName(&quot;Groovy&quot;); System.out.println( helloWorld.greet() ); } } </li></ul>
  9. 9. A Taste of Groovy — Take 3 A Groovier Program! <ul><li>class HelloWorld { String name String greet() { &quot;Hello $name&quot; } } def helloWorld = new HelloWorld(name: &quot;Groovy&quot;) println helloWorld.greet() </li></ul>
  10. 10. The Groovy Web Console A Groovy Playground <ul><li>Groovy works nicely on Google App Engine </li></ul><ul><ul><li>You can also deploy Grails applications </li></ul></ul><ul><li>You can play with Groovy in the web console </li></ul><ul><ul><li>http: //groovyconsole . appspot . com/ </li></ul></ul>
  11. 11. The Groovy Web Console A Screenshot
  12. 12. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  13. 13. Performance Improvements Both Runtime & Compile-Time <ul><li>The Groovyc compiler is 3x to 5x faster </li></ul><ul><ul><li>With a clever class lookup cache </li></ul></ul><ul><li>Certain online micro-benchmarks show 150% to 460% increase in performance compared to Groovy 1.5 </li></ul><ul><ul><li>Thanks to advanced call-site caching techniques </li></ul></ul><ul><ul><li>Beware of micro-benchmarks! </li></ul></ul><ul><li>Makes Groovy one of the fastest dynamic languages available </li></ul>
  14. 14. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  15. 15. Multiple Assignment Assign Multiple Variables at Once <ul><li>Newly defined variables </li></ul><ul><ul><li>def (a, b) = [1, 2] assert a == 1 assert b == 2 </li></ul></ul><ul><li>Assign to existing variables </li></ul><ul><ul><li>def lat, lng (lat, lng) = geocode(‘Paris’) </li></ul></ul><ul><li>The classical swap case </li></ul><ul><ul><li>(a, b) = [b, a] </li></ul></ul><ul><li>Extra elements  not assigned to any variable </li></ul><ul><li>Less elements  null into extra variables </li></ul>
  16. 16. More Optional Return In if/else and try/catch Blocks <ul><li>The return keyword is optional for the last expression of a method body </li></ul><ul><ul><li>But if / else & try / catch didn’t return any value </li></ul></ul><ul><li>def method() { if (true) 1 else 0 } assert method() == 1 </li></ul><ul><li>def method(bool) { try { if (bool) throw new Exception(&quot;foo&quot;) 1 } catch(e) { 2 } finally { 3 } } assert method(false) == 1 assert method(true) == 2 </li></ul>
  17. 17. Annotation Definition The Missing Bit of Java 5 Support <ul><li>Groovy support for Java 5 features is now complete with the missing annotation definition </li></ul><ul><li>Nothing to show here, it’s just normal Java :-) </li></ul><ul><li>Note that the sole dynamic language supporting annotation is… Groovy </li></ul><ul><ul><li>Opens the door to EJB3 / JPA / Spring annotations / Guice / TestNG… </li></ul></ul>
  18. 18. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  19. 19. Meta-What? Meta-Programming <ul><li>The ability of a language to modify itself </li></ul><ul><li>Groovy 1.6 introduces AST Transformations </li></ul><ul><ul><li>Abstract Syntax Tree </li></ul></ul><ul><li>Goodbye to a lot of boiler-plate technical code! </li></ul><ul><li>Two kinds of transformations </li></ul><ul><ul><li>Global transformations </li></ul></ul><ul><ul><li>Local transformations: triggered by annotations </li></ul></ul>
  20. 20. AST Transformations in Groovy 1.6 Implement Patterns through Transformations <ul><li>Several transformations finds their way </li></ul><ul><ul><li>@Singleton — okay, not really a pattern ;-) </li></ul></ul><ul><ul><li>@Immutable , @Lazy , @Delegate </li></ul></ul><ul><ul><li>@Newify </li></ul></ul><ul><ul><li>@Category and @Mixin </li></ul></ul><ul><ul><li>@PackageScope </li></ul></ul><ul><ul><li>Swing’s @Bindable and @Vetoable </li></ul></ul><ul><ul><li>Grape’s @Grab </li></ul></ul><ul><li>Let’s have a look at some of them! </li></ul>
  21. 21. @Singleton (Anti-)Pattern Revisited <ul><li>The evil Java singleton </li></ul><ul><ul><li>public class Evil { public static final Evil instance = new Evil (); private Evil () {} Evil getInstance() { return instance; } } </li></ul></ul><ul><li>In Groovy: </li></ul><ul><ul><li>@Singleton class Evil {} </li></ul></ul><ul><li>There’s also a « lazy » version </li></ul><ul><ul><li>@Singleton(lazy = true) class Evil {} </li></ul></ul>
  22. 22. @Immutable The Immutable… Boiler-Plate Code <ul><li>To properly implement immutable classes </li></ul><ul><ul><li>No mutators (state musn’t change) </li></ul></ul><ul><ul><li>Private final fields </li></ul></ul><ul><ul><li>Defensive copying of mutable components </li></ul></ul><ul><ul><li>Proper equals() / hashCode() / toString() for comparisons or for keys in maps, etc. </li></ul></ul><ul><li>In Groovy </li></ul><ul><ul><li>@Immutable final class Coordinates { Double lat, lng } def c1 = new Coordinates(lat: 48.8, lng: 2.5) def c2 = new Coordinates(48.8, 2.5) assert c1 == c2 </li></ul></ul>
  23. 23. @Lazy Not Just for Lazy Dudes! <ul><li>When you need to lazy evaluate / instantiate complex data structures for class fields, mark them as @Lazy </li></ul><ul><ul><li>class Dude { @Lazy pets = retrieveFromSlowDB() } </li></ul></ul><ul><li>Groovy will handle the boiler-plate code for you </li></ul>
  24. 24. @Delegate Not Just for Managers! <ul><li>You can delegate to fields of your class </li></ul><ul><ul><li>Think multiple inheritance </li></ul></ul><ul><ul><li>class Employee { def doTheWork() { &quot;done&quot; } } class Manager { @Delegate Employee slave = new Employee() } def god = new Manager() assert god.doTheWork() == &quot;done&quot; </li></ul></ul><ul><li>Damn manager who will get all the praise… </li></ul>
  25. 25. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  26. 26. Grab a Grape Groovy Advanced Packaging Engine <ul><li>Helps you distribute scripts without dependencies </li></ul><ul><li>Just declare your dependencies with @Grab </li></ul><ul><ul><li>Will look for dependencies in Maven or Ivy repositories </li></ul></ul><ul><li>@Grab(group = 'org.mortbay.jetty', module = 'jetty-embedded', version = '6.1.0') def startServer() { def srv = new Server(8080) def ctx = new Context(srv , &quot;/&quot;, SESSIONS); ctx.resourceBase = &quot;.&quot; ctx.addServlet(GroovyServlet, &quot;*.groovy&quot;) srv.start() } </li></ul>
  27. 27. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  28. 28. @Bindable (1/2) Event-Driven Made Easy <ul><li>Speaking of boiler-plate code… property change listeners </li></ul><ul><li>import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeListener; public class MyBean { private String prop; PropertyChangeSupport pcs = new PropertyChangeSupport(this); public void addPropertyChangeListener(PropertyChangeListener l) { pcs.add(l); } public void removePropertyChangeListener(PropertyChangeListener l) { pcs.remove(l); } </li></ul><ul><li>public String getProp() { </li></ul><ul><li>return prop; } </li></ul><ul><li>public void setProp(String prop) { pcs.firePropertyChanged(&quot;prop&quot;, this.prop, this.prop = prop); } } </li></ul>
  29. 29. @Bindable (2/2) Event-Driven Made Easy <ul><li>Groovy’s solution </li></ul><ul><ul><li>class MyBean { @Bindable String prop } </li></ul></ul><ul><li>Interesting in Griffon and Swing builder </li></ul><ul><ul><li>textField text: bind { myBean.prop } </li></ul></ul><ul><li>Also of interest: @Vetoable </li></ul>
  30. 30. Griffon The Swing MVC Framework <ul><li>Leverages Groovy’s SwingBuilder and Grails’ infrastructure </li></ul><ul><ul><li>http://griffon.codehaus.org </li></ul></ul><ul><li>Don’t miss the “Griffon in Depth” BOF-5189! </li></ul><ul><ul><li>Wednesday 8:45pm, Gateway 104 </li></ul></ul>
  31. 31. Swing Console Improvements <ul><li>The console can be run as an applet </li></ul><ul><li>Code indentation support </li></ul><ul><li>Script drag’n drop </li></ul><ul><li>Add JARs in the classpath from the GUI </li></ul><ul><li>Execution results visualization plugin </li></ul><ul><li>Clickable stacktraces and error messages </li></ul><ul><li>Not intended to be a full-blown IDE, but handy </li></ul>
  32. 32.
  33. 33. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  34. 34. ExpandoMetaClass DSL Less Repetition <ul><li>EMC is a way to change the behavior of types at runtime </li></ul><ul><li>Before </li></ul><ul><ul><li>Number.metaClass.multiply = { Amount amount -> amount.times(delegate) } Number.metaClass.div = { Amount amount -> amount.inverse().times(delegate) } </li></ul></ul><ul><li>Now in Groovy 1.6 </li></ul><ul><ul><li>Number.metaClass { multiply { Amount amount -> amount.times(delegate) } div { Amount amount -> amount.inverse().times(delegate) } } </li></ul></ul>
  35. 35. Runtime Mixins Inject New Behavior to Types at Runtime <ul><li>class FlyingAbility { def fly() { &quot;I'm ${name} and I fly!&quot; } } class JamesBondVehicle { String getName() { &quot;James Bond's vehicle&quot; } } JamesBondVehicle.mixin FlyingAbility assert new JamesBondVehicle().fly() == &quot;I'm James Bond's vehicle and I fly!&quot; </li></ul>
  36. 36. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  37. 37. javax.script.* Scripting APIs Groovy Scripting Engine Built-In <ul><li>In Groovy 1.6, the JSR-223 / javax.script. * scripting engine for Groovy is bundled </li></ul><ul><ul><li>import javax.script.* def manager = new ScriptEngineManager() def engine = manager.getEngineByName(&quot;groovy&quot;) assert engine.evaluate(&quot;2 + 3&quot;) == 5 </li></ul></ul><ul><li>To evaluate Groovy scripts at runtime in your application, just drop the Groovy JAR in your classpath! </li></ul>
  38. 38. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  39. 39. JMX Builder (1/2) Domain-Specific Language for JMX <ul><li>Simplify JMX handling with a Builder pattern approach </li></ul><ul><li>Declaratively expose Java/Groovy objects as MBeans </li></ul><ul><li>JMX's event model support </li></ul><ul><ul><li>Inline closures to create event handler & broadcaster </li></ul></ul><ul><ul><li>Closures for receiving event notifications </li></ul></ul><ul><li>Provides a flexible registration policy for MBean </li></ul><ul><li>Exposes attribute, constructors, operations, parameters, and notifications </li></ul><ul><li>Simplified creation of connector servers & clients </li></ul><ul><li>Support for exporting JMX timers </li></ul><ul><li>http: //groovy . codehaus . org/Groovy + JmxBuilder </li></ul>
  40. 40. JMX Builder (2/2) Examples <ul><li>Create a connector server </li></ul><ul><ul><li>def jmx = new JmxBuilder() jmx.connectorServer(port:9000).start() </li></ul></ul><ul><li>Create a connector client </li></ul><ul><ul><li>jmx.connectorClient(port:9000).connect() </li></ul></ul><ul><li>Ex port a bean </li></ul><ul><ul><li>jmx.export { bean new MyService() } </li></ul></ul><ul><li>Defining a timer </li></ul><ul><ul><li>jmx.timer(name: &quot;jmx.builder:type=Timer&quot;, event: &quot;heartbeat&quot;, period: &quot;1s&quot;).start() </li></ul></ul><ul><li>JMX listener </li></ul><ul><ul><li>jmx.listener(event: &quot;…&quot;, from: &quot;foo&quot;, call: { event -> …}) </li></ul></ul>
  41. 41. Agenda <ul><li>Groovy Overview </li></ul><ul><li>Performance Improvements </li></ul><ul><li>Syntax Enhancements </li></ul><ul><li>Compile-Time Metaprogramming </li></ul><ul><li>The Grape Module System </li></ul><ul><li>Swing-Related Improvements </li></ul><ul><li>Runtime Metaprogramming Additions </li></ul><ul><li>JSR-223 Scripting Engine Built-In </li></ul><ul><li>JMX Builder </li></ul><ul><li>OSGi Readiness </li></ul>
  42. 42. OSGi Readiness <ul><li>The Groovy JAR contains OSGi metadata </li></ul><ul><ul><li>Can be reused in OSGi containers out-of-the-box </li></ul></ul><ul><li>Tutorials on Groovy and OSGi </li></ul><ul><ul><li>http: //groovy . codehaus . org/OSGi + and + Groovy </li></ul></ul><ul><ul><li>Will show you how to load Groovy as a service, write, publish and consume Groovy services, and more </li></ul></ul>
  43. 43. Summary
  44. 44. Summary Just Remember that Groovy Rocks! :-) <ul><li>Groovy 1.6 provides </li></ul><ul><ul><li>Important performance gains </li></ul></ul><ul><ul><li>Efficient compile-time metaprogramming hooks </li></ul></ul><ul><ul><li>New useful features (JMX, javax.script.*, etc.) </li></ul></ul><ul><ul><li>A script dependencies system </li></ul></ul><ul><ul><li>Various Swing-related improvements </li></ul></ul><ul><ul><li>Several runtime metaprogramming additions </li></ul></ul><ul><li>Get it now! </li></ul><ul><ul><li>http://groovy.codehaus.org/Download </li></ul></ul>
  45. 45. Guillaume Laforge [email_address]
  1. A particular slide catching your eye?

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

×