Java Reference
In-Depth Information
Finally, the developers of the Grails project also created a class called BeanBuilder ,
which is used to script Spring beans in Groovy. That brings Groovy capabilities to Spring
bean files much the way Gradle enhances XML build files.
1.3.2. Simplified database access
Virtually all Java developers work with databases. Groovy has a special set of classes to
make database integration easy, and I'll review them in chapter 8 on databases. I also show
an example of working with a MongoDB database through a Groovy library that wraps the
corresponding Java API.
I'll also borrow from the Grails world and discuss GORM, the Grails Object-Relational
Mapping tool, a DSL for configuring Hibernate. In fact, GORM has been refactored to
work with a variety of persistence mechanisms, including NoSQL databases like Mon-
goDB, Neo4J, Redis, and more.
1.3.3. Building and accessing web services
Another area of active development today is in web services. Java developers work with
both SOAP-based and RESTful services, the former involving auto-generated proxies and
the latter using HTTP as much as possible. REST is covered in chapter 9 , and SOAP-based
web services are discussed in appendix C, available as a free download. In both cases, if a
little care is applied, the existing Java tools work just fine with Groovy implementations.
1.3.4. Web application enhancements
Groovy includes a “groovlet” class, which acts like a Groovy-based servlet. It receives
HTTP requests and returns HTTP responses, and it includes pre-built objects for requests,
responses, sessions, and more. One of the most successful instances of Groovy and Java
integration, and arguably the killer app for Groovy, is the Grails framework, which brings
extraordinary productivity to web applications. Both are covered in chapter 10 on web de-
velopment.
In each of these use cases, Groovy can work with existing Java tools, libraries, and infra-
structure. In some situations, Groovy will simplify the required code. In other cases, the
Search WWH ::




Custom Search