Introduction a Groovy

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Introduction a Groovy - Presentation Transcript

    1. Introducción a Groovy Un lenguaje dinámico para la JVM
    2. Agenda
      • Que es Groovy
      • Caracteristicas Lenguaje Groovy
      • Sintaxis en Groovy
      • Comunidad Groovy
      • Laboratorios (1-13)
    3. 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. Agenda
      • Que es Groovy
      • Caracteristicas Lenguaje Groovy
      • Sintaxis en Groovy
      • Comunidad Groovy
      • Laboratorios (1-12)
    5. 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 de 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. Agenda
      • Que es Groovy
      • Caracteristicas de Groovy
      • Sintaxis en Groovy
      • Comunidad Groovy
      • Laboratorios (1-12)
    7. 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. Agenda
      • Que es Groovy
      • Caracteristicas de Groovy
      • Sintaxis en Groovy
      • Comunidad Groovy
      • Laboratorios (1-12)
    9. 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. 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. Agenda
      • Que es Groovy
      • Caracteristicas de Groovy
      • Sintaxis en Groovy
      • Recursos
      • Laboratorios (1-12)
    12. 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. Laboratorios Un lenguaje dinámico para la JVM
    14. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Labs 05 – GString
      • class Noticia {
      • def titulo
      • def cuerpo
      • def publicar() {
      • return “ ””
      • ${titulo}
      • ${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.publicar() )
      • }
      • }
    29. Labs 05 – GString
      • class Noticia {
      • def titulo
      • def cuerpo
      • def publicar() {
      • return “ ””
      • ${title}
      • ${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.publicar() )
      • }
      • }
    30. Labs 05 – GString
      • class Noticia {
      • def titulo
      • def cuerpo
      • def publicar() {
      • return “ ””
      • ${titulo}
      • ${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.publicar() }”
      • }
      • }
    31. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. Labs 12- GroovyServlet
      • <?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
      • <web-app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot;
      • xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      • xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd&quot;
      • version=&quot;2.4&quot;>
      • <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. 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. 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. Gracias!
    SlideShare Zeitgeist 2009

    + Alex  FuentesAlex Fuentes Nominate

    custom

    143 views, 0 favs, 0 embeds more stats

    Groovy nos entrega una nueva generación de lenguaj more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 143
      • 143 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 7
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags