4. About me
Paul Bakker
EJB 3
• Trainer Info Support
JSF
• Java Magazine author Seam
• Big time Groovy fan ;-) JavaFX
Spring
Hibernate
Flex
5. Outline
• Freshing up your Groovy knowledge
• Real life Groovy examples
–Test Data
–Database conversion
–Unit Testing
• A leap of faith
–A Groovy web service client
–Generating XML
–A Groovy session bean
6. So what was Groovy again?
• A dynamic language
• Compiles to byte code
• Running in the JVM
• Completely compatible with Java
15. The problem:
Database conversion
Old legacy schema
Redesigned schema for new application
• Reuse most of the data
• Don’t loose references
• But don’t limit new mappings
16. The schema
MESSAGE ATTACHMENT
1
MESSAGE message_id message_id
*
subject file_id
message_id
body
subject
* *
user_id
body
1
firstname
lastname
FILE
username
USER
attachment
file_id
user_id
1 filename
username data
firstname
lastname
email
23. Making untestable code testable
• Replace Java code at joint points
–Replace direct service calls with a Groovy proxy
Groovy Java Service
Java Class
Proxy delegate
31. A warning about domain classes
Don’t forget about the metaClass property
Serialize
Groovy ActionScript
domain class class
Must have
metaClass
property!
32. GANT
• ANT without XML
• More natural build definition
• Use control structures
• Works in every build environment
33. Just get the Groove
• Groovy makes a lot of tasks easier
• Fits in most environments
• Use Groovy where it really adds value
34. Should we ever write Java code?
• More readable code
• Better unit testing
• Advanced frameworks
• Not everybody knows Groovy
• No static code analysis