Grails 0.3-SNAPSHOT Presentation WJAX 2006

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

    Grails 0.3-SNAPSHOT Presentation WJAX 2006 - Presentation Transcript

    1. GRAILS
        • RAPID WEB APPLICATION DEVELOPMENT MADE EASY
    2. about: Sven Haiges
      • Actionality Deutschland GmbH
      • Java EE / ME Entwickler
      • Diplom-Informatiker (FH), MBA
      • Meine „Framework-Evolution“: Struts, JSF, Spring MVC, GRAILS
      • Seit August 2006: Grails Podcast, Grails Screencasts
    3. Ziele
      • Was steckt hinter Grails, wie erzeuge ich meine erste App?
      • Welche Technologien verbergen sich hinter Grails?
      • Welche Features sind in Grails enthalten?
      • Infos zu weiteren Ressourcen
    4. Agenda Basics Grails Foundations MVC Features Roadmap Weitere Infos, Tipps
    5. Grails Basics
    6. Grails MVC
      • Grails ist ein MVC Web Framework
        • Inspiriert von Ruby on Rails
        • Benutzt die mächtige Groovy Scriptsprache
        • „ Convention Over Configuration”
        • „ Don't Repeat Yourself“ (DRY)
    7. Grails History & Team
      • Entstand aus E-Mail Diskussion: Guillaume LaForge, Steven Devijver and Graeme Rocher (aktueller Project Lead)
      • 0.1 am 29. März, 2006
      • Aktuelles Team: Graeme Rocher, Marc Palmer, Dierk Koenig, Steven Devijer, Jason Rudolph, Sven Haiges... SIE!
    8. Grails im Einsatz...
      • Standalone
        • Kein XML, keine aufwändige Konfiguration
        • 0..100 in no time!
      • Integration mit bestehenden Applikationen
        • Die Flexibilität von Grails bleibt weitestgehend erhalten, dennoch kann man z.B. das OR-Mapping beliebig konfigurieren
        • Etwas Integration zu Beginn
    9. Die Basis von Grails
      • Java EE
      • Groovy: perfekte Integration mit der Java Plattform, Groovy kompiliert zu bytecode :-)
      • Spring: IoC, Spring MVC, WebFlow, ...
      • Hibernate: DER Persistence Layer schlechthin
      • SiteMesh: flexibles Layout-Framework
      • Quartz: Job Scheduling
      • ...
    10. Installation
      • Keine separate Groovy-Installation benötigt, Groovy ist im Download enthalten
      • grails.org/Installation
      • Herunterladen, extrahieren, GRAILS_HOME setzen,Grails command line tool zum Path hinzufügen... fertig.
      • „ grails“ zum Test aufrufen
    11. Ihre erste Grails-Applikation
      • „ grails create-app“
      • „ cd appName”
      • „ grails run-app“
      • „ grails create-domain-class“, edit class
      • „ grails generate-all“
      • „ grails run-app“
    12. Grails Foundations
    13. Spring
      • Eine Grails Web Application wird durch Spring “zusammengehalten”, im Normalfall ist keine Anpassung dieser Konfiguration notwendig
      • Eigene Spring Beans können dennoch einfach deklariert werden. Eigene Beans können sehr einfach in Grails Artefakte wie Controller, Services oder Jobs “injected” werden
      • Eine Grails App ist eine „normale“ Spring MVC-Applikation. Spring Webflow kommt...
    14. Hibernate
      • Hibernate ist der de facto Standard für O/R Mapping
      • Grails erzeugt das DB-Schema basierend auf den Domain-Klassen automatisch und legt das Schema in der DB-An / führt Update aus
        • 1:n & m:n seit Grails 0.3
      • Oftmals ist das DB-Schema bereits vorhanden: Grails erlaubt eigene Hibernate Mappings
    15. SiteMesh
      • SiteMesh ist ein mächtiges Layout Framework und ist in Grails integriert
      • grails-app/views/layout/main.gsp definiert das Standard-Layout
      • Dieses Meta-Element im HTML Header verknüpft eine GSP-Seite mit dem “main” Layout: < meta name = &quot;layout&quot; content = &quot;main&quot; />
    16. Grails Philosophie
      • Wiederverwendung bestehender Lösungen
      • Kein “Reinventing the Wheel”
      • “Coding by Convention”
        • Ohne jegliche Flexibilität zu verlieren
      • Domain-Centric, nicht DB-Centric
      • DRY
    17. Grails MVC
    18. Model
      • Oben: eine Domain-Class
        • .groovy-Dateiim grails-app/domain Verzeichnis
        • Persistent
        • id, version, equals, hashCode, toString wird von Grails generiert. Diese Methoden können natürlich bei Bedarf überschrieben werden.
      • class Book {
      • String title
      • }
    19. Model
      • Normalerweise werden Domain-Classes per Grails command line tool erzeugt
      • Der Task fragt nach dem Namen der Klasse und erzeugt diese im domain-Verzeichnis
      • Klasse kann ebenso selbst erstellt werden...
      • > grails create-domain-class
    20. Model
      • 1:1 mapping mit Author
      • Der “Eigentümer” für cascading update/save wird so festgelegt:
      • class Book {
      • Author author
      • String title
      • }
      • class Book {
        • def belongsTo = Author
      • Author author
      • String title
      • }
    21. Model
      • 1:n mapping: Author hat viele Books
      • Property “books” automatisch erzeugt
      • Ebenso die “addXXX”-Methode
      • class Author {
        • def hasMany = [ books : Book ]
      • String name
      • }
      • author.addBook(new Book(title:'Grails'))
      • author.save()
    22. Model
      • m:n ebenso...
      • “belongsTo” definiert Eigentümer
      • class Book {
      • def belongsTo = Author
      • def hasMany = [authors:Author]
      • }
      • class Author {
      • def hasMany = [books:Book]
      • }
    23. Model
      • Constraints werden per Closure definiert
      • Auswirkungen auf die erzeugten Views
      • class User {
      • String login
      • String password
      • String email
      • Date age
      • static constraints = {
      • login(length:5..15,blank:false,unique:true)
      • password(length:5..15,blank:false)
      • email(email:true,blank:false)
      • age(min:new Date().minus(14),nullable:false)
      • }
      • }
    24. Model
      • Dynamic Finder Methods
      • def results = Book.findByTitle(&quot;The Stand&quot;)
      • results = Book.findByTitleLike(&quot;Harry Pot%&quot;)
      • results = Book.findByReleaseDateBetween( firstDate, secondDate )
      • results = Book.findByReleaseDateGreaterThan( someDate )
      • Ebenso möglich: Query by Example (QBE) Hibernate Criteria Builder, oder direkte HQL-Abfragen!
    25. Model
      • Datenbank-Konfiguration im grails-app/conf Verzeichnis
        • DevelopmentDataSource.groovy
        • ProductionDataSource.groovy
        • TestDataSource.groovy
      • “grails run-app” benutzt standardmäßig die “dev” DataSource
    26. Model
      • “grails war” erzeugt das Deployment WAR-File mit der production datasource
      • class DevelopmentDataSource {
      • boolean pooling = true
      • // one of 'create', 'create-drop','update'
      • //String dbCreate = &quot;create-drop&quot;
      • String url = &quot;jdbc:postgresql://localhost:5432/act_dev&quot;
      • String driverClassName = &quot;org.postgresql.Driver&quot;
      • String username = &quot;dev&quot;
      • String password = &quot;devpw&quot;
      • def logSql = true //enable logging of SQL generated by Hibernate
      • }
    27. Model
      • *BootStrap-Files werden zum Start ausgeführt; idealer Ort für die Erzeugung von Test-Daten
      • class CompanyBootStrap {
      • def init = { servletContext ->
      • //Delete all data in the tables that we work on
      • Company.executeUpdate( &quot;delete Company&quot; )
      • //now create the test data
      • Company c1 = new Company(name: 'bmw' )
      • c1.addUser( new User(name: 'herbert' , admin: true , ...))
      • .save()
      • }
      • ...
    28. View
      • Groovy Server Pages(GSP) oder JavaServer Pages (JSP)
      • TagLibs für GSP & JSP, GSP ist groovier...
      • Alle Views sind im grails-app/views Verzeichnis
      • Die CRUD-Views können einfach generiert werden: “grails generate-views”
    29. View
      • Beispiel: GSP, benutzt das “main” Layout
      • < html >
      • < head >
      • < meta name = &quot;layout&quot; content = &quot;main&quot; />
      • < title > BlogEntry List </ title >
      • </ head >
      • < body >
      • < div class = &quot;nav&quot; >
      • < span class = &quot;menuButton&quot; > < g:link controller = &quot;authentication&quot; action = &quot;viewControllers&quot; > Home </ g:link ></ span >
      • < span class = &quot;menuButton&quot; >< g:link action = &quot;create&quot; > New BlogEntry </ g:link ></ span >
      • </ div >
      • < div class = &quot;body&quot; >
        • ...
      • </ div >
        • ...
    30. View
      • Dynamic Tag Libraries
      • Tags machen endlich wieder Spaß!
      • “grails create-taglib” erzeugt ein *TagLib.groovy File in grails-app/taglib
      • Wie mit GSP/Controller updates: kein Server-Restart!
    31. View
      • TagLib Beispiel (“simple” tag)
      • class MyTagLib {
        • includeJs = { attrs ->
      • out << &quot;<script src='scripts/ ${attrs['script']} .js' />&quot;
        • }
      • }
      • OutputStream ist automatich über “out” erreichbar
      • Alle Tag-Attribute in der “attrs”-Map
    32. View
      • Logische und iterative Tags genauso easy
      • Tags können sogar als “Methoden” aus GSP-Seiten aufgerufen werden:
      • <g:hasErrors bean=&quot;${book}&quot; field=&quot;title&quot;>
      • <span class='label error'>There were errors on the book title</span>
      • </g:hasErrors>
      • Oder als Methode:
      • <span id=&quot;title&quot; class=&quot;label ${hasErrors(bean:book,field:'title','errors')}&quot;>Title</span>
    33. View
      • Einfaches Erzeugen von Markup aus Tags heraus:
      • def dialog = { attrs, body ->
      • mkp {
      • div('class':'dialog') {
      • body()
      • }
      • }
      • }
      • Beispiel: Groovy MarkupBuilder
    34. Controller
      • Alle Controller werden vom Grails dispatcher servlet gemapped
      • Neuer Controller per: “grails create-controller”
      • Oder: Generierung auf Basis einer Bestehenden Domain-Klasse: “grails generate-controller”
    35. Controller
      • Standard-Mapping (Konvention) http://.../appName/controller/action/id
      • Best. properties automatisch
        • flash – Map speichert Nachrichten für nächsten Request
        • log - eine Log4J Logger-Instanz
        • params – Map mit allen Parametern
        • request/response/servletContext etc.
    36. Controller
      • Generierter Controller:
      • class AdvertisementController {
      • def index = { redirect(action:list,params:params) }
      • def list = {
      • [ advertisementList: Advertisement.list( params ) ]
      • }
      • def show = {
      • [ advertisement : Advertisement.get( params.id ) ]
      • }
      • ...
    37. Controller
      • Es geht auch dynamisch:
      • class BookController {
      • def scaffold = Book
      • }
      • list/show/edit/delete/create/save/ update “dynamisch” verfügbar
      • Überschreiben einzelner Actions möglich!
      • “grails generate-all” erzeugt alle Views Controller-Actions für eine Domain Class
    38. Controller
      • Grails Services können die Business Logik kapseln
      • Services können sehr einfach in Controller-Klassen aufgerufen werden
      • “grails create-service” erzeugt einen neuen Service in grails-app/services
    39. Controller
      • Beispiel-Service
      • class CountryService {
      • def String sayHello(String name) {
      • return &quot;hello ${name}&quot;
      • }
      • }
      • Aufruf aus einem Controller:
      • class GreetingController {
      • CountryService countryService
      • def helloAction = {
      • render(countryService.sayHello(params.name))
      • }
      • }
    40. Scaffolding...
      • Benutzen Sie es, um schnell eine voll benutzbare Web-Applikation zu haben und um etwas demonstrieren zu können.
      • Auf dem Weg zum Endprodukt werden Sie sicherlich zahlreiche Änderungen vornehmen müssen.
      • Benutzen Sie Scaffolding, um schnell zu Lernen! Passen Sie dann alles gemäß Ihren Anforderungen an.
    41. Grails Features
    42. Auto Reloading
      • Im Development-Modus, synchronisiert Grails die aktuelle Applikation mit dem (Jetty-)Server
      • Controller, GSPs, Tag Libraries, Domain-Klassen, Services, etc.
      • Dadurch möglich: iterative und inkrementelle Entwicklung
      • “agile”
    43. Spring Integration
      • Zusätzliche Spring-Konfiguration kann im /spring-Verzeichnis abgelegt werden
      • Automatische DI ist auch für diese Beans verfügbar
      • Bestehende (Java-) Funktionalität (per Spring) sehr einfach integrierbar
    44. Hibernate Integration
      • Eigene Hibernate Mappings (HBM Files) für die Domain-Klassen
      • Die Arbeit mit “legacy database schemas” wird dadurch sehr einfach und effizient
      • Trotzdem können Sie dynamische Finder-Methoden (GORM) verwenden!
    45. Eclipse “Integration”
      • Automatisch wird eine Eclipse Projekt-Datei erzeugt - einfach zu importieren: File > Import > Existing Project
      • Achtung: bie Snapshots müssen ein paar Pfade/Dateinamen aktualisiert werden...
      • Installieren Sie auf jeden Fall das Groovy Plugin: groovy.codehaus.org/Eclipse+Plugin
    46. AJAX
      • Grails unterstützt AJAX mit unterschiedlichen AJAX toolkits, momentan Prototype, Dojo und Yahoo
      • Spezielle AJAX Tags können für asynchrone Aufrufe und Form-Submissions benutzt werden:
      • <div id=&quot;message&quot;></div>
      • <g:remoteLink action=&quot;delete&quot; id=&quot;1&quot; update=&quot;message&quot;>Delete Book</g:remoteLink>
    47. AJAX
      • Serverseitig unterstützt Grails AJAX durch die render()-Methode. Hier eine AJAX-Response:
      • def time = {
      • render (contentType:'text/xml') {
      • time(new Date())
      • }
      • }
      • Render() unterstützt MarkupBuilder für XML, HTML, JSON und OpenRico
    48. Job Scheduling
      • Grails macht die periodische Ausführung von Jobs noch einfacher:
      • class MyJob {
        • def cronExpression = &quot;0,15,30,45 * * * * ?&quot; //every 15 seconds
        • def execute(){
          • println &quot;Running job!&quot;
        • }
      • }
    49. Unit & Functional Testing
      • Sowohl Unit- als auch Functional-Testing werden unterstützt
      • Functional Testing: Canoo Webtest
        • “grails test-app” startet alle Unit-Tests
        • “grails run-webtest” für alle WebTests
      • Funktionale Tests werden einfach per scaffolding erzeugt:
        • “grails generate-webtest”
    50. Grails Roadmap
    51. Die Sandbox
      • Neue Controllers
      • Page Flows (WebFlow)
      • Constraints für DB-Schema-Erzeugung
      • Laszlo on Grails
      • Mail / Messaging Integration
      • Test DataSets
      • Plugin-System
    52. Roadmap
      • 0.3
        • Spring 2
        • Web Services Service Classes
        • M:N Mapping for GORM
      • 0.4
        • DWR Support für Service Classes
        • Pluggable Persistence Layer
    53. Roadmap
      • 0.5
        • XML-RPC for Service Classes
        • Generation des Domain Model vom DB Schema
      • 0.6
        • Scaffolding für User Authentication Code
        • Grails ist immer noch klein und fein: Sie entscheiden, was wichtig wird: http://jira.codehaus.org/browse/GRAILS
    54. Weitere Infos, Tipps
    55. Weitere Infos...
      • Herunterladen, Installieren, die erste App erzeugen mit dem QuickStart Guide: http://www.grails.org/Quick+Start
      • Tutorials lesen: http://www.grails.org/Tutorials
    56. Weitere Infos...
      • Den User Guide lesen und ausprobieren: http://www.grails.org/User+Guide
      • Die Grails Mailing List lesen: http://www.grails.org/Mailing+lists
      • Achtung: Grails ist open source...
        • Je mehr Sie selbst dazu beitragen, desto schneller lernen Sie Grails kennen
    57. “SEE” the Light
      • Derzeit gibt es 2 Screencasts über Grails:
        • Scaffolding
        • Directory Structure
        • http://www.grails.org/Grails+Screencasts
    58. Grails Podcast
      • Grails Podcast
      • ~ wöchentlich
      • Grails News
      • Grails Features
      • Interviews
      • Agile Development
        • http://hansamann.podspot.de/rss
    59. Lesestoff
      • Erscheint in Kürze!
      • Von Graeme Rocher, Grails Project Lead
      • ISBN: 1-59059-758-3
    60. Machen Sie mit!
      • Veröffentlichen Sie z.B. einen Tag! grails.org/Contribute+a+Tag
      • Bloggen Sie über Grails!
      • Beantworten Sie Fragen in der Grails User List
      • und...
    61. Groovy & Grails Shop
      • Kaufen Sie endlich einen richtigen “GString”!
      • http://tinyurl.com/y3zmos
      Neu!
    62. GRAILS
        • RAPID WEB APP DEVELOPMENT MADE EASY
        • Vielen Dank! Fragen?
        • www.grails.org www.svenhaiges.de
        • skype: hansamann

    + Sven HaigesSven Haiges, 4 years ago

    custom

    7853 views, 0 favs, 2 embeds more stats

    Presentation at WJAX 2006 in German. Audio will fol more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 7853
      • 7835 on SlideShare
      • 18 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 0
    Most viewed embeds
    • 12 views on http://www.thorsten-kamann.de
    • 6 views on http://www.flavor.de

    more

    All embeds
    • 12 views on http://www.thorsten-kamann.de
    • 6 views on http://www.flavor.de

    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