SlideShare una empresa de Scribd logo
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Introducción a Groovy
Un lenguaje dinámico para la JVM
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Agenda
• Que es Groovy
• Caracteristicas Lenguaje Groovy
• Sintaxis en Groovy
• Comunidad Groovy
• Laboratorios (1-13)
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinámicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Agenda
• Que es Groovy
• Caracteristicas Lenguaje Groovy
• Sintaxis en Groovy
• Comunidad Groovy
• Laboratorios (1-12)
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Que es Groovy?
• Groovy es un agil y dinámico lenguaje para la Java
Virtual Machine
• Construido pensando en Java pero adicionando las
poderosas caracteristicas de lenguajes como Python,
Ruby & Smalltalk.
• Entregas atractivas caracteristicas disponibles para los
desarrolladores de Java con una pequeña curva depequeña curva de
aprendizaje.aprendizaje.
• Soporta Domain Specific Languages y otras
sintaxis compactas que facilitan tanto la lectura como
la mantencion del codigo.
• Permite la integracion con todo los Objetos y librerias
existentes desarrolladas en Java.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Agenda
• Que es Groovy
• Caracteristicas de Groovy
• Sintaxis en Groovy
• Comunidad Groovy
• Laboratorios (1-12)
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Caracteristicas de Groovy
• Closures
• Sintaxis nativa para List y Maps
• Soporte para GroovyMarkup y GPath
• Soporte nativo para expresiones regulares
• Soporte para tipificación dinámica y estática.
• Soporta embeber expresiones dentro de string
• Una gran cantidad de Metodos agregados al JDK.
• Simple sintaxis para escribir Beans ( getter y setter )
• Soporte para Anotaciones y Genericos
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Agenda
• Que es Groovy
• Caracteristicas de Groovy
• Sintaxis en Groovy
• Comunidad Groovy
• Laboratorios (1-12)
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Sintaxis en Groovy
• La keyword para la definición de variables es def
• Los punto y coma al final de las sentencias son opcionales
 println x
 def y = 5; def x = y + 7
• Las declaraciones puede ir en varias lineas
• Los comentarios para una linea con el caracter // ....
• Los comentarios para varias lineas son con el caracter /* ... */
• La sentencia return es opcional
• Los parentesis son opcionales
• Soporta el paso de parametros con nombre en las invocaciones
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Sintaxis en Groovy
• Metodos y Clases en Groovy por defecto son public.
• La palabra in es keyword
• La palabra as es keyword
• Se realizan import por default
 * java.io.*
 * java.lang.*
 * java.math.BigDecimal
 * java.math.BigInteger
 * java.net.*
 * java.util.*
 * groovy.lang.*
 * groovy.util.*
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Agenda
• Que es Groovy
• Caracteristicas de Groovy
• Sintaxis en Groovy
• Recursos
• Laboratorios (1-12)
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Recursos
• Groovy Language, guides, examples
 http://groovy.codehaus.org
• Groovy Eclipse Plugin
 http://groovy.codehaus.org/Eclipse+Plugin
• Groovy Related News
 http://aboutgroovy.com
 http://groovyblogs.org
 http://groovy.dzone.com
• Andres Almiray’s Groovy Commiter
http://jroller.com/aalmiray
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
Un lenguaje dinámico para la JVM
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Lab 01 – Instalación de Groovy ( Linux y Windows)
• Download Groovy 1.5.6 stable
• http://groovy.codehaus.org/Download
• Linux
Ubuntu/Debian http://dist.codehaus.org/groovy/distributions/installers/deb/groovy-1.5.6.deb
Install
# sudo dpkg –install groovy-1.5.6.deb
# groovy -version
Groovy Version: 1.5.6 JVM: 1.5.0_14-b03
• Windows
 http://dist.codehaus.org/groovy/distributions/installers/windows/nsis/groovy-1.5.6-installer.exe
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Lab 01 – Instalación de Groovy ( Linux y Windows)
• GroovyConsole ( Consola Gráfica de Groovy )
print “hola” Ctrl + R
• groovysh ( Consola de Groovy )
print “hola” Enter
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Lab 02 – Eclipse y Groovy Plug-in
• Eclipse 3.3.1
Help >> Software Update >> Find and Install
* Search for new feature for install
• Plug-in site
http://dist.codehaus.org/groovy/distributions/update/
• Detalles
http://docs.codehaus.org/download/attachments/2744/Groovy_Installation_Eclipse_Plugin.pdf?version=1
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 03 – Hola Mundo
class HelloWorld {
String name
String greet()
{ return "Hello "+ name }
static void main( args ){
HelloWorld helloWorld = new HelloWorld()
helloWorld.setName("Groovy")
println( helloWorld.greet() )
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 04 – Tipos dinámicos
• Utiliza el operador def , cuando no necesites tipificar la variable a utilizar.
( def es el equivalente al operador var en JavaScript)
• Groovy utilizara el tipo correcto para la variable.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 04 – Tipos dinámicos
class HelloWorld {
def name
def greet()
{ return "Hello "+ name }
static void main( args ){
def helloWorld = new HelloWorld()
helloWorld.setName("Groovy")
println( helloWorld.greet() )
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 04 – Tipos dinámicos
class Calculadora {
def suma(a,b)
{ return a+b }
def resta(a,b)
{ return a-b }
static void main( args ){
def calculadora = new Calculadora()
println calculadora.suma(5,5)
println calculadora.resta(5,5)
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 05 - GString
• Groovy soporta la capacidad de incrustar variables dentro de
String
• Capacidad de definir bloques de String entre los caracteres
“”” …. “””
• Capacidad de invocar APIs dentro de String
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 05 – GString
class HelloWorld {
def name
def greet()
{ return "Hello ${name}" }
static void main( args ){
def helloWorld = new HelloWorld()
helloWorld.setName("Groovy")
println( helloWorld.greet() )
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 05 – GString
class Noticia {
def titulo
def cuerpo
def publicar() {
return “””
t ${titulo} n
t t ${cuerpo} n
“””
}
static void main( args ){
def noticia = new Noticia()
noticia.setTitulo(“Liberacion de Groovy")
noticia.setCuerpo(“Se libero la version 1.5.6 ")
println( noticia.publicar() )
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 05 – GString
class Noticia {
def titulo
def cuerpo
def publicar() {
return “””
t ${title} n
t t ${cuerpo} n
“”” }
static void main( args ){
def noticia = new Noticia()
noticia.setTitulo(“Liberacion de Groovy")
noticia.setCuerpo(“Se libero la version 1.5.6 ")
println( noticia.publicar() )
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 05 – GString
class Noticia {
def titulo
def cuerpo
def publicar() {
return “””
t ${titulo} n
t t ${cuerpo} n
“””
}
static void main( args ){
def noticia = new Noticia()
noticia.setTitulo(“Liberacion de Groovy")
noticia.setCuerpo(“Se libero la version 1.5.6 ")
println “${noticia.publicar()}”
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 06 – POGOs
class Noticia {
def titulo
def cuerpo
static void main( args ){
def noticia = new Noticia()
noticia.setTitulo(“Liberacion de Groovy”)
noticia.setCuerpo(“Se libero la version 1.5.6 “)
println “${noticia.getTitulo()}”
println “${noticia.getCuerpo()}”
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 06 – POGOs
class Noticia {
def titulo
def cuerpo
static void main( args ){
def noticia = new Noticia()
noticia.titulo = “Liberacion de Groovy”
noticia.cuerpo = “Se libero la version 1.5.6 “
println “${noticia.titulo}”
println “${noticia.cuerpo}”
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 06 – POGOs
class Noticia {
def titulo
def cuerpo
static void main( args ){
def noticia = new Noticia(titulo: “Liberacion de Groovy”,
cuerpo: “Se libero la version 1.5.6“)
println “${noticia.titulo}”
println “${noticia.cuerpo}”
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 07 - Closures
• Bloque de código anónimo definido entre llaves, el cual toma
argumentos y retorna valor.
• Si se omite el nombre del argumento , este recibe el nombre de it
• Los Closures siempre generan un return ,la cual sera por defecto
la ultima sentencia evaluada.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 06 – Closures
class Noticia {
def titulo
def cuerpo
static void main( args ){
def salida = { println it }
def noticia = new Noticia(titulo: “Liberacion de Groovy”,
cuerpo: “Se libero la version 1.5.6“)
salida( “${noticia.titulo}”)
salida( “${noticia.cuerpo}”)
}
}
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 08 –Operadores
• ?: (elvis) - Una redifinicion del ternary operator
• ?. Safe dereference – Navegando por un objeto sin tener la
preocupacion de obtener un NullPointerException.
• <=> (spaceship) – Comparacion de dos valores con un retorno a
boolean.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 10 – GroovyMarkup y GPath
• Groovy tiene un sorpote para varios tipos de
lenguajes de marcas como lo son : XML, HTML, SAX,
W3C DOM, Ant tasks.
• GPath define una sintaxis para la navegacion por
estructuras de datos.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramación
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 11 – Metaprogramación
• Escribir programas que escriben o manipulan a otros programas
o a si mismos.
• Soporte para agregar metodos y propiedades a un objeto en
runtime.
• Soporte para interceptar llamadas a metodos, simulando algo parecido a
AOP.
• Groovy extiende clases como String y Integer con nuevos metodos, esto
es conocido con el nombre de GDK.
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 12- GroovyServlet
• Permite el desarrollo de Servlet en formato de script
• Se pueder realizar cambios sin tener que reiniciar el server
• No es necesario parsar por un proceso de compilacion
• Utilies para el desarrollo de prototipos o funcionalidades
acotadas
• Se realiza el binding de una serie de objetos para faciliar el uso
dentro del scope de Groovy
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 12- GroovyServlet
• request - the HttpServletRequest
• response - the HttpServletResponse
• application - the ServletContext associated with the servlet
• session - the HttpSession associated with the HttpServletRequest
• out - the PrintWriter associated with the ServletRequest
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 12- GroovyServlet
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>GroovyAction</servlet-name>
<servlet-class>groovy.servlet.GroovyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GroovyAction</servlet-name>
<url-pattern>/action/*</url-pattern>
</servlet-mapping>
</web-app>
http://www.jroller.com/afuentes/entry/groovyservlet_ejemplo
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Laboratorios
• Lab 01 – Instalación de Groovy ( Linux and Windows )
• Lab 02 - Eclipse y Groovy Plug-ins
• Lab 03 - Hola Mundo
• Lab 04 - Tipos dinamicos
• Lab 05 - GString
• Lab 06 - POGOs
• Lab 07 - Closures
• Lab 08 - Operadores
• Lab 09 - List y Map y iteradores
• Lab 10 - GroovyMarkup y GPath
• Lab 11 - Metaprogramacion
• Lab 12 - GroovyServlet
• Lab 13 - Gsql
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Labs 13 - GSql
• API que permite todo el manejo de Acceso a Base de Datos en
forma facil
• Permite la generacion de select en pocas lineas de codigos
Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0
Gracias!

Más contenido relacionado

PDF
Migrando CI a Docker
PDF
05 intro-git-github-heroku-v4
PDF
Herramientas de trabajo para entorno LAMP
PDF
Uso practico de git
PDF
Introducción a git
PDF
Mini-tutorial de git
PDF
WorkShop: Introducción a GIT
ODP
Uso de git (Cursos de e-ghost 2011)
Migrando CI a Docker
05 intro-git-github-heroku-v4
Herramientas de trabajo para entorno LAMP
Uso practico de git
Introducción a git
Mini-tutorial de git
WorkShop: Introducción a GIT
Uso de git (Cursos de e-ghost 2011)

La actualidad más candente (13)

PDF
Introducción a Git (Git 101)
PDF
Git para-principiantes
PDF
Git with Scrum en español
PDF
Introducción a Git
PPTX
Git: un enfoque práctico
PPTX
Git: flujos de trabajo y herramientas para trabajo colaborativo
PDF
El git nuestro de cada dia
PPTX
Git / Guía Básica
PPTX
Introducción a git y git hub
ODP
Taller breve de introduccion a Git
PDF
Tallerintroducciongit
PPTX
Configurando un repositorio de git hub usando netbeans ide
PDF
Git git hub
Introducción a Git (Git 101)
Git para-principiantes
Git with Scrum en español
Introducción a Git
Git: un enfoque práctico
Git: flujos de trabajo y herramientas para trabajo colaborativo
El git nuestro de cada dia
Git / Guía Básica
Introducción a git y git hub
Taller breve de introduccion a Git
Tallerintroducciongit
Configurando un repositorio de git hub usando netbeans ide
Git git hub
Publicidad

Similar a Introduction a Groovy (20)

PPT
Introducción a Grails
KEY
Taller Groovy
PPT
Grails en Expo FISI 2011
PPT
Introduccion A Groovy
PDF
Introducción a Groovy
PDF
Introduccion a Groovy
PDF
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
PDF
Madrid-GUG (Alicante) 2017 - De Java a Groovy: ¡Hora de Aventuras!
ZIP
grails.org.mx Primera Reunion
PDF
Codemotion Madrid 2016 - De Java a Groovy: ¡Hora de Aventuras!
PDF
Seminario de Groovy y grails
PPT
Realizando Pruebas en la JVM con Velocidad y Eficacia
PPTX
Introduccion a grails en Campusparty
PPT
Introducción a Groovy
PDF
Groovy&Grails: Cambia la forma de desarrollar tus aplicaciones web
PDF
Cambia la forma de desarrollar tus aplicaciones web con groovy y grails
PDF
Programación Políglota en la JVM
Introducción a Grails
Taller Groovy
Grails en Expo FISI 2011
Introduccion A Groovy
Introducción a Groovy
Introduccion a Groovy
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
Madrid-GUG (Alicante) 2017 - De Java a Groovy: ¡Hora de Aventuras!
grails.org.mx Primera Reunion
Codemotion Madrid 2016 - De Java a Groovy: ¡Hora de Aventuras!
Seminario de Groovy y grails
Realizando Pruebas en la JVM con Velocidad y Eficacia
Introduccion a grails en Campusparty
Introducción a Groovy
Groovy&Grails: Cambia la forma de desarrollar tus aplicaciones web
Cambia la forma de desarrollar tus aplicaciones web con groovy y grails
Programación Políglota en la JVM
Publicidad

Último (20)

PPTX
modulo seguimiento 1 para iniciantes del
PPTX
CLAASIFICACIÓN DE LOS ROBOTS POR UTILIDAD
PDF
MANUAL TECNOLOGÍA SER MINISTERIO EDUCACIÓN
PDF
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
PDF
CyberOps Associate - Cisco Networking Academy
PDF
Diapositiva proyecto de vida, materia catedra
PDF
Documental Beyond the Code (Dossier Presentación - 2.0)
PDF
informe_fichas1y2_corregido.docx (2) (1).pdf
PPTX
Power Point Nicolás Carrasco (disertación Roblox).pptx
DOCX
TRABAJO GRUPAL (5) (1).docxjsjsjskskksksk
PPTX
Historia Inteligencia Artificial Ana Romero.pptx
PPTX
historia_web de la creacion de un navegador_presentacion.pptx
PPTX
Mecanismos-de-Propagacion de ondas electromagneticas
PDF
Distribucion de frecuencia exel (1).pdf
PPTX
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
PPTX
Acronis Cyber Protect Cloud para Ciber Proteccion y Ciber Seguridad LATAM - A...
PPTX
unidad 3 tecnología 8° básico: planificación y elaboración de un objeto
PDF
Instrucciones simples, respuestas poderosas. La fórmula del prompt perfecto.
PPTX
la-historia-de-la-medicina Edna Silva.pptx
PDF
PRESENTACIÓN GENERAL MIPIG - MODELO INTEGRADO DE PLANEACIÓN
modulo seguimiento 1 para iniciantes del
CLAASIFICACIÓN DE LOS ROBOTS POR UTILIDAD
MANUAL TECNOLOGÍA SER MINISTERIO EDUCACIÓN
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
CyberOps Associate - Cisco Networking Academy
Diapositiva proyecto de vida, materia catedra
Documental Beyond the Code (Dossier Presentación - 2.0)
informe_fichas1y2_corregido.docx (2) (1).pdf
Power Point Nicolás Carrasco (disertación Roblox).pptx
TRABAJO GRUPAL (5) (1).docxjsjsjskskksksk
Historia Inteligencia Artificial Ana Romero.pptx
historia_web de la creacion de un navegador_presentacion.pptx
Mecanismos-de-Propagacion de ondas electromagneticas
Distribucion de frecuencia exel (1).pdf
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
Acronis Cyber Protect Cloud para Ciber Proteccion y Ciber Seguridad LATAM - A...
unidad 3 tecnología 8° básico: planificación y elaboración de un objeto
Instrucciones simples, respuestas poderosas. La fórmula del prompt perfecto.
la-historia-de-la-medicina Edna Silva.pptx
PRESENTACIÓN GENERAL MIPIG - MODELO INTEGRADO DE PLANEACIÓN

Introduction a Groovy

  • 1. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Introducción a Groovy Un lenguaje dinámico para la JVM
  • 2. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Agenda • Que es Groovy • Caracteristicas Lenguaje Groovy • Sintaxis en Groovy • Comunidad Groovy • Laboratorios (1-13)
  • 3. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinámicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 4. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Agenda • Que es Groovy • Caracteristicas Lenguaje Groovy • Sintaxis en Groovy • Comunidad Groovy • Laboratorios (1-12)
  • 5. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Que es Groovy? • Groovy es un agil y dinámico lenguaje para la Java Virtual Machine • Construido pensando en Java pero adicionando las poderosas caracteristicas de lenguajes como Python, Ruby & Smalltalk. • Entregas atractivas caracteristicas disponibles para los desarrolladores de Java con una pequeña curva depequeña curva de aprendizaje.aprendizaje. • Soporta Domain Specific Languages y otras sintaxis compactas que facilitan tanto la lectura como la mantencion del codigo. • Permite la integracion con todo los Objetos y librerias existentes desarrolladas en Java.
  • 6. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Agenda • Que es Groovy • Caracteristicas de Groovy • Sintaxis en Groovy • Comunidad Groovy • Laboratorios (1-12)
  • 7. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Caracteristicas de Groovy • Closures • Sintaxis nativa para List y Maps • Soporte para GroovyMarkup y GPath • Soporte nativo para expresiones regulares • Soporte para tipificación dinámica y estática. • Soporta embeber expresiones dentro de string • Una gran cantidad de Metodos agregados al JDK. • Simple sintaxis para escribir Beans ( getter y setter ) • Soporte para Anotaciones y Genericos
  • 8. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Agenda • Que es Groovy • Caracteristicas de Groovy • Sintaxis en Groovy • Comunidad Groovy • Laboratorios (1-12)
  • 9. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Sintaxis en Groovy • La keyword para la definición de variables es def • Los punto y coma al final de las sentencias son opcionales  println x  def y = 5; def x = y + 7 • Las declaraciones puede ir en varias lineas • Los comentarios para una linea con el caracter // .... • Los comentarios para varias lineas son con el caracter /* ... */ • La sentencia return es opcional • Los parentesis son opcionales • Soporta el paso de parametros con nombre en las invocaciones
  • 10. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Sintaxis en Groovy • Metodos y Clases en Groovy por defecto son public. • La palabra in es keyword • La palabra as es keyword • Se realizan import por default  * java.io.*  * java.lang.*  * java.math.BigDecimal  * java.math.BigInteger  * java.net.*  * java.util.*  * groovy.lang.*  * groovy.util.*
  • 11. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Agenda • Que es Groovy • Caracteristicas de Groovy • Sintaxis en Groovy • Recursos • Laboratorios (1-12)
  • 12. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Recursos • Groovy Language, guides, examples  http://groovy.codehaus.org • Groovy Eclipse Plugin  http://groovy.codehaus.org/Eclipse+Plugin • Groovy Related News  http://aboutgroovy.com  http://groovyblogs.org  http://groovy.dzone.com • Andres Almiray’s Groovy Commiter http://jroller.com/aalmiray
  • 13. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios Un lenguaje dinámico para la JVM
  • 14. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 15. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Lab 01 – Instalación de Groovy ( Linux y Windows) • Download Groovy 1.5.6 stable • http://groovy.codehaus.org/Download • Linux Ubuntu/Debian http://dist.codehaus.org/groovy/distributions/installers/deb/groovy-1.5.6.deb Install # sudo dpkg –install groovy-1.5.6.deb # groovy -version Groovy Version: 1.5.6 JVM: 1.5.0_14-b03 • Windows  http://dist.codehaus.org/groovy/distributions/installers/windows/nsis/groovy-1.5.6-installer.exe
  • 16. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Lab 01 – Instalación de Groovy ( Linux y Windows) • GroovyConsole ( Consola Gráfica de Groovy ) print “hola” Ctrl + R • groovysh ( Consola de Groovy ) print “hola” Enter
  • 17. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 18. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Lab 02 – Eclipse y Groovy Plug-in • Eclipse 3.3.1 Help >> Software Update >> Find and Install * Search for new feature for install • Plug-in site http://dist.codehaus.org/groovy/distributions/update/ • Detalles http://docs.codehaus.org/download/attachments/2744/Groovy_Installation_Eclipse_Plugin.pdf?version=1
  • 19. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 20. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 03 – Hola Mundo class HelloWorld { String name String greet() { return "Hello "+ name } static void main( args ){ HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") println( helloWorld.greet() ) } }
  • 21. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 22. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 04 – Tipos dinámicos • Utiliza el operador def , cuando no necesites tipificar la variable a utilizar. ( def es el equivalente al operador var en JavaScript) • Groovy utilizara el tipo correcto para la variable.
  • 23. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 04 – Tipos dinámicos class HelloWorld { def name def greet() { return "Hello "+ name } static void main( args ){ def helloWorld = new HelloWorld() helloWorld.setName("Groovy") println( helloWorld.greet() ) } }
  • 24. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 04 – Tipos dinámicos class Calculadora { def suma(a,b) { return a+b } def resta(a,b) { return a-b } static void main( args ){ def calculadora = new Calculadora() println calculadora.suma(5,5) println calculadora.resta(5,5) } }
  • 25. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 26. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 05 - GString • Groovy soporta la capacidad de incrustar variables dentro de String • Capacidad de definir bloques de String entre los caracteres “”” …. “”” • Capacidad de invocar APIs dentro de String
  • 27. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 05 – GString class HelloWorld { def name def greet() { return "Hello ${name}" } static void main( args ){ def helloWorld = new HelloWorld() helloWorld.setName("Groovy") println( helloWorld.greet() ) } }
  • 28. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 05 – GString class Noticia { def titulo def cuerpo def publicar() { return “”” t ${titulo} n t t ${cuerpo} n “”” } static void main( args ){ def noticia = new Noticia() noticia.setTitulo(“Liberacion de Groovy") noticia.setCuerpo(“Se libero la version 1.5.6 ") println( noticia.publicar() ) } }
  • 29. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 05 – GString class Noticia { def titulo def cuerpo def publicar() { return “”” t ${title} n t t ${cuerpo} n “”” } static void main( args ){ def noticia = new Noticia() noticia.setTitulo(“Liberacion de Groovy") noticia.setCuerpo(“Se libero la version 1.5.6 ") println( noticia.publicar() ) } }
  • 30. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 05 – GString class Noticia { def titulo def cuerpo def publicar() { return “”” t ${titulo} n t t ${cuerpo} n “”” } static void main( args ){ def noticia = new Noticia() noticia.setTitulo(“Liberacion de Groovy") noticia.setCuerpo(“Se libero la version 1.5.6 ") println “${noticia.publicar()}” } }
  • 31. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 32. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 06 – POGOs class Noticia { def titulo def cuerpo static void main( args ){ def noticia = new Noticia() noticia.setTitulo(“Liberacion de Groovy”) noticia.setCuerpo(“Se libero la version 1.5.6 “) println “${noticia.getTitulo()}” println “${noticia.getCuerpo()}” } }
  • 33. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 06 – POGOs class Noticia { def titulo def cuerpo static void main( args ){ def noticia = new Noticia() noticia.titulo = “Liberacion de Groovy” noticia.cuerpo = “Se libero la version 1.5.6 “ println “${noticia.titulo}” println “${noticia.cuerpo}” } }
  • 34. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 06 – POGOs class Noticia { def titulo def cuerpo static void main( args ){ def noticia = new Noticia(titulo: “Liberacion de Groovy”, cuerpo: “Se libero la version 1.5.6“) println “${noticia.titulo}” println “${noticia.cuerpo}” } }
  • 35. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 36. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 07 - Closures • Bloque de código anónimo definido entre llaves, el cual toma argumentos y retorna valor. • Si se omite el nombre del argumento , este recibe el nombre de it • Los Closures siempre generan un return ,la cual sera por defecto la ultima sentencia evaluada.
  • 37. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 06 – Closures class Noticia { def titulo def cuerpo static void main( args ){ def salida = { println it } def noticia = new Noticia(titulo: “Liberacion de Groovy”, cuerpo: “Se libero la version 1.5.6“) salida( “${noticia.titulo}”) salida( “${noticia.cuerpo}”) } }
  • 38. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 39. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 08 –Operadores • ?: (elvis) - Una redifinicion del ternary operator • ?. Safe dereference – Navegando por un objeto sin tener la preocupacion de obtener un NullPointerException. • <=> (spaceship) – Comparacion de dos valores con un retorno a boolean.
  • 40. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 41. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 42. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 10 – GroovyMarkup y GPath • Groovy tiene un sorpote para varios tipos de lenguajes de marcas como lo son : XML, HTML, SAX, W3C DOM, Ant tasks. • GPath define una sintaxis para la navegacion por estructuras de datos.
  • 43. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramación • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 44. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 11 – Metaprogramación • Escribir programas que escriben o manipulan a otros programas o a si mismos. • Soporte para agregar metodos y propiedades a un objeto en runtime. • Soporte para interceptar llamadas a metodos, simulando algo parecido a AOP. • Groovy extiende clases como String y Integer con nuevos metodos, esto es conocido con el nombre de GDK.
  • 45. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 46. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 12- GroovyServlet • Permite el desarrollo de Servlet en formato de script • Se pueder realizar cambios sin tener que reiniciar el server • No es necesario parsar por un proceso de compilacion • Utilies para el desarrollo de prototipos o funcionalidades acotadas • Se realiza el binding de una serie de objetos para faciliar el uso dentro del scope de Groovy
  • 47. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 12- GroovyServlet • request - the HttpServletRequest • response - the HttpServletResponse • application - the ServletContext associated with the servlet • session - the HttpSession associated with the HttpServletRequest • out - the PrintWriter associated with the ServletRequest
  • 48. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 12- GroovyServlet <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>GroovyAction</servlet-name> <servlet-class>groovy.servlet.GroovyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>GroovyAction</servlet-name> <url-pattern>/action/*</url-pattern> </servlet-mapping> </web-app> http://www.jroller.com/afuentes/entry/groovyservlet_ejemplo
  • 49. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Laboratorios • Lab 01 – Instalación de Groovy ( Linux and Windows ) • Lab 02 - Eclipse y Groovy Plug-ins • Lab 03 - Hola Mundo • Lab 04 - Tipos dinamicos • Lab 05 - GString • Lab 06 - POGOs • Lab 07 - Closures • Lab 08 - Operadores • Lab 09 - List y Map y iteradores • Lab 10 - GroovyMarkup y GPath • Lab 11 - Metaprogramacion • Lab 12 - GroovyServlet • Lab 13 - Gsql
  • 50. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Labs 13 - GSql • API que permite todo el manejo de Acceso a Base de Datos en forma facil • Permite la generacion de select en pocas lineas de codigos
  • 51. Introduccion a Groovy | © 2008 by «Alex Fuentes»; made available under the GPL v1.0 Gracias!