Java Reference
In-Depth Information
Figure 7.1. Guide to the Spring technologies with Groovy. Spring manages POGOs as easily as POJOs, so
the examples include Groovy implementations of both normal beans and aspects. Closure coercion is used to
implement the RowMapper interface in a JdbcTemplate . Refreshable beans are Groovy source files that can
be modified at runtime. Inline scripted beans are included inside XML configuration files. Grails provides a
BeanBuilder class for configuring beans. Finally, Spock has a library that allows it to be used with Spring's test
context feature.
To show how Groovy helps Spring, I need to review what Spring is all about and how it's
used and configured. I'll start with a simple, but non-trivial, sample application. Rather
than show all the pieces (which are in the source code repository for the topic), I'll high-
light the overall architecture and the Groovy parts.
7.1. A Spring application
For all its benefits, Spring is a hard framework to demonstrate to developers unfamiliar
with it. The “Hello, World” application in Spring makes you question why you'd ever want
it, because it replaces a couple of lines of simple, easy-to-understand, strongly typed Java
with several additional lines of code, plus about 20 lines of XML. That's not exactly a
ringing endorsement.
 
Search WWH ::




Custom Search