PacktLib: Groovy for Domain-Specific Languages

Groovy for Domain-Specific Languages

Credits

About the Author

About the Reviewers

Preface

Introduction to DSL and Groovy

DSL: New name for an old idea

Groovy

Summary

Groovy Quick Start

How to find and install Groovy

Running Groovy

Groovy IDE and editor integration

Introducing the Groovy Language

Summary

Groovy Closures

What is a closure

Closures and collection methods

Closures as method parameters

Calling closures

Finding a named closure field

Closure parameters

Closure return values

Closure scope

Summary

Example DSL: GeeTwitter

Twitter

Working with the Twitter APIs

Groovy improvements

Removing boilerplate

Adding a command-line interface

Adding built-in methods

Summary

Power Groovy DSL features

Named parameters

Builders

SwingBuilder

Method pointers

Metaprogramming and the Groovy MOP

How Builders work

ExpandoMetaClasses

Summary

Existing Groovy DSLs

The Grails Object Relational Mapping (GORM)

Gant

ATDD, BDD with GSpec, EasyB, and Spock

Summary

Building a Builder

Builder code structure

BuilderSupport

FactoryBuilderSupport

Summary

Implementing a Rules DSL

Groovy bindings

Building a Rewards DSL

Summary

Integrating it all

Mixing and matching Groovy and Java

GroovyClassLoader

Summary

Index