6. 6
2003
1.0
2007
designed by
James Strachan
project manager
Guillaume LaForge
glaforge.appspot.com
2.0
2012
https://github.com/groovy/groovy-core
Apache License, Version 2.0
3.0
?
JSR-241
Groovy – A New Standard Programming
Language for the Java Platform
2004
2.3.5
2.4.0-beta
Groovy History
J2SE 5.0 Java SE 6 Java SE 7
1.8
20112006
JAX 2007
Innovation Awards
2008 2009
1995
Spring, VMware
10. 10
Java
Groovy
Groovy Second language to learn after Java.
Gradle
A better way to build your
Java (EE) projects.
Geb
The best way to test your
web applications automatically.
Language
Development Tools
Framework
Grails
Rapid web development framework
based on Groovy and Java.
42. Groovy DSL
• DSL: Domain-Specific Language
• Could be implemented with Groovy Builders
42
sendmail {
from me
to someone
message “leave a message”
} (pseudo code)
68. s3upload.groovy
68
1. def credentials = new BasicAWSCredentials(
2. accessKey,
3. secretKey
4. )
5.
6. // Get S3 client
7. def s3client = new AmazonS3Client(credentials)
8.
69. 69
9. // Create a S3 Bucket
10. s3client.createBucket('s3.myhost')
11.
12. // Upload a file to S3
13. def localFile = new File('path-to-local-file')
!
15. s3client.putObject(
16. 's3.myhost',
17. 'key-for-remote-file',
18. localFile
19. )
20.
70. WAR Deployment on AWS
70
Local WAR file
MyApp-1.0.war
Amazon
S3 Bucket
Amazon
Amazon Elastic BeansTalk
!
Application
upload Environmentdeploy
Create or update
an environment
82. 82
grails create-domain-class User
1. class User {
2. String firstName
3. String lastName
4. Integer age
5.
6. static constraints = {
7. age range: 0..99
8. }
9. }
10.
83. 83
1. @TestFor(User)
2. class UserSpec extends Specification {
3. void "The new user must have first and last names"() {
4. when:
5. def user = new User()
6. then:
7. !user.validate()
8. when:
9. user = new User(firstName: 'John', lastName: 'Smith')
10. then:
11. user.validate()
12. }
13. } grails test-app