The document is a presentation about Groovy and Grails. It discusses the history and goals of Groovy, a dynamic language for the JVM. It covers Groovy syntax and features like closures, builders for XML, Swing and Ant. The presentation also discusses how Groovy enables the creation of internal Domain Specific Languages through its meta-object protocol and dynamic nature.
Apache Groovy: the language and the ecosystemKostas Saidis
Ā
An overview of the Groovy language and its awesome ecosystem, advocating Groovy as the language of choice for (a) Java developers that want to dive into dynamic languages or (b) for Javascript, Ruby or Python developers that want to dive into the Java platform.
The presentation was given at the 9th FOSSCOMM (16-17 April 2016) organized by the Software Libre Sociecy of the University of Piraues.
Custom deployments with sbt-native-packagerGaryCoady
Ā
sbt-native-packager offers a comprehensive approach to packaging artifacts with SBT. The user describes a generic layout, which can then be extended for different types of software and deployments. For example, it is flexible enough to describe both a Zip-based archive format, and an RPM package with appropriate Systemd configuration for a service.
This talk will cover the essentials needed to understand the design of sbt-native-packager, and how to extend its structure to create custom layouts and deployments.
Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax. It integrates smoothly with any Java program, and immediately delivers to your application powerful features, including scripting capabilities, Domain-Specific Language authoring, runtime and compile-time meta-programming and functional programming.
In this presentation, we'll see how Groovy simplifies the life of Java Developers. Basically, this talk would be for beginners where I would introduce powerful Groovy concepts like - Groovy Collections, Closure, Traits etc.
Apache Groovy: the language and the ecosystemKostas Saidis
Ā
An overview of the Groovy language and its awesome ecosystem, advocating Groovy as the language of choice for (a) Java developers that want to dive into dynamic languages or (b) for Javascript, Ruby or Python developers that want to dive into the Java platform.
The presentation was given at the 9th FOSSCOMM (16-17 April 2016) organized by the Software Libre Sociecy of the University of Piraues.
Custom deployments with sbt-native-packagerGaryCoady
Ā
sbt-native-packager offers a comprehensive approach to packaging artifacts with SBT. The user describes a generic layout, which can then be extended for different types of software and deployments. For example, it is flexible enough to describe both a Zip-based archive format, and an RPM package with appropriate Systemd configuration for a service.
This talk will cover the essentials needed to understand the design of sbt-native-packager, and how to extend its structure to create custom layouts and deployments.
Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax. It integrates smoothly with any Java program, and immediately delivers to your application powerful features, including scripting capabilities, Domain-Specific Language authoring, runtime and compile-time meta-programming and functional programming.
In this presentation, we'll see how Groovy simplifies the life of Java Developers. Basically, this talk would be for beginners where I would introduce powerful Groovy concepts like - Groovy Collections, Closure, Traits etc.
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design
Patterns are formalized best practices that the programmer must implement in the application.
Introducing containers into your infrastructure brings new capabilities, but also new challenges, in particular around configuration. This talk will take a look under the hood at some of those operational challenges including:
* The difference between runtime and build-time configuration, and the importance of relating the two together.
* Configuration drift, immutable mental models and mutable container file systems.
* Who configures the orchestrators?
* Emergent vs. model driven configuration.
In the process we will identify some common problems and talk about potential solutions.
Talk from PuppetConf 2016
How do we go from your Java code to the CPU assembly that actually runs it? Using high level constructs has made us forget what happens behind the scenes, which is however key to write efficient code.
Starting from a few lines of Java, we explore the different layers that constribute to running your code: JRE, byte code, structure of the OpenJDK virtual machine, HotSpot, intrinsic methds, benchmarking.
An introductory presentation to these low-level concerns, based on the practical use case of optimizing 6 lines of code, so that hopefully you to want to explore further!
Presentation given at the Toulouse (FR) Java User Group.
Video (in french) at https://www.youtube.com/watch?v=rB0ElXf05nU
Slideshow with animations at https://docs.google.com/presentation/d/1eIcROfLpdTU2_Z_IKiMG-AwqZGZgbN1Bs2E0nGShpbk/pub?start=true&loop=false&delayms=60000
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
Ā
While Singletons have become a Pattern-Non-Grata over the years, you still find it surprisingly often in PHP applications and frameworks. This talk will explain what the Singleton pattern is, how it works in PHP and why you should avoid it in your application.
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design
Patterns are formalized best practices that the programmer must implement in the application.
Introducing containers into your infrastructure brings new capabilities, but also new challenges, in particular around configuration. This talk will take a look under the hood at some of those operational challenges including:
* The difference between runtime and build-time configuration, and the importance of relating the two together.
* Configuration drift, immutable mental models and mutable container file systems.
* Who configures the orchestrators?
* Emergent vs. model driven configuration.
In the process we will identify some common problems and talk about potential solutions.
Talk from PuppetConf 2016
How do we go from your Java code to the CPU assembly that actually runs it? Using high level constructs has made us forget what happens behind the scenes, which is however key to write efficient code.
Starting from a few lines of Java, we explore the different layers that constribute to running your code: JRE, byte code, structure of the OpenJDK virtual machine, HotSpot, intrinsic methds, benchmarking.
An introductory presentation to these low-level concerns, based on the practical use case of optimizing 6 lines of code, so that hopefully you to want to explore further!
Presentation given at the Toulouse (FR) Java User Group.
Video (in french) at https://www.youtube.com/watch?v=rB0ElXf05nU
Slideshow with animations at https://docs.google.com/presentation/d/1eIcROfLpdTU2_Z_IKiMG-AwqZGZgbN1Bs2E0nGShpbk/pub?start=true&loop=false&delayms=60000
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
Ā
While Singletons have become a Pattern-Non-Grata over the years, you still find it surprisingly often in PHP applications and frameworks. This talk will explain what the Singleton pattern is, how it works in PHP and why you should avoid it in your application.
Discusses using the Groovy dynamic language for primarily functional and acceptance testing with a forward looking perspective. Also considers polyglot options. The techniques and lessons learned can be applied to other kinds of testing and are also applicable to similar languages. Drivers and Runners discussed include: Native Groovy, HttpBuilder, HtmlUnitWebTest, Watij, Selenium, WebDriverTellurium, JWebUnit, JUnit, TestNG, Spock, EasyB, JBehave, Cucumber, Robot Framework and Slim
Slides for JJUG(Japan Java User Group) 2009 Fall BOF.
Talking about groovy history, new features in Groovy 1.6,1.7.
Especially focused on AST Transformations.
Groovy & Grails: Scripting for Modern Web Applicationsrohitnayak
Ā
Dynamic scripting languages are a powerful addition to a software designerās toolbox. Rails/Ruby and Python have not gained much acceptance in the enterprise. Grails and Groovy are an attempt to bridge the gap between the modern scripting world and the Enterprise Java world.
This talk is an introduction towards building web applications in Grails. First we will go about creating a REST based webservice. We will also show how to replace the default database backend of Grails with MySQL.
We will then build a web application that consumes this webservice. The emphasis will be on the design patterns and idioms in Grails that address the web application development lifecycle.
Groovy - Grails as a modern scripting language for Web applicationsIndicThreads
Ā
Dynamic scripting languages are a powerful addition to a software designerās toolbox. Rails/Ruby and Python have not gained much acceptance in the enterprise. Grails and Groovy are an attempt to bridge the gap between the modern scripting world and the Enterprise Java world.
This talk is an introduction towards building web applications in Grails. First we will go about creating a REST based webservice. We will also show how to replace the default database backend of Grails with MySQL.
We will then build a web application that consumes this webservice. The emphasis will be on the design patterns and idioms in Grails that address the web application development lifecycle.
"Groovy 2.0 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
Groovy Domain Specific Languages - SpringOne2GX 2012Guillaume Laforge
Ā
Paul King, Andrew Eisenberg and Guillaume Laforge present about implementation of Domain-Specific Languages in Groovy, while at the SpringOne2GX 2012 conference in Washington DC.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
Ā
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Ā
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Ā
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
Ā
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
DevOps and Testing slides at DASA ConnectKari Kakkonen
Ā
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
Ā
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Ā
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overviewā
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
Ā
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more āmechanicalā approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Ā
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
2. Groovy & Grails in Action!
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development
www.devoxx.com
3. Overall Presentation Goal
Discover the Groovy dynamic language for the JVM
Understand how you can create DSLs in Groovy
Getting productive with the Grails agile web stack
www.devoxx.com
4. Guillaume Laforge
Groovy Project Manager
JSR-241 Spec Lead
Head of Groovy Development
at SpringSource
Initiator of the Grails framework
Co-author of Groovy in Action
Speaker at numerous conferences
JavaOne, QCon, JavaZone, Sun TechDays, JavaPolis,
The Spring Experience, JAX, Dynamic Language World...
4 www.devoxx.com
5. G2One / SpringSource
Back in 2007, Graeme Rocher and Guillaume Laforge
created G2One, the Groovy/Grails company
Professional services
consulting, expertise, training, support
Last november, SpringSource acquired G2One
5 www.devoxx.com
6. Groovy in Action
A bit of history and background
Groovy syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy Ecosystem
www.devoxx.com
7. James Strachan to Bob McWhirter in 2003:
Wouldnāt it be āgroovyā if we could have
native syntax for lists, maps and regexs
in Java like in most scripting languages?
Wouldnāt it be āgroovyā if we
could have duck typing in Java?
Wouldnāt it be āgroovyā if we had
closures and properties in Java?
www.devoxx.com
8. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
9. Groovy is...
Groovy is a dynamic language for the JVM
Groovy directly compiles down to bytecode
Inspired by other languages: Python, Ruby, Smalltalk
Whose goal is to simplify the life of developers
Apache 2 licensed Open Source project
hosted at Codehaus
Grammar directly deriving from the Java 5 language
support for annotations, generics, enums, static imports
9 www.devoxx.com
10. Groovy is everywhere
Integrated in Open Source projects
Spring, JBoss SEAM, ServiceMix, Mule, Oracle OC4J
Integrated in mission-critical applications
Mutual of Omaha, US Fortune 500 insurance company
US National Cancer Institute
Integrated in commercial products
IBM WebSphere Smash, SAP Composition on Grails
Oracle Data Integrator, Oracle Fusion (ADF)
10 www.devoxx.com
12. Features at a glance
Totally object-oriented
Optional typing
No need to wait for Java 7 / 8 / 9:
Closures: reusable / assignable code blocks
Properties: auto-generated getters / setters
Multimethods: call the right method for the right type
BigDecimal arithmetics
Useful wrapper APIs: SQL, XML, Swing, templates, JMX...
12 www.devoxx.com
13. Java integration
Groovy generates Java bytecode for the JVM
Same strings, same regex
Same APIs ā JDK, collections, 3rd party, etc.
Same security model, same threading model
Same OO concepts JInterface GInterface
Joint-compilation <<implements>> <<implements>>
GClass JClass
JClass GClass
13 www.devoxx.com
14. Letās get started
Go to http://groovy.codehaus.org/Download
Download the latest version
Groovy 1.5.7 ā maintenance branch
Groovy 1.6-beta-2 ā soon to be released
Unzip the archive, set GROOVY_HOME
Add $GROOVY_HOME/bin to your path
Youāre ready!
14 www.devoxx.com
15. Tools at your disposal
Shell and console: groovysh and groovyConsole
An Ant task, a Maven plugin (GMaven)
A joint compiler
Lets you compile both Groovy and Java together!
IDE support
15 www.devoxx.com
17. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
18. A Java program
public class HelloWorld {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String greet() {
return quot;Hello quot;+ name;
}
public static void main(String[] args) {
HelloWorld helloWorld = new HelloWorld();
helloWorld.setName(quot;Groovyquot;);
System.out.println( helloWorld.greet() );
}
}
18 www.devoxx.com
19. A Groovy program
public class HelloWorld {
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public String greet() {
return quot;Hello quot;+ name;
}
public static void main(String[] args) {
HelloWorld helloWorld = new HelloWorld();
helloWorld.setName(quot;Groovyquot;);
System.out.println( helloWorld.greet() );
}
}
19 www.devoxx.com
23. Groovy Strings
GStrings: interpolated strings
def person = āJohnā
def letter = āāā${new Date()}
Dear ${person},
this is a Groovy letter!āāā
println letter
Multiline strings: triple single or double quotes
Slashy syntax
def whitespace = ~/s+?/
23 www.devoxx.com
24. Closures
A reusable / assignable block of code
delimited by curly braces
can take parameters
can be passed as parameters to methods, or inline
def printer = { println it }
def double = { int i -> 2 * i }
new File(āf.txtā).eachLine { line ->
println line
}
new File(āf.txtā).eachLine( printer )
24 www.devoxx.com
25. Time savers
The Groovy Truth
def blank = āā; assert !blank
def empty = []; assert !empty
Safe graph navigation
def order = null
assert order?.customer?.address == null
Elvis operator
def name = customer.name ?: āUnknownā
25 www.devoxx.com
26. Java 5 features
Since Groovy 1.5
Annotations, generics, static imports, enums, varargs
You can leverage frameworks supporting annotations
Spring, Hibernate, Guice, JPA, EJB3, TestNG, and more
Sole dynamic language supporting annotations
26 www.devoxx.com
27. Annotation example
@Entity
@Name(āhotelā)
class Hotel implements Serializable {
@Id @GeneratedValue
Long id
@Length(max = 40) @NotNull
String name
@Override String toString() {
āHotel ${name}ā
}
}
27 www.devoxx.com
28. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
29. The GDK ā Groovy Dev Kit
Groovy ādecoratesā existing JDK APIs
We canāt extend java.lang.String or java.io.File, can we?
new File(āf.txtā).eachLine { println it }
(1..100).findAll { it % 2 == 1 }
speakers.groupBy { it.lastname }
ā123ā.padLeft(5, ā0ā)
āls -laā.execute()
āR3Jvb3Z5IHJvY2tzIQ==ā.decodeBase64()
Thread.start { /* code to be executed */ }
29 www.devoxx.com
30. JDBC made easy
With transparent resource handling, thanks to closures
def sql = Sql.newInstance(url, usr, pwd, driver)
sql.execute(quot;insert into table values ($foo, $bar)quot;)
sql.execute(quot;insert into table values(?,?)quot;, [a, b])
sql.eachRow(quot;select * from USERquot;) { print it.name }
def list = sql.rows(quot;select * from USERquot;)
A poor-manās dataset notion
def set = sql.dataSet(quot;USERquot;)
set.add(name: quot;Johnnyquot;, age: 33)
set.each { user -> println user.name }
set.findAll { it.age > 22 && it.age < 42 }
30 www.devoxx.com
31. Parsing XML
With this multiline string XML fragment
def xml = quot;quot;quot;
<languages>
<language name=quot;Groovyquot;>
<feature coolness=quot;lowquot;>SQL</feature>
<feature coolness=quot;highquot;>Template</feature>
</language>
<language name=quot;Perlquot;/>
</languages>quot;quot;quot;
Navigate your XML graph as an object graph!
def root = new XmlParser().parseText(xml)
println root.language.feature[1].text()
root.language.feature
.findAll{ it['@coolness'] == quot;lowquot; }
.each{ println it.text() }
31 www.devoxx.com
32. Producing XML too!
The same XML document as before
new MarkupBuilder().languages {
language(name: quot;Groovyquot;) {
feature(coolness: quot;lowquot;, quot;SQLquot;)
feature(coolness: quot;highquot;, quot;Templatequot;)
}
language(name: quot;Perlquot;)
}
32 www.devoxx.com
33. Swing builder
Following the same ābuilder patternā, but for Swing
import javax.swing.WindowConstants as WC
import groovy.swing.SwingBuilder
def theMap = [color: quot;greenquot;, object: quot;pencilquot;]
def swing = new SwingBuilder()
def frame = swing.frame(
title: 'A Groovy Swing', location: [240,240],
defaultCloseOperation:WC.EXIT_ON_CLOSE) {
panel {
for (entry in theMap) {
label(text: entry.key)
textField(text: entry.value)
}
button(text: 'About', actionPerformed: {
def pane = swing.optionPane(message: 'SwingBuilder')
def dialog = pane.createDialog(null, 'About')
dialog.show()
})
button(text:'Quit', actionPerformed:{ System.exit(0) })
}
}
frame.pack()
frame.show()
33 www.devoxx.com
34. Swing builder
Following the same ābuilder patternā, but for Swing
import javax.swing.WindowConstants as WC
import groovy.swing.SwingBuilder
def theMap = [color: quot;greenquot;, object: quot;pencilquot;]
def swing = new SwingBuilder()
def frame = swing.frame(
title: 'A Groovy Swing', location: [240,240],
defaultCloseOperation:WC.EXIT_ON_CLOSE) {
panel {
for (entry in theMap) {
label(text: entry.key)
textField(text: entry.value)
}
button(text: 'About', actionPerformed: {
def pane = swing.optionPane(message: 'SwingBuilder')
def dialog = pane.createDialog(null, 'About')
dialog.show()
})
button(text:'Quit', actionPerformed:{ System.exit(0) })
}
}
frame.pack()
frame.show()
33 www.devoxx.com
35. Another builder with Ant
Reuse the wealth of Ant tasks for your build or system
scripting needs
// create sequantial Ant execution
new AntBuilder().sequential {
def buildClasses = ābuild/classesā
// create classes directory
mkdir(dir: buildClasses)
// compile sources
javac(srcdir: āsrcā,
destdir: buildClasses)
// jar everything
jar(destfile: āmy.jarā,
basedir: buildClasses)
}
34 www.devoxx.com
36. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
37. Whatās a DSL?
A Domain-Speciļ¬c Language is a small language
designed to be useful for a speciļ¬c set of tasks, for a
given domain
Not necessarily Turing-complete
Produces some result
conļ¬guration, data structures, simulation declarations...
Can be internal or external
Has a form: textual or visual
36 www.devoxx.com
38. Some examples
Technical
SELECT * FROM USERS WHERE NAME LIKE āGuil%ā
^[w-.]+@([w-]+.)+[w-]{2,4}$
Notation
1. e4 e5 2. Nf3 Nc6 3. Bb5 a6
U Rā U2 R U Rā U R
Business oriented
Risk calculation for insurance policies
Human Resources employee skills representation
Anti-malaria drug resistance simulation
37 www.devoxx.com
45. Groovyās MOP to the rescue
DSLs are possible in Groovy because of
Groovyās malleable syntax and APIs
Omitting parentheses, semi-columns
Named arguments, Closures
Everything is an object
Groovyās dynamic nature
MOP: Meta-Object Protocol
Nothing hard-wired,
behavior modiļ¬able at runtime!
40 www.devoxx.com
46. Parentheses & named args
Optional parentheses
move left
Named arguments
compare fund: āXYZā, withIndicator: āNIKEIā
account.debit amount: 30.euros, in: 3.days
Plus native syntax elements
Lists: [NIKEI, CAC40, NASDAK]
Maps: [CA: āCaliforniaā, CO: āColoradoā]
Ranges: Monday..Friday
41 www.devoxx.com
48. Operator overloading
Operators are a shorcut
for method calls
a + b == a.plus(b)
a - b == a.minus(b)
a * b == a.multiply(b)
a / b == a.divide(b)
a % b == a.modulo(b)
a | b == a.or(b)
a & b == a.and(b)
a[b] == a.getAt(b)
a << b == a.leftShift(b)
43 www.devoxx.com
49. Operator overloading
Operators are a shorcut Currency arithmetics
for method calls
30.euros + 15.dollars
a + b == a.plus(b)
Distances
a - b == a.minus(b)
a * b == a.multiply(b) 12.kilometers + 3.meters
a / b == a.divide(b) Parallelism or workļ¬ow
a % b == a.modulo(b)
taskA & taskB | taskC
a | b == a.or(b)
Banking
a & b == a.and(b)
a[b] == a.getAt(b) account += 10.euros
a << b == a.leftShift(b)
43 www.devoxx.com
50. Closures and builders
Remember the builder pattern? Ant, Swing, Markup...
You can easily create your own
Extend BuilderSupport or FactoryBuilderSupport
Nested method calls with closures as last argument
plan {
artifact {
name = āspring.coreā
type = ābundleā
version = ā2.5.6ā
}
}
44 www.devoxx.com
51. Why creating your own DSL?
Use a more expressive language than a general purpose
Share a common metaphore between developers and
subject matter experts
Have domain experts help with the design of the
business logic of an application
Avoid cluttering business code with too much boilerplate
technical code
Cleanly separate business logic from application code
Let business rules have their own lifecycle
45 www.devoxx.com
52. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
53. Groovy 1.6
Main focus on performance
to make Groovy the fastest dynamic language
Multiple assignment
def (a, b) = [1, 2]
def (int i, String s) = [1, āGroovyā]
(a, b) = functionReturningAList()
AST Transformations
@Lazy, @Immutable, @Singleton, @Delegate
Annotation deļ¬nition
47 www.devoxx.com
54. Groovy agenda
A bit of history and
background
Syntax basics
Interesting Groovy APIs
Domain-Speciļ¬c Languages
Whatās new in Groovy 1.6?
The Groovy ecosystem
www.devoxx.com
55. More than just Groovy...
First major Groovy child: Grails, but thereās more...
Griffon: a Grails-like MVC framework for building rich
Swing applications
Gradle: a new build system learning from the good ideas
and mistakes of Ant, Maven and Ivy
Easyb: a Behavior Driven Development toolkit which lets
you write user stories with a Groovy DSL
All three will be presented at Devoxx, check your agenda!
49 www.devoxx.com
56. Groovy Summary
The Groovy dynamic language for the JVM simpliļ¬es the
life of developers
Groovy opens up some interesting perspectives towards
extending and enhancing your applications
Groovy provides the most seamless Java integration
experience
Groovy lets you create Domain-Speciļ¬c Languages
Groovy protects your investment in skills, tools, libraries
and application servers
50 www.devoxx.com
57. Grails in Action
A bit of history and background
The Grails stack
Getting started with scaffolding
The layers: persistence, controllers & services, views
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
58. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
59. Guillaume Laforge on the Groovy lists in 2005:
Ruby on Rails is all the rage these days, but you
compromise on your past investment, if youāre a Java
shop: developer and IT team skills, training, app servers,
the great JVM platform, third-party libraries...
Canāt we leverage Groovy and proven technologies like
Spring and Hibernate to bring the āConvention over
Conļ¬gurationā paradigm on the Java platform, without
compromising on your investment?
www.devoxx.com
60. The Holy Grail(s)
Observation: lack of productivity in webapp development
We have all the tools at our disposal to change that
Back in 2005, Graeme Rocher, Steven Devijsver and
myself launched Grails
Apache licensed OSS project, hosted at Codehaus
Goal similar to Groovy: simplify the life of developers
So whatās under the hood?
54 www.devoxx.com
61. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
62. From 10,000 feet
Grails is an MVC action-based framework
Grails follows good principles popularized by Rails
CoC: Convention over Conļ¬guration
DRY: Donāt Repeat Yourself
The essence of Rails but with tight integration with the
Java platform to protect your investment!
56 www.devoxx.com
64. Near the ground...
Grails is built on rock-solid and proven technologies
the JVM, the Java EE specs, existing app servers, and...
Spring: IoC, DI, Spring MVC, Spring WebFlow
Hibernate: Object-Relational Mapping
SiteMesh: page layout and composition
Quartz: for job scheduling
Jetty and HSQLDB: for fast development cycles
Productive out of the box with a full development stack
58 www.devoxx.com
65. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
66. First step, download & install
Go to http://grails.org/Download
Download the latest archive
Unzip it somewhere
Create GRAILS_HOME
Add $GRAILS_HOME/bin to your PATH
Youāre ready to go!
Next step: grails create-app
60 www.devoxx.com
67. DEMO
Getting started
with scaffolding
Remember scaffolding is nice for CRUD,
admin interfaces, prototyping, getting up
and running quickly, but Grails is more
than just a CRUD framework!
www.devoxx.com
69. Did you notice?
Where are my conļ¬guration ļ¬les?
Why havenāt I written any XML ļ¬le?
Where are my DAOs?
Where are my mapping ļ¬les?
No database to conļ¬gure?
Nor a servlet container or
app server to install?
Or tons of jars to download
from Maven repositories?
There must be some magic under the hood :-)
www.devoxx.com
70. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
71. The usual problems
When you start a project, you have to setup everything
The build, wire all components together
You suffer from impedance mismatch
You have to handle the ORM mapping manually
Itās hard to write clean views
Taglibs are a pain to develop
65 www.devoxx.com
72. Persistence
Enters GORM: Grails Object Relational Mapping
Hibernate under the hood
Your domain model is a set of POGOs
Your domain classes are transparentely mapped
Although you can use legacy schemas with GORM DSL
No conf: hibernate.cfg.xml, no *.hbm.xml ļ¬les!
But you can bring your own existing ones if needed
Always a path to conļ¬guration when in need
66 www.devoxx.com
73. Persistence
Enters GORM: Grails Object Relational Mapping
Hibernate under the hood Not limited by
Your domain model is a set of POGOs conventions?
Your domain classes are transparentely mapped
Although you can use legacy schemas with GORM DSL
No conf: hibernate.cfg.xml, no *.hbm.xml ļ¬les!
But you can bring your own existing ones if needed
Always a path to conļ¬guration when in need
66 www.devoxx.com
74. Dynamic ļ¬nders
All domain classes have got injected methods like
Book.count(), Book.list(), Book.get(id)
book.save(), book.delete(), etc...
Dynamic ļ¬nders
Book.findByTitle(āHarry Potterā)
Book.findAllByAuthorLike(ā%Rowlinsā)
Book.findAllByTitleLikeAndReleaseDateLessThan(
ā%Grails%ā, 2007
) // donāt do that :-)
67 www.devoxx.com
75. Dynamic ļ¬nders
All domain classes have got injected methods like
Book.count(), Book.list(), Book.get(id)
book.save(), book.delete(), etc...
Dynamic ļ¬nders
Book.findByTitle(āHarry Potterā)
Book.findAllByAuthorLike(ā%Rowlinsā)
Book.findAllByTitleLikeAndReleaseDateLessThan(
ā%Grails%ā, 2007
) // donāt do that :-)
Whereās
my DAO?
67 www.devoxx.com
76. Queries
You can use raw HQL queries
Book.ļ¬nd(āfrom Book b where b.title = ?ā, [āShiningā])
Grails wraps the Hibernate Criteria API
def results = Account.list {
like āholderFirstNameā, āFred%ā
and {
between ābalanceā, 500, 1000
eq ābranchā, āLondonā
}
order āholderLastNameā, ādescā
}
68 www.devoxx.com
77. Constraints
Constraints can be added to domain classes
through a static constraints ļ¬eld
static constraints = {
isbn matches: /[0-9]{9}[0-9X]/
}
Many constraints available
blank, creditcard, email, nullable, matches, range, unique
Create your own validator
myIntField = { it % 2 == 0 }
You can also register your own constraints
69 www.devoxx.com
78. Controllers
In the controller directory, name ending with Controller
http://myserver:8080/app/controller/action
Handy things at your disposal
redirect, chain, render, ļ¬ash scope
Controllers return Maps as models for the view to render
Possible access to the raw output stream
Easy databinding from form ļ¬elds
book.properties = params
70 www.devoxx.com
79. Controllers
In the controller directory, name ending with Controller
http://myserver:8080/app/controller/action
a d
Handy things at your disposal
e lo
redirect, chain, render, ļ¬ash scope R
Controllers return Maps as models for the view to render
Possible access to the raw output stream
Easy databinding from form ļ¬elds
book.properties = params
70 www.devoxx.com
80. Services
Another naming convention and placement
Transactional by default
Just declare your service, itāll be transparently injected!
no need to conļ¬gure it in some XML ļ¬e
71 www.devoxx.com
81. The view tier
The view tier is essentially composed of two things
The Groovy Server Pages
Similar to JSPs
But with GString interpolation
The Grails Tag Libraries
Useful existing tag libraries
So easy to write your own!
Templates, URL mapping, conversations and more
72 www.devoxx.com
85. Create your own taglib
Yet another Grails convention
class MyTaglib {
def isAdmin = { attrs, body ->
def user = attrs[āuserā]
if (user && checkUserPrivs(user)) {
body()
}
}
}
Use it in your GSP
<g:isAdmin user=ā${user}ā>
Some restricted content
75 www.devoxx.com
86. Create your own taglib
Yet another Grails convention
class MyTaglib {
def isAdmin = { attrs, body ->
def user = attrs[āuserā]
if (user && checkUserPrivs(user)) {
body()
}
}
a d
}
e lo
Use it in your GSP R
<g:isAdmin user=ā${user}ā>
Some restricted content
75 www.devoxx.com
87. Custom URL mappings
Not satisļ¬ed with the default URL mapping?
Deļ¬ne your URLs yourself!
class UrlMapping {
static mappings = {
ā$blog/$yeah?/$month?/$day?ā (controller: āblogā,
action: āshowā) {
constraints {
year matches: /d{4}/
}
}
}
}
76 www.devoxx.com
88. What have I not shown?
Conversation concept using Spring WebFlow
Templates for reusing view logic and presentation
Internationalization
You can reuse JSP tag libraries (in Grails 1.1)
SiteMesh layouts and page componentization
Handling of REST style architecture
Unit and integration tests
Reuse legacy schemas
or Spring conļ¬gurations
77 www.devoxx.com
89. What have I not shown?
Conversation concept using Spring WebFlow
Templates for reusing view logic and presentation
Internationalization
You can reuse JSP tag libraries (in Grails 1.1)
SiteMesh layouts and page componentization
Handling of REST style architecture
Unit and integration tests Not limited by
conventions?
Reuse legacy schemas
or Spring conļ¬gurations
77 www.devoxx.com
90. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
91. A wealth of plugins
Grails is built on top of a core plugin system
100+ plugins already available
Testing: Webtest, Easyb, Selenium, jsUnit, Fitnesse
Rich client / AJAX: Yahoo, Ext-JS, GWT, jQuery, iUI
Web Services: XFire, remoting, Axis2, Metro
Security: Spring Security, JSecurity
Search: Compass integration
Other integration: Drools, Struts, GridGain, Terracotta
79 www.devoxx.com
92. Grails agenda
A bit of history and
background
The Grails stack
Getting started with
scaffolding
The various layers
The plugin ecosystem
Whatās new in Grails 1.1?
www.devoxx.com
93. Grails 1.1
JSP tag library support and reuse
New GORM events
Improvements to data binding
Read-only access to domain objects
More options for the GORM DSL
Improvements to dynamic ļ¬nders
More support for legacy mappings
New testing plugin included for easier testing
81 www.devoxx.com
94. Grails Summary
Grails is not just a web framework,
but a full-blown development stack
Grails is not a clone of Ruby on Rails
Grails is built on proven rock-solid technologies
Grails brings back the productivity to Java developers
Grails is a new weapon for the war on Java complexity
82 www.devoxx.com
96. Thanks for your attention!
http://groovy.codehaus.org
http://grails.org
http://www.springsource.com/g2one
http://glaforge.free.fr/blog/groovy
glaforge@gmail.com
www.devoxx.com
97. Pictures from the web used in this presentation:
Question marks: http://weblogs.newsday.com
Agenda: http://www.jouy.inra.fr
Mop: http://www.spitjack.com
Harry Potter: http://madhavgopalkrish.ļ¬les.wordpress.com
www.devoxx.com