Introduction grails-es

33
NOT CONFIDENTIAL -- TELL EVERYONE Introducción a Grails Graeme Rocher SpringSource Friday, 30 September 2011

description

Introduction to Grails fullstack framework by Grame Rocher

Transcript of Introduction grails-es

Page 1: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Introducción a Grails

Graeme RocherSpringSource

Friday, 30 September 2011

Page 2: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

¿Que es Grails?

• MVC sistema web inspirado en:– Convención en lugar de configuración– Don’t Repeat Yourself (Nó te repitas) (DRY)– Contiene características de sistemas como Rails, Django y

TurboGears• http://grails.org

2

Friday, 30 September 2011

Page 3: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Why Groovy & Grails?

• Toda la potencia de otros sistemas con plataformas dinámicas.• Construido con base de tecnologías Java.

– Diseñado para Java por Ingenieros de Java.• Beneficiandose de tecnologías y herramientas existentes.

– Caches distribuidos, replicando tecnologías etc.– Monitorización y debugging herramientas– Análisis de rendimiento

3

Friday, 30 September 2011

Page 4: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Quien utiliza Grails?

4

Friday, 30 September 2011

Page 5: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Los Mejores en su clase

• Spring• Hibernate• Groovy• Quartz• Sitemesh• Tomcat• Java

5

Spring

Hibernate

QuartzJava

Sitemesh

Groovy

Friday, 30 September 2011

Page 6: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Componentes de Grails

6

The Java Virtual Machine

Groovy

Java Enterprise

Edition (JEE)Spring Hibernate SiteMesh

Grails

The Java LanguageThe Java Development

Kit (JDK)

Friday, 30 September 2011

Page 7: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 7

Como empezar

Descargar Grails dehttp://grails.org/DownloadDescomprimir el archivo zip en una carpeta del disco duroConfigurar la variable de enterno GRAILS_HOME haciendo referencia a la carpeta del punto anteriorAñadir a la variable PATH del sistema la carpeta$GRAILS_HOME/bin

Descargar Groovy dehttp://groovy.codehaus.orgDescomprimir el archivo zip en una carpeta del disco duroConfigurar la variable de enterno GROOVY_HOME haciendo referencia a la carpeta del punto anteriorAñadir a la variable PATH del sistema la carpeta$GROOVY_HOME/bin

Friday, 30 September 2011

Page 8: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Demo - Como Empezar

Friday, 30 September 2011

Page 9: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Ejemplo de estructura de carpetas

9

Web Controllers

The Domain Model

Business Logic

View Helpers in Tags

Views & Layouts

JAR Archives

Additional Sources

Web Resources

12

Friday, 30 September 2011

Page 10: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 10

Grails - Las Características Mas Importantes

GORM - ORM construido en HibernateMVC Completo“Domain Specific Languages”• Reglas de validación• “ORM Mapping”• “URL Mapping”

Comunidad de desarrollo de plugins activa.• http://grails.org/Plugins• Mas 600 plugins desarrallodos por los usuarios.• Existen plugins para integrar otras tecnologías

como Flex y SOAP.

Friday, 30 September 2011

Page 11: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 11

Fácil ORM con GORM

class Album { String title String artist Date releaseDate static hasMany = [songs:Song]}class Song { String title Double duration}

id title artist release_date

table - album

id title duration album_id

table - song

GORM classes, also known as domain classes, go in the domain directory

Friday, 30 September 2011

Page 12: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Demo - GORM

Friday, 30 September 2011

Page 13: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 13

Fácil MVC con Grails

Sistema MVC integral construido en Spring• “Command objects”• “Data binding”• “Zero configuration”• “URL Mappings”• “Groovy Server Pages (GSP) “• “Tag libraries”• “CRUD (Scaffolding)”• Internacionalización (i18n)

Friday, 30 September 2011

Page 14: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 14

class AlbumController {

def search = { def albums= Album.findByTitleLike("%${params.q}%")

[albumResults:albums] }}

Controllers go in the “controllers” directory

Actions are properties assigned a block or closure

Return a model as a map

Fácil MVC con Grails

Friday, 30 September 2011

Page 15: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Demo - Controllers

Friday, 30 September 2011

Page 16: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Plugins

16

Plugin Plugin Plugin Plugin

Grails Runtime Environment

GrailsApplication ApplicationContext

Read ConventionsRegister Bean Definitions

Friday, 30 September 2011

Page 17: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Que puedes obtener con plugins...

17

Friday, 30 September 2011

Page 18: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Que puedes obtener con plugins...

• Pruebas con Grails: selenium, fitnesse, code coverage etc.

17

Friday, 30 September 2011

Page 19: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Que puedes obtener con plugins...

• Pruebas con Grails: selenium, fitnesse, code coverage etc.

• JavaScript con Grails: Flex, GWT, ZK, jQuery etc.

17

Friday, 30 September 2011

Page 20: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Que puedes obtener con plugins...

• Pruebas con Grails: selenium, fitnesse, code coverage etc.

• JavaScript con Grails: Flex, GWT, ZK, jQuery etc.

• Seguridad con Grails: Spring Security, JSecurity, OpenID etc.

17

Friday, 30 September 2011

Page 21: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Que puedes obtener con plugins...

• Pruebas con Grails: selenium, fitnesse, code coverage etc.

• JavaScript con Grails: Flex, GWT, ZK, jQuery etc.

• Seguridad con Grails: Spring Security, JSecurity, OpenID etc.

• Persistencia: MongoDB, Redis, SimpleDB etc.

17

Friday, 30 September 2011

Page 22: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Página de Plugins

• http://grails.org/Plugins

18

Friday, 30 September 2011

Page 23: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Novedades en Grails 2.0

Friday, 30 September 2011

Page 24: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Grails 2.0

• Librerías actualizadas: Groovy 1.8, Spring 3.1, Hibernate 3.6, Servlet 3.0 and Tomcat 7

• Nueva línea de comandos y Modo Interactivo• Plugins precompilados como archivos JAR• Reloading Agent • HTML5 Scaffolding UI• Nuevos Modelos de Test y Documentación• Dirección de Archivos Estáticos Integrados (CSS,

JS, Images)• Mejor Testing.

20

Friday, 30 September 2011

Page 25: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Grails 2.0

• GORM Mejoras• “Detached Criteria”• Soporte de Multiples Bases De Datos • Soporte de Migración de Databases• jQuery Por Defecto• http://grails.org/doc/2.0.x/guide/

introduction.html#whatsNew

21

Friday, 30 September 2011

Page 26: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

New UI

22

Friday, 30 September 2011

Page 27: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

New Unit Testing

23

@TestFor(MyController)@Mock(Person)class MyControllerUnitTests { void setUp() { new Person(...).save() new Person(...).save() }

void testIndex() { def model = this.controller.index() ... }}

Friday, 30 September 2011

Page 28: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

GORM API

24

Friday, 30 September 2011

Page 29: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

GORM API

24

Friday, 30 September 2011

Page 30: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Demo - Grails 2.0

Friday, 30 September 2011

Page 31: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Libros

26

Friday, 30 September 2011

Page 32: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE 27

Mas Información

Grails• Pagina web: http://grails.org• Guia de usuario: http://grails.org/doc/latest

Groovy• http://groovy.codehaus.org

SpringSource• http://www.springsource.com

Friday, 30 September 2011

Page 33: Introduction grails-es

NOT CONFIDENTIAL -- TELL EVERYONE

Preguntas & Respuestas

Friday, 30 September 2011