Summary
In this chapter, you were introduced to Groovy, a popular dynamic language on the JVM. We downloaded and installed it and explored its two REPL shells, GroovyConsole (desktop GUI application) and GroovyShell (text-based shell). We discovered that while Java and Groovy syntax are (for the most part) compatible, Groovy code can be much more compact, as many elements that are required in Java are optional in Groovy. We tried various annotations that generate code automatically on the fly, including annotations that generate valid implementations for the toString()
, equals()
and hashCode()
methods, but also generate complete constructors. We briefly explored the Groovy Development Kit (GDK) and looked at the differences between dynamic programming and static programming and discovered that Groovy supports both methods.
In the next chapter, we will create a simple web service that generates XML and consumes data from a database by using the Java Database Connectivity (JDBC) interface....