SlideShare uma empresa Scribd logo
1 de 29
Grails Presentation Adam Evans (http://www.ctisn.com)
What is Grails? Rapid development framework Convention over configuration Built on proven technologies Spring IoC Spring MVC Hibernate Sitemesh Uses groovy
What is Groovy? A scripting language which runs on the JVM Groovy Objects extend java.lang.Object Seamless Java integration Designed for the Java developer Linear learning curve Familiar syntax
A Java Class
And A Groovy Example
What's The Difference NONE! Groovy lets you use Java code in your groovy classes / scripts We can make this groovier
A Groovy Example V2 No constructor – groovy allows you to pass in a map to set variables Closures (the each function) Null safe operations '?' Extends standard JDK classes objects (the each function) Typing optional – def keyword
Groovy Allows you to use Java + Static typing when necessary Adds additional functionality to standard JDK classes Closures MOP Meta Object Protocol Java like syntax Linear learning curve, you can start with Java and re-factor to make it groovier
Grails Uses best practices with the power of Groovy to make a rapid development environment built on proven technologies you already know
Grails Cont Provides a view layer (GSP's + Sitemesh) Service layer (Service spring managed beans) Repository (GORM, Grails object relational mapping...hibernate abstraction) Unit / integration tests a key feature The grails app structure
Grails Plugins Provide a full slice of the application Views Controllers Domain objects Sessions Scripts Allow to make a application modular, great for teams working on feature sets and to reuse ability
Demo Lets take a look at how easy it is to create a grails application and integrate spring libraries We'll create a basic application to search twitter using the api, cache and display the results
Demo (contd) Create the application, type 'grails create-app twitter-search' from the command line We now have a fully functional web application, this can be run using 'grails run-app'
Demo (contd) Create a service bean to query twitter. 'grails create-service com.demo.TwitterService'
Demo (contd) Create a controller to query the service 'grails create-controller com.demo.TwitterSearch' Notes:  1) Spring injects the TwitterService class based on the variable name  2) Controller actions are defined as groovy closures. We return a map to the view. By convention the view will be under  'grails-app/views/${controller}/${action}‘ Iefor the above:      'grails-app/views/twitterSearch/search.gsp'
Demo (cont) Create the view 'grails-app/views/twitterSearch/seach.gsp' Note: the layout meta tag, this tells sitemesh to decorate the page using the  'grails-app/layouts/main.gsp' template
Complete We now have a basic web application displaying results from the twitter api
Demo (cont) Run 'grails-stats' 18 lines of code !
Integrating with Spring We've not interacted with Spring directly so far Grails has taken over in the background configuring the view resolver, url mappings / controllers for Spring MVN, injecting session beans
Spring In Grails We'll look at making further use of Spring in Grails by using Spring AOP to cache the search results
Spring AOP In Grails 1) We place the required lib directory aspectjrt.jar (v1.5+)  aspectjweaver.jar (v1.5+) 2) Create the spring config xml file 'grails-app/conf/resources.xml' Note: As of grails 1.2 the component-scan will not be needed as grails supports the @Component annotation by default
Create a Annotation We create a Cacheable annotation under src/java.
We create a Aspect With the above, any method with the annotation @Cacheable will be handled by the aroundAdvice method. For now we just called proceed() so the method We are intercepting is executed and  we return the value
Trivial Caching As we apply 'around' advice to our method it is trivial to cache. Check if we have a cached value If not execute method and store result else load cached item Return result For this example grails comes with the oscache libs already so I'll use that for the caching
Trivial Caching (cont)
Trivial Caching (cont) Below is the function we use to generate the cache key based on method name / arguments
Conclusion We've seen how Grails integrates with Java Spring The rapidness of creating a application If you have a spring application already you can import your spring beans into Grails Boilerplate code has gone, no more days lost setting up new projects writing masses of XML
Points not Discussed Scaffolding Grails attempts to create basic views of your domain to get you started GORM
Questions

Mais conteúdo relacionado

Mais procurados

The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018Carlos Mendible
 
Serverless Pipelines for Serverless Applications
Serverless Pipelines for Serverless ApplicationsServerless Pipelines for Serverless Applications
Serverless Pipelines for Serverless ApplicationsAmazon Web Services
 
Building robust REST APIs
Building robust REST APIsBuilding robust REST APIs
Building robust REST APIsNejc Zupan
 
GradleのREPLプラグイン紹介 #jggug
GradleのREPLプラグイン紹介 #jggugGradleのREPLプラグイン紹介 #jggug
GradleのREPLプラグイン紹介 #jggugkyon mm
 
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"NodeUkraine
 
Dockerized apps on Kubernetes
Dockerized apps on KubernetesDockerized apps on Kubernetes
Dockerized apps on KubernetesŁukasz Barulski
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-newBradDesAulniers2
 
GitLab Frontend and VueJS at GitLab
GitLab Frontend and VueJS at GitLabGitLab Frontend and VueJS at GitLab
GitLab Frontend and VueJS at GitLabFatih Acet
 
Github Actions in action - GHA in OSS project (instead of Travis)
Github Actions in action - GHA in OSS project (instead of Travis)Github Actions in action - GHA in OSS project (instead of Travis)
Github Actions in action - GHA in OSS project (instead of Travis)Juho Saarinen
 
GWTcon 2015 - Best development practices for GWT web applications
GWTcon 2015 - Best development practices for GWT web applications GWTcon 2015 - Best development practices for GWT web applications
GWTcon 2015 - Best development practices for GWT web applications Arcbees
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow ToolsFITC
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuFramgia Vietnam
 

Mais procurados (20)

The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018The State of the Developer Ecosystem - .NET Conf Barcelona 2018
The State of the Developer Ecosystem - .NET Conf Barcelona 2018
 
Serverless Pipelines for Serverless Applications
Serverless Pipelines for Serverless ApplicationsServerless Pipelines for Serverless Applications
Serverless Pipelines for Serverless Applications
 
Building robust REST APIs
Building robust REST APIsBuilding robust REST APIs
Building robust REST APIs
 
GradleのREPLプラグイン紹介 #jggug
GradleのREPLプラグイン紹介 #jggugGradleのREPLプラグイン紹介 #jggug
GradleのREPLプラグイン紹介 #jggug
 
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
Nikolai Boiko "NodeJS Refactoring: How to kill a Dragon and stay alive"
 
Intro to javascript (4 week)
Intro to javascript (4 week)Intro to javascript (4 week)
Intro to javascript (4 week)
 
Dockerized apps on Kubernetes
Dockerized apps on KubernetesDockerized apps on Kubernetes
Dockerized apps on Kubernetes
 
Introducing spring
Introducing springIntroducing spring
Introducing spring
 
Grails Spring Boot
Grails Spring BootGrails Spring Boot
Grails Spring Boot
 
Angular 2 observables
Angular 2 observablesAngular 2 observables
Angular 2 observables
 
2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new2016 05-cloudsoft-amp-and-brooklyn-new
2016 05-cloudsoft-amp-and-brooklyn-new
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
GitLab Frontend and VueJS at GitLab
GitLab Frontend and VueJS at GitLabGitLab Frontend and VueJS at GitLab
GitLab Frontend and VueJS at GitLab
 
Cloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud PlatformCloud Spin - building a photo booth with the Google Cloud Platform
Cloud Spin - building a photo booth with the Google Cloud Platform
 
Groovy & Grails
Groovy & GrailsGroovy & Grails
Groovy & Grails
 
Github Actions in action - GHA in OSS project (instead of Travis)
Github Actions in action - GHA in OSS project (instead of Travis)Github Actions in action - GHA in OSS project (instead of Travis)
Github Actions in action - GHA in OSS project (instead of Travis)
 
GWTcon 2015 - Best development practices for GWT web applications
GWTcon 2015 - Best development practices for GWT web applications GWTcon 2015 - Best development practices for GWT web applications
GWTcon 2015 - Best development practices for GWT web applications
 
Jedi knight
Jedi knightJedi knight
Jedi knight
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Jenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh VuJenkins and rails app - Le Dinh Vu
Jenkins and rails app - Le Dinh Vu
 

Destaque

Cf Moto
Cf MotoCf Moto
Cf Motomrt326
 
Architecture Projects P
Architecture Projects PArchitecture Projects P
Architecture Projects Pbmermans
 
Wytyczne do pisania programów
Wytyczne do pisania programówWytyczne do pisania programów
Wytyczne do pisania programówPiotr Szymański
 
Egypt Vacation
Egypt VacationEgypt Vacation
Egypt VacationJulia1002
 
Participantes del dial a la nube
Participantes del dial a la nubeParticipantes del dial a la nube
Participantes del dial a la nube5206406
 
Recent Works
Recent WorksRecent Works
Recent Worksbmermans
 
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)ajevans
 
AWS at Childrens in the BBC
AWS at Childrens in the BBCAWS at Childrens in the BBC
AWS at Childrens in the BBCajevans
 
Finding The Slope And Y Intercept
Finding The Slope And Y InterceptFinding The Slope And Y Intercept
Finding The Slope And Y InterceptThief River Falls
 
How to engage, nurture and close more prospects with Full Funnel Marketing
How to engage, nurture and close more prospects with Full Funnel MarketingHow to engage, nurture and close more prospects with Full Funnel Marketing
How to engage, nurture and close more prospects with Full Funnel MarketingHeinz Marketing Inc
 
Referral hacks: 22 best practices to help you win more business
Referral hacks: 22 best practices to help you win more businessReferral hacks: 22 best practices to help you win more business
Referral hacks: 22 best practices to help you win more businessHeinz Marketing Inc
 
Eight ways to double your sales team's productivity #b2bmx
Eight ways to double your sales team's productivity #b2bmxEight ways to double your sales team's productivity #b2bmx
Eight ways to double your sales team's productivity #b2bmxHeinz Marketing Inc
 

Destaque (14)

Cf Moto
Cf MotoCf Moto
Cf Moto
 
Architecture Projects P
Architecture Projects PArchitecture Projects P
Architecture Projects P
 
Wytyczne do pisania programów
Wytyczne do pisania programówWytyczne do pisania programów
Wytyczne do pisania programów
 
Egypt Vacation
Egypt VacationEgypt Vacation
Egypt Vacation
 
Participantes del dial a la nube
Participantes del dial a la nubeParticipantes del dial a la nube
Participantes del dial a la nube
 
Informat
InformatInformat
Informat
 
Recent Works
Recent WorksRecent Works
Recent Works
 
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)
Making the case for Play Framework and Scala- Budapest Ping-Conf (2014)
 
AWS at Childrens in the BBC
AWS at Childrens in the BBCAWS at Childrens in the BBC
AWS at Childrens in the BBC
 
Finding The Slope And Y Intercept
Finding The Slope And Y InterceptFinding The Slope And Y Intercept
Finding The Slope And Y Intercept
 
Red Black Trees
Red Black TreesRed Black Trees
Red Black Trees
 
How to engage, nurture and close more prospects with Full Funnel Marketing
How to engage, nurture and close more prospects with Full Funnel MarketingHow to engage, nurture and close more prospects with Full Funnel Marketing
How to engage, nurture and close more prospects with Full Funnel Marketing
 
Referral hacks: 22 best practices to help you win more business
Referral hacks: 22 best practices to help you win more businessReferral hacks: 22 best practices to help you win more business
Referral hacks: 22 best practices to help you win more business
 
Eight ways to double your sales team's productivity #b2bmx
Eight ways to double your sales team's productivity #b2bmxEight ways to double your sales team's productivity #b2bmx
Eight ways to double your sales team's productivity #b2bmx
 

Semelhante a Spring Northwest Usergroup Grails Presentation

Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsJames Williams
 
Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grailsGeorge Platon
 
Java to Golang: An intro by Ryan Dawson Seldon.io
Java to Golang: An intro by Ryan Dawson Seldon.ioJava to Golang: An intro by Ryan Dawson Seldon.io
Java to Golang: An intro by Ryan Dawson Seldon.ioMauricio (Salaboy) Salatino
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Tugdual Grall
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishGrails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishSven Haiges
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sOrtus Solutions, Corp
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthDanno Ferrin
 
JavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderJavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderAndres Almiray
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyJames Williams
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 
Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0Diego Zuluaga
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkeyjervin
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y GradleAntonio Mas
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerPaul Jensen
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesRainer Stropek
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's Howmrdon
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Arun Gupta
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails FrameworkHarshdeep Kaur
 

Semelhante a Spring Northwest Usergroup Grails Presentation (20)

Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
 
Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grails
 
Java to Golang: An intro by Ryan Dawson Seldon.io
Java to Golang: An intro by Ryan Dawson Seldon.ioJava to Golang: An intro by Ryan Dawson Seldon.io
Java to Golang: An intro by Ryan Dawson Seldon.io
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishGrails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api's
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
 
JavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilderJavaOne TS-5098 Groovy SwingBuilder
JavaOne TS-5098 Groovy SwingBuilder
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0
 
Introduction to Groovy Monkey
Introduction to Groovy MonkeyIntroduction to Groovy Monkey
Introduction to Groovy Monkey
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
Spring boot
Spring bootSpring boot
Spring boot
 
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and PuppeteerE2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
E2E testing Single Page Apps and APIs with Cucumber.js and Puppeteer
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile Services
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails Framework
 

Último

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Spring Northwest Usergroup Grails Presentation

  • 1. Grails Presentation Adam Evans (http://www.ctisn.com)
  • 2. What is Grails? Rapid development framework Convention over configuration Built on proven technologies Spring IoC Spring MVC Hibernate Sitemesh Uses groovy
  • 3. What is Groovy? A scripting language which runs on the JVM Groovy Objects extend java.lang.Object Seamless Java integration Designed for the Java developer Linear learning curve Familiar syntax
  • 5. And A Groovy Example
  • 6. What's The Difference NONE! Groovy lets you use Java code in your groovy classes / scripts We can make this groovier
  • 7. A Groovy Example V2 No constructor – groovy allows you to pass in a map to set variables Closures (the each function) Null safe operations '?' Extends standard JDK classes objects (the each function) Typing optional – def keyword
  • 8. Groovy Allows you to use Java + Static typing when necessary Adds additional functionality to standard JDK classes Closures MOP Meta Object Protocol Java like syntax Linear learning curve, you can start with Java and re-factor to make it groovier
  • 9. Grails Uses best practices with the power of Groovy to make a rapid development environment built on proven technologies you already know
  • 10. Grails Cont Provides a view layer (GSP's + Sitemesh) Service layer (Service spring managed beans) Repository (GORM, Grails object relational mapping...hibernate abstraction) Unit / integration tests a key feature The grails app structure
  • 11. Grails Plugins Provide a full slice of the application Views Controllers Domain objects Sessions Scripts Allow to make a application modular, great for teams working on feature sets and to reuse ability
  • 12. Demo Lets take a look at how easy it is to create a grails application and integrate spring libraries We'll create a basic application to search twitter using the api, cache and display the results
  • 13. Demo (contd) Create the application, type 'grails create-app twitter-search' from the command line We now have a fully functional web application, this can be run using 'grails run-app'
  • 14. Demo (contd) Create a service bean to query twitter. 'grails create-service com.demo.TwitterService'
  • 15. Demo (contd) Create a controller to query the service 'grails create-controller com.demo.TwitterSearch' Notes: 1) Spring injects the TwitterService class based on the variable name 2) Controller actions are defined as groovy closures. We return a map to the view. By convention the view will be under 'grails-app/views/${controller}/${action}‘ Iefor the above: 'grails-app/views/twitterSearch/search.gsp'
  • 16. Demo (cont) Create the view 'grails-app/views/twitterSearch/seach.gsp' Note: the layout meta tag, this tells sitemesh to decorate the page using the 'grails-app/layouts/main.gsp' template
  • 17. Complete We now have a basic web application displaying results from the twitter api
  • 18. Demo (cont) Run 'grails-stats' 18 lines of code !
  • 19. Integrating with Spring We've not interacted with Spring directly so far Grails has taken over in the background configuring the view resolver, url mappings / controllers for Spring MVN, injecting session beans
  • 20. Spring In Grails We'll look at making further use of Spring in Grails by using Spring AOP to cache the search results
  • 21. Spring AOP In Grails 1) We place the required lib directory aspectjrt.jar (v1.5+) aspectjweaver.jar (v1.5+) 2) Create the spring config xml file 'grails-app/conf/resources.xml' Note: As of grails 1.2 the component-scan will not be needed as grails supports the @Component annotation by default
  • 22. Create a Annotation We create a Cacheable annotation under src/java.
  • 23. We create a Aspect With the above, any method with the annotation @Cacheable will be handled by the aroundAdvice method. For now we just called proceed() so the method We are intercepting is executed and we return the value
  • 24. Trivial Caching As we apply 'around' advice to our method it is trivial to cache. Check if we have a cached value If not execute method and store result else load cached item Return result For this example grails comes with the oscache libs already so I'll use that for the caching
  • 26. Trivial Caching (cont) Below is the function we use to generate the cache key based on method name / arguments
  • 27. Conclusion We've seen how Grails integrates with Java Spring The rapidness of creating a application If you have a spring application already you can import your spring beans into Grails Boilerplate code has gone, no more days lost setting up new projects writing masses of XML
  • 28. Points not Discussed Scaffolding Grails attempts to create basic views of your domain to get you started GORM