Why Grails

2,578 views
2,502 views

Published on

This presentation would like to convince you grails is very good and you have lots to enjoy

Published in: Technology
1 Comment
4 Likes
Statistics
Notes
  • Check out this webinar on Grails to understand its full potentials and features - http://www.cygnet-infotech.com/whitepaper-grails
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
2,578
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
33
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Why Grails

  1. 1. Why  Grails?   Yiguang  Hu  
  2. 2. What  is  Grails?   •  Grails  is  a  web  framework  based  on   –  JAVA,  GROOVY,  Spring,  GORM   •  Scaffolding!   •  Plugin  everything!!!   –  GWT,  DWR,  YUI,  ACEGI,  Google  AppEngine,  Google   Wave,  COMET,  JQuery,  Clojure,  Scala,  JSF,  Struts…   •  Support  all  modern  browsers  automaRcally   •  Render  object  to  JSON,  XML  free!   •  MVC+IOC(services)+plugin  
  3. 3. Why  Grails?   •  Rapid   –  Have  your  next  Web  2.0  project  done  in  weeks  instead  of   months.  Grails  delivers  a  new  age  of  Java  web  applicaRon   producRvity.   •  Dynamic   –  Get  instant  feedback,  see  instant  results.  Grails  is  the   premier  dynamic  language  web  framework  for  the  JVM.   •  Robust   –  Powered  by  Spring,  Grails  out  performs  the  compeRRon.   Dynamic,  agile  web  development  without  compromises.   •  Proven  Technologies:  JAVA(Groovy),  Spring,  GORM  
  4. 4. What  is  Groovy?   •  Groovy  =   –  JAVA+Dynamic  Typing+Closure+   DSL,  GPars,Griffon….   •  Runs  on  JVM   • 0  Learning  curve  for  Java  programmer  
  5. 5. Success  Stories   •  The  Sites  I  personally  involved:   –  Worthpoint.com  (80  million  records)   –  Gsword:  h_p://www.ccimweb.org/gsword   •  Web  2.0.  Highly  interacRve.   •  Done  in  two  days!   –  Others  
  6. 6. Demo   •  Install  java,  groovy,  grails   •  grails  create-­‐app  interop   –  Goto  dir  interop  and  see  the  dires/files  created   •  Run  it!   •  Add  domain   •  Generate  controller/views  and  run   –  SorRng,  paginaRon  are  there  already!   •  Add  a  service  and  use  in  controller   •  Run  it!  
  7. 7. Demo…   •  SOA   –  Render  objects  as  JSON,  XML  etc   –  Import  grails.converters.*;   •  Parallel  compuRng  in  Services  using  GPars   •  Using  other  languages  like  Clojure  in  grails   •  …  
  8. 8. Performance  Concern?   •  User  Java  in  high  demanding  place   •  Gpars  (Actors,  map  reducer…)   •  Use  clojure  in  services   •  User  Scala  in  services   •  Yes.  It  is  AGILE!  
  9. 9. Clojure  Demo   •  grails  install-­‐plugin  clojure   •  New  dir  src/clj  is  created   •  Add  file  Addnumber.clj  in  src/clj   (ns  grails)   (def  twenty  20)   (defn  add_numbers  [a  b]          (+  a  b))  
  10. 10. Call  Clojure  from  Service   class  ClojService  {          boolean  transacRonal  =  false          def  addNumbers(x,  y)  {          clj.add_numbers(x,  y)          }        def  addTwenty(x)  {        clj.add_numbers(x,  clj.twenty)        }   }  
  11. 11. Call  Service  in  Controller   import  grails.converters.XML;   class  PlayController  {          def  index  =  {  }      def  clojService   def  cljaddnumber={                render  clojService.addNumbers(Integer.parseInt(params.a?:"5"),   Integer.parseInt(params.b?:"4"))      }      def  cljadd20={          render  clojService.addTwenty(Integer.parseInt(params.a?:"10"))      }   }  
  12. 12. Gpars  Map  Reducer  Demo   //@Grab(group='org.codehaus.gpars',  module='gpars',  version='0.9')   import  staRc  groovyx.gpars.Parallelizer.*   class  ConcurrentService  {          boolean  transacRonal  =  true          def  sqr()  {              def  myNumbers              doParallel{            myNumbers  =  (1..1000).parallel.filter{it  %  2  ==  0}.map{Math.sqrt   it}.collecRon              }              myNumbers          }  
  13. 13. Gpars  Map  Reducer  Demo   def  search(String  key,keys){            key+":"+  keys.replaceAll(key,key.toUpperCase())        /turns  key  to  upper  case      }      def  webs=["a  b  c  d  e  f  g  h  j  k  i  o  as  da  o  sa  ds  h  vcx  aw  s  dsf  gdsg    ds  ,  bbx   fdwvcx  786  ",  "b  sd  sd  sd  dsfgh  fds    ewr  56y    k  o  aw    n  q    12    g    n  1          uy  t  r",                      "sad  assa  sa  sa  sa  sa  456t465367  45  45  23  23  12      453  43  5  3  234  523  ",                      "8sdf  ds  5ue    we    123    42  hg    h  k      s  x  d  f    t  r  g  h  j    y  k  v    b  n    m  l  qw  ew  c"]      def  reducer(String  key)  {                def  rst          doParallel  {   rst  =  webs.parallel.map  {search(key,it)}.collecRon          }          rst      }}  

×