Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Un poco más allá con       Grails          Daniel Latorre       dani@primerviernes.com     11/03/2011 – Madrid on Rails   ...
¿Quién?             Cofundador de Jobsket.com             Desarrollador independiente          Principalmente Grails/Groov...
¿Qué es Grails? Framework web para la plataforma Java “full stack”. Escritoen Groovy y Java utilizando como base varias he...
Principales características               de Groovy      Menos ceremonioso y más expresivo que Java        Todo es un obje...
Artefactos de Grails Clases de Dominio (GORM)         Servicios      Controladores      Vistas + layouts     Librerías de ...
Soporte I18N                 Un properties por Locale.         Cambio de idioma con /book/list?lang=en.<g:message code="my...
Externalizar configuraciones         Base de datos por JDNI. En el DataSoruce.groovy:dataSource {     jndiName = "java:com...
Plugins AutentificaciónSpring Security, casi indiscutible. También con soporte                 OpenID, LDAP, CAS          ...
Plugin REST ClientPara consumir servicios REST externos. Ejemplo:
Envío de emails        Mail Plugin, para envíos por SMTPPostmark Plugin, servicio que asegura la recepción.  Existen vario...
Lazy/eager loadingPor defecto los objetos relacionados se cargan de forma                       perezosa.        Podemos n...
Evitando el problema N+1                           La solución: fetch.                     A nivel de relaciones GORM:stat...
Caché de primer nivel de Hibernate  Caché de primer nivel para ahorrar tráfico en red y              aumentar la velocidad...
Caché de segundo nivel de                 HibernateSe cachea cada insancia de la clase de Dominio:static mapping = {    ca...
Caché de consultas de Hibernate    Es posible cachear queries indicándolo al ejecutar.     Habitual para consultas que se ...
¿Opciones para una política de       caché propia?                 EhCahe                 OSCahe                Memcache  ...
Caché de métodos de un Service         con SpringCache    Puede interesar cachear las llamadas al método de               ...
Caché de HTML con SpringCache  Cachear porciones de HTML es una práctica habitual.Para hacerlo se combina SpringCache y el...
Caché HTTP Podemos cachear a nivel de navegador jugando con las      cabeceras HTTP. Ahorrando tráfico y CPU. Con el plugi...
Caché de estáticos       Resources plugin: comprime .js/.cssCache-resources plugin: añade manejo de cacheo de             ...
Sistemas de mensajería  Hay que tratar quitar lo máximo de la request para mejorar la velocidad, la UX y facilitar la esca...
Optimizando para móviles  Es posible detectar si el navegador es un teléfono en elrequest.getHeader(user-agent). Para ahor...
Optimizando para móviles IIEn la parte de front, hay que optimizar también el html,     tamaño de ficheros estáticos, imág...
Algunos enlaces de interésPostmark, servicio de mailing: http://postmarkapp.com/Reading i18n messages from the database wi...
Upcoming SlideShare
Loading in …5
×

Un poco más allá con grails. PrimerViernes

3,178 views

Published on

Published in: Technology
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy &amp; Proven Way to Build Good Habits &amp; Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THI5 BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Un poco más allá con grails. PrimerViernes

  1. 1. Un poco más allá con Grails Daniel Latorre dani@primerviernes.com 11/03/2011 – Madrid on Rails PrimerVienes
  2. 2. ¿Quién? Cofundador de Jobsket.com Desarrollador independiente Principalmente Grails/Groovy/JavaGoogle Summer of Code 2008 y contribuidor Open Source Web: http://www.danilat.com/ CV: http://www.jobsket.es/cv/dani Twitter: @dani_latorre
  3. 3. ¿Qué es Grails? Framework web para la plataforma Java “full stack”. Escritoen Groovy y Java utilizando como base varias herramientas maduras(Spring, Hibernate, Tomcat...). CoC & DRY. Fuertemente inspirado en Ruby on Rails.
  4. 4. Principales características de Groovy Menos ceremonioso y más expresivo que Java Todo es un objeto (no hay tipos primitivos) Compilado o script Imports por defecto (java.util.*, java.io.*, java.net.*,java.math.BigDecimal, java.math.BigInteger, groovy.util.*) Compilación cruzada (Joint compilation) El GDK extiende a la JDKExpandos y MOP (añade y modifica atributos y métodos en tiempo de ejecución)
  5. 5. Artefactos de Grails Clases de Dominio (GORM) Servicios Controladores Vistas + layouts Librerías de tags Filtros Codecs
  6. 6. Soporte I18N Un properties por Locale. Cambio de idioma con /book/list?lang=en.<g:message code="my.localized.content" args="${[Juan]}"/> message(code:"my.localized.content", args:[Juan]) Podemos inyectar messageSoruce de Spring en cualquier parte.Usando Spring podemos incluso modificar el origen de datos del messageSoruce.
  7. 7. Externalizar configuraciones Base de datos por JDNI. En el DataSoruce.groovy:dataSource { jndiName = "java:comp/env/myDS"} Configuración del Config.groovy: grails.config.locations = [ "classpath:${appName}-config.groovy","file:$ {userHome}/.grails/${appName}-config.groovy"]
  8. 8. Plugins AutentificaciónSpring Security, casi indiscutible. También con soporte OpenID, LDAP, CAS Facebook Connect OAuth Solución Do It Yourself
  9. 9. Plugin REST ClientPara consumir servicios REST externos. Ejemplo:
  10. 10. Envío de emails Mail Plugin, para envíos por SMTPPostmark Plugin, servicio que asegura la recepción. Existen varios plugins con más funcionalidades
  11. 11. Lazy/eager loadingPor defecto los objetos relacionados se cargan de forma perezosa. Podemos necesitar una session diferente al OpenSessionInView de Grails/Springstatic mapping = { books lazy: false} NO evitamos el problema de N + 1 queries.
  12. 12. Evitando el problema N+1 La solución: fetch. A nivel de relaciones GORM:static mapping = { books fetch: join} En las consultas:Author.findAllByNameLike("John%", [fetch: [location: join] ])
  13. 13. Caché de primer nivel de Hibernate Caché de primer nivel para ahorrar tráfico en red y aumentar la velocidad. Sin flush:true en save o delete, no se persisten loscambios hasta que hibernate ejecute el próximo select.
  14. 14. Caché de segundo nivel de HibernateSe cachea cada insancia de la clase de Dominio:static mapping = { cache read-only // cache true}read-only: Si los datos son sólo lectura.non-strict-read-write: Para pocas actualizaciones, no asegura si variastransacciones modifican la misma instancia.read-write: Actualizaciones frecuentes. Al modificar se actualiza encache, no soporta transacciones y pueden surgir inconsistencias.transactional: Necesita un proveedor que lo soporte(JBoss TreeCache)
  15. 15. Caché de consultas de Hibernate Es posible cachear queries indicándolo al ejecutar. Habitual para consultas que se repitan de forma constantedef person = Person.findByFirstName("Fred", [cache:true])
  16. 16. ¿Opciones para una política de caché propia? EhCahe OSCahe Memcache JBoss Cache Terracota ¿Bases de datos NoSQL?: Redis, Mongo...
  17. 17. Caché de métodos de un Service con SpringCache Puede interesar cachear las llamadas al método de algún Service.@Cacheable("pirateCache")def getPirates() {...}@CacheFlush("pirateCache")void registerNewPirate(Pirate pirate) {...}
  18. 18. Caché de HTML con SpringCache Cachear porciones de HTML es una práctica habitual.Para hacerlo se combina SpringCache y el tag include en las vistas.@Cacheable("albumControllerCache") def list = {...}@CacheFlush("albumControllerCache") def save = {...}
  19. 19. Caché HTTP Podemos cachear a nivel de navegador jugando con las cabeceras HTTP. Ahorrando tráfico y CPU. Con el plugin Caching Headers, antes de los renders de losactions a cachear:cache shared:true, validFor: 3600 // 1hr on contentcache shared: true, validUntil: new Date()+1lastModified book.dateUpdateHay disponible también un DSL con withCacheHeaders, para permitirmás flexibilidad.
  20. 20. Caché de estáticos Resources plugin: comprime .js/.cssCache-resources plugin: añade manejo de cacheo de estáticos al navegador.
  21. 21. Sistemas de mensajería Hay que tratar quitar lo máximo de la request para mejorar la velocidad, la UX y facilitar la escalabilidad. JMS Plugin. Java Message ServiceRabbit MQ Plugin. Advanced Message Queuing Protocol Jabber Plugin.Solución Do It Yourself(Con quartz o java.util.concurrent)
  22. 22. Optimizando para móviles Es posible detectar si el navegador es un teléfono en elrequest.getHeader(user-agent). Para ahorrar ese trabajo manual, SpringMobile.def list = { withMobileDevice {def device -> if(device.id.contains("iphone"){ render(view: "iphoneList", model: [list: listInstance]) } render(view: "mobileList", model: [list: listInstance]) } render(view: "list", model: [list: listInstance])}
  23. 23. Optimizando para móviles IIEn la parte de front, hay que optimizar también el html, tamaño de ficheros estáticos, imágenes, etc.Para smartphones, HTML5: Soporte de geolocalización, Web Database...Librerías Javascript que pueden ayudar: Sencha Touch o jQuery Mobile.
  24. 24. Algunos enlaces de interésPostmark, servicio de mailing: http://postmarkapp.com/Reading i18n messages from the database with Grails: http://1vm.es/000KSpringSecurity with SpringCache: Caching content per user: http://1vm.es/000LLocalizable plugin: https://github.com/danilat/localizable

×