IEEE Day 2013
01 October 2013, Qafqaz University
Ziya Askerov
Java Software Developer
Cybernet LLC
ziyaaskerov@gmail.com
Build modern,
sophisticated and
robust Groovy web
applications in record
time !
Ziya Askerov
http://www.professionals.az
Contents
 Java Web Technologies Overview
 Groovy Scripting Language
 Grails Framework
 Convention Over Configuration
...
JAVA WEB TECHNOLOGIES
What is Groovy ?
 Is an agile and dynamic language for the Java Virtual Machine
 Makes modern programming features avail...
What is Grails?
 Full stack MVC framework for web apps
 Exploits the awesome power of Groovy
 Leverages proven staples
...
GRAILS ARCHITECTURE
Why GRAILS?
 Java web development as it stands today is
dramatically more complicated than it needs
to be
 Most modern w...
Why GRAILS?
- An easy to use Object Relational Mapping (ORM)
layer built on Hibernate
- An expressive view technology call...
Why GRAILS?
 Based on battle tested and proven Java frameworks (Spring,
Hibernate, SiteMesh, Quartz, etc) 
 Based on Gro...
Convention Over Configuration
 Grails uses "convention over configuration" to configure itself
 This typically means tha...
GRAILS AND SECURITY
 All standard database access via GORM domain objects is 
automatically SQL escaped to prevent SQL in...
GORM
 GORM is Grails' object relational mapping 
(ORM) implementation.
 Under the hood it uses Hibernate  (a very 
popul...
GRAILS ARCHITECTURE
GORM
 Domain Modelling in GORM
 Persistence Basics
 Querying with GORM
 Saving and Updating
 Dynamic Finders
 Eager ...
GORM DOMAIN MODELING
CONSTRAINTS
blank
creditCard
email
inList
matches
max
maxSize
min
minSize
notEqual
nullable
range
scale
size
unique
url
SAVING AND UPDATING
def p = Person.get(1) 
p.save()
def p = Person.get(1)
p.save(flush: true)
def p = Person.get(1)
p.dele...
Querying With GORM
def books = Book.list()
def books = Book.list(offset:10, max:20)
def books = Book.list(sort:"title", or...
Dynamic Finders
def book = Book.findByTitle("The Stand")
book = Book.findByTitleLike("Harry Pot%")
book = Book.findByRelea...
Hibernate's Criteria API
GRAILS AND MVC
Controllers, Services
Dependency Injection
TAGS
 <g:form name="myForm" action="myaction" id="1">...</g:form>
 <select onchange="${remoteFunction(action: 'bookByNam...
GRAILS PLUGINS
 Spring Security Core Plugin
 Spring Security UI Plugin
 Quartz Plugin
 Quartz Monitor Plugin
 Mail Pl...
SPRING SECURITY ANNOTATIONS
SPRING SECURITY ANNOTATIONS
Spring Security TagLib
<sec:ifLoggedIn> Welcome Back! </sec:ifLoggedIn>
<sec:ifAllGranted roles="ROLE_ADMIN,ROLE_SUPERVISO...
Spring Security Utils
 authoritiesToRoles()
 getPrincipalAuthorities()
 parseAuthoritiesString()
 ifAllGranted()
 ifN...
Configuration
 BootStrap.groovy
 BuildConfig.groovy
 Config.groovy
 DataSource.groovy
 UrlMappings.groovy
Config.groovy
BuildConfig.groovy
DataSource.groovy
UrlMappings.groovy
class UrlMappings {
static mappings = {
}
}
"/profile"(controller:"userProfile“,action:"userProfile")
"...
GRAILS TOOL (GGTS)
Download from : http://spring.io/tools/ggts
SITES USING GRAILS
Upcoming SlideShare
Loading in...5
×

GROOVY ON GRAILS

1,105

Published on

Build modern, sophisticated and robust Groovy web applications in record time !

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

  • Be the first to like this

No Downloads
Views
Total Views
1,105
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

GROOVY ON GRAILS

  1. 1. IEEE Day 2013 01 October 2013, Qafqaz University Ziya Askerov Java Software Developer Cybernet LLC ziyaaskerov@gmail.com
  2. 2. Build modern, sophisticated and robust Groovy web applications in record time ! Ziya Askerov http://www.professionals.az
  3. 3. Contents  Java Web Technologies Overview  Groovy Scripting Language  Grails Framework  Convention Over Configuration  GORM (Grails Object Relational Mapping)  GSP (Groovy Server Pages)  Grails Tags  Web Layer  Grails Plugins  Spring Security  Configuration
  4. 4. JAVA WEB TECHNOLOGIES
  5. 5. What is Groovy ?  Is an agile and dynamic language for the Java Virtual Machine  Makes modern programming features available to Java developers with almost-zero learning curve  Increases developer productivity  Compiles straight to Java bytecode so you can use it anywhere you can use Java  Seamlessly integrates with all existing Java classes and libraries
  6. 6. What is Grails?  Full stack MVC framework for web apps  Exploits the awesome power of Groovy  Leverages proven staples – Hibernate – Spring – Sitemesh  Works on JVM
  7. 7. GRAILS ARCHITECTURE
  8. 8. Why GRAILS?  Java web development as it stands today is dramatically more complicated than it needs to be  Most modern web frameworks in the Java space are over complicated and don't embrace the Don't Repeat Yourself (DRY) principles.
  9. 9. Why GRAILS? - An easy to use Object Relational Mapping (ORM) layer built on Hibernate - An expressive view technology called Groovy Server Pages (GSP) - A controller layer built on Spring MVC - A transactional service layer built on Spring's transaction abstraction
  10. 10. Why GRAILS?  Based on battle tested and proven Java frameworks (Spring, Hibernate, SiteMesh, Quartz, etc)   Based on Groovy language  GORM(Grails Object Relational Mapping)  Doesn’t stop you from using the power of underlying frameworks  Easy to set-up and get started  Minimal server restart required while development  Convention over Configuration / No painful XML configuration & XML Management  Tag Lib Authoring mechanism  Tons of available plugins
  11. 11. Convention Over Configuration  Grails uses "convention over configuration" to configure itself  This typically means that the name and location of files is used  instead of explicit configuration  No config files  No action mappings
  12. 12. GRAILS AND SECURITY  All standard database access via GORM domain objects is  automatically SQL escaped to prevent SQL injection attacks  Grails link creating tags (link, form, createLink, createLinkTo and  others) all use appropriate escaping mechanisms to prevent code  injection  Grails provides codecs to let you trivially escape data when rendered  as HTML, JavaScript and URLs to prevent injection attacks here.  XSRF attacks prevention with useToken
  13. 13. GORM  GORM is Grails' object relational mapping  (ORM) implementation.  Under the hood it uses Hibernate  (a very  popular and flexible open source ORM  solution)  
  14. 14. GRAILS ARCHITECTURE
  15. 15. GORM  Domain Modelling in GORM  Persistence Basics  Querying with GORM  Saving and Updating  Dynamic Finders  Eager and Lazy Fetching   
  16. 16. GORM DOMAIN MODELING
  17. 17. CONSTRAINTS blank creditCard email inList matches max maxSize min minSize notEqual nullable range scale size unique url
  18. 18. SAVING AND UPDATING def p = Person.get(1)  p.save() def p = Person.get(1) p.save(flush: true) def p = Person.get(1) p.delete(flush: true)
  19. 19. Querying With GORM def books = Book.list() def books = Book.list(offset:10, max:20) def books = Book.list(sort:"title", order:"asc") def book = Book.get(23) def books = Book.getAll(23, 93, 81)
  20. 20. Dynamic Finders def book = Book.findByTitle("The Stand") book = Book.findByTitleLike("Harry Pot%") book = Book.findByReleaseDateBetween(firstDate, secondDate) book = Book.findByReleaseDateGreaterThan(someDate)
  21. 21. Hibernate's Criteria API
  22. 22. GRAILS AND MVC
  23. 23. Controllers, Services Dependency Injection
  24. 24. TAGS  <g:form name="myForm" action="myaction" id="1">...</g:form>  <select onchange="${remoteFunction(action: 'bookByName', update: [success: 'great', failure: 'ohno'], params: ''bookName=' + this.value')}"> <option>first</option> <option>second</option> </select>  <g:render template="bookTemplate" />  <g:paginate controller="book" action="list" total="${bookCount}" />  <g:if test="${name == 'fred'}"> Hello ${name}! </g:if>  <g:include controller="book" action="list" />
  25. 25. GRAILS PLUGINS  Spring Security Core Plugin  Spring Security UI Plugin  Quartz Plugin  Quartz Monitor Plugin  Mail Plugin  XSS sanitizer Plugin
  26. 26. SPRING SECURITY ANNOTATIONS
  27. 27. SPRING SECURITY ANNOTATIONS
  28. 28. Spring Security TagLib <sec:ifLoggedIn> Welcome Back! </sec:ifLoggedIn> <sec:ifAllGranted roles="ROLE_ADMIN,ROLE_SUPERVISOR">secure stuff here</sec:ifAllGranted> <sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_SUPERVISOR">secure stuff here</sec:ifAnyGranted> Welcome Back <sec:loggedInUserInfo field="fullName"/>
  29. 29. Spring Security Utils  authoritiesToRoles()  getPrincipalAuthorities()  parseAuthoritiesString()  ifAllGranted()  ifNotGranted()  ifAnyGranted()  getSecurityConfig()  loadSecondaryConfig()  reloadSecurityConfig()  isAjax()
  30. 30. Configuration  BootStrap.groovy  BuildConfig.groovy  Config.groovy  DataSource.groovy  UrlMappings.groovy
  31. 31. Config.groovy
  32. 32. BuildConfig.groovy
  33. 33. DataSource.groovy
  34. 34. UrlMappings.groovy class UrlMappings { static mappings = { } } "/profile"(controller:"userProfile“,action:"userProfile") "/newsfeed"(controller:"userProfile“,action:"homePage") "/company"(controller:"company“,action:"companyProfile")
  35. 35. GRAILS TOOL (GGTS) Download from : http://spring.io/tools/ggts
  36. 36. SITES USING GRAILS
  1. ¿Le ha llamado la atención una diapositiva en particular?

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×