Making Spring
Groovy
Contact Info
Ken Kousen
ken.kousen@kousenit.com
@kenkousen
Making Java Groovy
http://manning.com/kousen
The Spring Framework
Dependency injection
Huge library of “beans”
Open source
The Swiss Army Chainsaw of
Frameworks
Hello, Spring!
Not much point
Replaces simple Java with complex Java
and configuration metadata
Need an app with some serv...
Managing Accounts
Managing Accounts
Spring manages:
Account service
Account repository
Transactions
Injected dependencies
Managing Accounts
Spring provides:
jdbcTemplate
Embedded database for testing
Testing
Spring test context
Caches application context
Rolls back transactions after each test
Great for testing DAO layer...
Spring and Groovy
1. POGOs are Spring beans too
bytecodes are bytecodes
Account Demo
Classes:
Account.groovy → POGO
AccountDAO.java → integration
JdbcAccountDAO.groovy
AccountService.java
Spock ...
Spring and Groovy
2. Refreshable beans
Use lang: namespace
Deploy Groovy source code
Can update running system
Mortgage Evaluator
Mortgage Evaluator Demo
Classes:
MortgageApplication.groovy
Evaluator.java
JavaEvaluator.java
GroovyEvaluator.groovy → ref...
Spring and Groovy
3. AOP
Implement aspects in Groovy
Tracking Properties
Tracking Properties
Files:
POJO.java
ChangeLogger.java
UpdateReporter.groovy
applicationContext.xml
JUnit tests
Spring and Groovy
4. Inline scripted beans
Bean definitions in config files
A feature looking for an application
Inline scripted beans
Files:
Same as AOP, but
bean def in applicationContext.xml
Spring and Groovy
5. BeanBuilder class from Grails
(projected to be in Spring 4.0)
Builder syntax for bean config
BeanBuilder
Files:
BeanBuilderTests.groovy
(from Grails distribution)
Spring Boot
6. Spring Boot
Sample application (Java) at
http://spring.io/guides/gs/spring-boot/
I added a Groovy demo as w...
Conclusions
POGOs are Groovy beans
Unique to dynamic languages in Spring:
Refreshable beans
Inline scripted beans
BeanBuil...
Making Spring Groovy
Upcoming SlideShare
Loading in …5
×

Making Spring Groovy

831 views

Published on

Speaker: Kenneth Kousen
The Spring framework has always had a friendly relationship with dynamic languages. In this presentation, we'll look at all the ways you can add Groovy to Spring to make development easier, ranging from simplifying your configuration files to deploying refreshable beans to using Spock tests in the Spring test context and more.
Groovy works comfortably with existing Java infrastructure, and Spring has special capabilities designed specifically for scripting languages. The combination is very powerful and is an easy way to take advantage of Groovy code simplification.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
831
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Making Spring Groovy

  1. 1. Making Spring Groovy
  2. 2. Contact Info Ken Kousen ken.kousen@kousenit.com @kenkousen Making Java Groovy http://manning.com/kousen
  3. 3. The Spring Framework Dependency injection Huge library of “beans” Open source The Swiss Army Chainsaw of Frameworks
  4. 4. Hello, Spring! Not much point Replaces simple Java with complex Java and configuration metadata Need an app with some services...
  5. 5. Managing Accounts
  6. 6. Managing Accounts Spring manages: Account service Account repository Transactions Injected dependencies
  7. 7. Managing Accounts Spring provides: jdbcTemplate Embedded database for testing
  8. 8. Testing Spring test context Caches application context Rolls back transactions after each test Great for testing DAO layers
  9. 9. Spring and Groovy 1. POGOs are Spring beans too bytecodes are bytecodes
  10. 10. Account Demo Classes: Account.groovy → POGO AccountDAO.java → integration JdbcAccountDAO.groovy AccountService.java Spock tests
  11. 11. Spring and Groovy 2. Refreshable beans Use lang: namespace Deploy Groovy source code Can update running system
  12. 12. Mortgage Evaluator
  13. 13. Mortgage Evaluator Demo Classes: MortgageApplication.groovy Evaluator.java JavaEvaluator.java GroovyEvaluator.groovy → refreshable Spock tests
  14. 14. Spring and Groovy 3. AOP Implement aspects in Groovy
  15. 15. Tracking Properties
  16. 16. Tracking Properties Files: POJO.java ChangeLogger.java UpdateReporter.groovy applicationContext.xml JUnit tests
  17. 17. Spring and Groovy 4. Inline scripted beans Bean definitions in config files A feature looking for an application
  18. 18. Inline scripted beans Files: Same as AOP, but bean def in applicationContext.xml
  19. 19. Spring and Groovy 5. BeanBuilder class from Grails (projected to be in Spring 4.0) Builder syntax for bean config
  20. 20. BeanBuilder Files: BeanBuilderTests.groovy (from Grails distribution)
  21. 21. Spring Boot 6. Spring Boot Sample application (Java) at http://spring.io/guides/gs/spring-boot/ I added a Groovy demo as well
  22. 22. Conclusions POGOs are Groovy beans Unique to dynamic languages in Spring: Refreshable beans Inline scripted beans BeanBuilder configuration class Spring boot looks cool

×