Java Reference
In-Depth Information
2
.
Groovy uses Java libraries.
Practically every Groovy class relies on the Java lib-
raries, with or without Groovy additions. That means virtually every Groovy class is
already an integration story, mixing Groovy and Java together. One nice use case for
Groovy is to experiment with Java libraries you haven't used before.
3
.
Groovy makes working with XML and JSON easy.
Here's an area where Groovy
shines. Groovy includes classes called
MarkupBuilder
, which makes it easy to
generate XML, and
JsonBuilder
, which produces JSON objects. It also has
classes called
XmlParser
and
XmlSlurper
, which convert XML data structures
into DOM structures in memory, and
JsonSlurper
, to parse JSON data. These will
be used throughout the topic, especially in
chapter 9
on RESTful web services.
4
.
Groovy includes simplified data source manipulation.
The
groovy.sql.Sql
class provides a very simple way to work with relational databases. I'll talk about
chapter 9
on RESTful web services.
5
.
Groovy's metaprogramming streamlines development.
The builder classes are an
example of Groovy metaprogramming. I'll show examples of DSLs in several
chapters.
6
.
Groovy tests work for Java code.
The Spock testing tool, demonstrated in this
chapter and extensively discussed in
chapter 6
on testing, is a great way to test Java
systems.
7
.
Groovy build tools work on Java (and mixed) projects.
In
chapter 5
on enhancing
build processes, I'll talk about
AntBuilder
, how to add Groovy to Maven builds,
and Gradle.
8
.
Groovy projects like Grails and Griffon make developing web and desktop ap-
plications easier.
The Grails project is a complete-stack, end-to-end framework for
building web applications, based on Spring and Hibernate. Griffon brings the same
convention-over-configuration ideas to desktop development. Grails is discussed in
chapter 8
on databases and
chapter 10
on web applications.
When looking at the sorts of problems Java developers typically encounter, this list will be
a source of ideas for making implementations simpler, easier to read and understand, and
faster to implement.