3. Context February 2010 : wrote a small Groovy/Grails app to learn the technologies March 1st, 2010 : started on CDGA project (Struts, Spring, JPA) March 1st, 2010 (later that day) : realized that CDGA had an enormous amount of boilerplate code that Grails could eliminate
4. (Additional) Context May 7th, 2010 : wrote CITYTECH blog post about code savings from replacing Spring DAO code with Grails May 8th, 2010 – present : blog is read by a total of 4 CITYTECH employees July 7th, 2010 : Grails begins to learn at a geometric rate. It becomes self-aware at 2:14 AM, Eastern time.
5. Grails Primer Web application framework built with Groovy (Java-based dynamic language) on top of proven Java technologies Spring MVC, Hibernate Full stack for rapid development Embedded Tomcat container, HSQLDB, (G)Ant, scaffolding features Get a basic app running within minutes
6. You may notice… Convention over configuration Little-to-no initial configuration Project structure is predefined according to best practices Command line scripts for common tasks Create new application, compile, test, run Generate domain classes, controllers, services, test cases Install plugins Contrast with your last Maven-built project
8. Simple Domain Delegate 1 ∞ User Delegate 1 ∞ Application A “delegate agency” has one-to-many users and one-to-many applications. An application contains various forms, input by users, to collect data about the delegate agency.
9. JPA (Java Persistence API) @Entity @Table(name = "USER") public class User implements Serializable { @Id private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "DELEGATE", referencedColumnName = "ID") private Delegate delegate; // getters and setters, equals(), hashCode(), toString()… }
17. Additional GORM Features ORM DSL for mapping to legacy DB schemas Custom mappings for non-standard table and column names Event handlers (beforeInsert, afterUpdate) Customizable caching and fetching strategies, transactions
18. Web Render XML or JSON responses using markup builders Automatic marshalling of domain classes to XML/JSON
19. (More) Web GSP Similar to JSP, but with better tag libraries findAll, grep (filter) for collections Method calls Templates Sitemesh (decorator) layouts Customizable URL mappings
21. More Features Spring Web Flow Supports subflows, conversation scope (similar to Seam) Interceptors / Filters AJAX DOJO, GWT plugins
22. Even more to like Groovy tests Ideal for TDD Unit tests created automatically from command line script Dynamic language features for easy mocking Easy RESTful web services URL mappings Controllers can render XML or JSON Consider attending a CGUG meeting Extremely active community 400+ plugins (Spring Security, JQuery, GWT, Google App Engine, Flex) Wide range of tutorials Frequent releases
23. Summary Grails compared to Spring, EJB, JPA Substantially less code without compromises Easier to maintain and test Shorter iterations and release cycles Same proven underlying technologies Gain competitive edge Why not?