Die Präsentation wird geladen. Bitte warten

Die Präsentation wird geladen. Bitte warten

DOAG SIG Java: Grails und Oracle

Ähnliche Präsentationen


Präsentation zum Thema: "DOAG SIG Java: Grails und Oracle"—  Präsentation transkript:

1 DOAG SIG Java: Grails und Oracle
Rapid Web Application Development mit Grails und Oracle Referent: Frank Szilinski

2 Firmenvorstellung Kernkompetenzen esentri Strategieberatung
Projektmanagement Technologie Java/SOA Software Solutions Open Source Oracle RIA

3 Technologie Portfolio

4 Ziele des Vortrags mit Grails und Oracle Overview Technology-Stack
Rapid Web Application Development mit Grails und Oracle Overview Technology-Stack Wo gehört das Framework hin? Groovy und Grails Einblick in die Sprache Groovy und das Framework Grails Grails und Oracle Zusammenspiel Datenbank, Grails und WebLogic Real-Life Plug-In, Integration, Einsatzgebiete, Conclusion

5 Trends – Groovy und Grails

6 Was ist Groovy? 2003 gestartet
2004 als JSR-241als Standard aufgenommen 2007 Release 1.0 2007 Jax Innovation Award 2010 Release 1.7.1 Basis für Grails Allzweck-Programmiersprache für die JVM Ausdrucksstärke von Ruby, Lisp und Python Stabile, funktionsreiche Sprache Objektorientiert Template Mechanismen

7 Was ist Grails? 2005 gestartet 2006 Release 0.1 2008 Release 1.0
2008 Februar Das Unternehmen Groovy Grails wurde von SpringSource gekauft 2008 November SpringSource wird von VMWare übernommen aktuell Release 1.2.2

8 Was ist Grails? Web Application Development Plattform
Rapid Getting things done Open Source keine Lizenzkosten Full-stack MVC Framework JVM als Laufzeitumgebung Code Compile Package Deploy Test Debug Nahtlose Java Integration Ausführbar in diversen Containern Deckt den JEE Development Cycle ab Verbindet bewährte OSS Frameworks wie Spring, Hibernate, Sitemesh, HSQLDB, Quartz

9 Vergleichbare Frameworks*
Application Development Framework

10 Java Development Kit (JDK)
Grails Framework Grails Spring Hibernate Sitemesh JEE Groovy Java Language Java Development Kit (JDK) Java Virtual Machine

11 Integrated Development Environments
SpringSource ToolSuite Grails-Nature Code-Completion Grails Aktionen über Kommandozeile Eclipse Bisher keine Integration Oracle JDeveloper Grails Aktionen über konfigurierbare externe Tools Oracle NetBeans Grails Integration in Projektbaum Automatische Generierung und Konfiguration Bester Support

12 Demo Teil I Scaffolding Sample

13 Grails Einflussfaktoren
Scaffolding und templating Rock-solid foundations Java Integration Agiles Vorgehen Incredible wetware Grails Convertion over Configuration ProduktivitätsEthos

14 Begriffe = Best Practices
Scaffolding Gerüst um die notwendigsten CRUD Operationen, Controller und Views eines Domain-Objects generieren zu lassen Convention over configuration (CoC) Ein Entwickler kann sich darauf verlassen, dass ein Standardverhalten ohne Konfiguration erreicht wird, was jedoch angepasst werden kann, falls dies notwendig ist Don‘t repeate yourself (DRY) Redundanzen, Mehrfachkonfiguration und Copy&Paste vermeiden Default is what you expect (DIWYE) Das Verhalten und die Standards sind so definiert, wie ein Entwickler es erwarten würde Domain-driven-Development (DDD) Die Domain ist die treibende Kraft

15 Der Einstieg in Groovy Groovy ist eine... dynamische Scriptsprache
Quelle: Bild:

16 Groovy Interpreter Groovy Groovy Source compile (groovy) Java ByteCode
execute (Class Loader)

17 Der Einstieg in Groovy Erfahrener Entwickler spart mit Groovy gegenüber Java % Quellcode und benötigt nur ⅓ der Zeit Kann mit Java vermischt werden Wird in Java ByteCode übersetzt Groovy Klasse = Java Klasse Groovy Servlets und Templates bieten optimale Voraussetzung zur Erstellung nicht nur von Webseiten Viele neue Sprachfeatures wie GPath GString Internal iterations Closures Meta Object Protocol (MOP) Dynamics/Expandos, Kategorien, Metaclass, AST Transformations

18 Die Sprache Groovy Beispiel 1
Parse alle Dateien rekursiv unterhalb des Verzeichnisses „aFolder“, die mit „TAG“ enden und prüfe die Gültigkeit und Wohlgeformtheit dieser Dateien: im Terminal groovy -e 'new File(“aFolder").eachFileRecurse{ f -> if (!f.isDirectory() && f.name.endsWith(“TAG")){ new XmlParser().parse(f)}}'

19 Die Sprache Groovy Beispiel 2 Beispiel 3 Java Groovy Java Groovy
((Date)getAttribute("PromotionDate")).compareTo((Date)getAttribute("HireDate")) > 0 Groovy PromotionDate > HireDate Beispiel 3 Java ((Number)getAttribute("Salary").multiply(new Number(0.10)) Groovy Salary * 0.10

20 Die Sprache Groovy Beispiel 4 Java Java Groovy
List names = new ArrayList(); for (Iterator iterator = people.iterator(); iterator.hasNext();) { Person person = (Person) iterator.next(); names.add(person.getName()); } System.out.println(names); Java List names = new ArrayList(); for (Iterator iterator = people.iterator(); iterator.hasNext();) { Person person = (Person) iterator.next(); names.add(person.getName()); } System.out.println(names); Groovy def names = people*.name println names

21 Die Sprache Groovy Beispiel 5 Java Groovy try {
// Create a URL for the desired page URL url = new URL(" // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; StringBuffer sb = new StringBuffer(); while ((str = in.readLine()) != null) { sb.append(str); } in.close(); } catch (MalformedURLException e) { } catch (IOException e) { System.out.println(sb.toString()); Groovy def text = new URL(" println text

22 Die Sprache Groovy Beispiel 6: Closures def adder = {a,b -> a+b }
assert 3 == adder.call(1,2) def multiplier = {a,b -> a*b } assert 2 == multiplier(1,2) def map = {a,b,f -> f(a,b) } assert 3 == map(1,2,adder) Beispiel 6: Closures

23 Die Sprache Groovy Beispiel 7: Expandos coach = new Expando()
coach.firstName = "Louis" coach.lastName = "Van Gaal" coach.victories = 148 coach.matchWon = { coach.victories++; } coach.matchWon() assert coach.victories == 149

24 Grails Architektur Grails Dojo Prototype Yahoo UI Flex Acegi ... Quarz
JUnit Canoo WebTest Groovy Java Spring Hibernate Sitemesh

25 Grails DispatcherServlet
Grails Integration Client Presentation Geschäftslogik Integration Data GSP Controller GORM Grails DispatcherServlet Service Domain Remote Services Enterprise Services

26 Grails MVC Paradigma Aufruf von Client: class BookController { def show = { ["books": Book.list ] } <html> <head> <title> Book list </title> </head> <body> <h1> Book list </h1> <table> <tr> <th> Title </th> <th> Author </th> </tr> <g:each in=" ${ books } "> <td> ${ it.title } </td> <td> ${ it.author } </td> </g:each> </table> </body> </html> Controller class Book { String title Author author String ISBN BigDecimal price def belongsTo = Author } Model View

27 Grails GORM GORM = Groovy Object-Relational Mapping
Basis für GORM ist Hibernate, kann aber durch Plug-Ins beliebige ausgetauscht werden Persistence Management ist ohne Konfiguration verfügbar Domain Klassen haben durch Konvention automatisch Methoden Zugriff über dynamische Finder-Methoden find count findAll list get ... class User { String login String firstName String lastName String role } User.findByLastNameAndFirstName('Szilinski', 'Robert') User.findByFirstNameLike('Sz%')

28 Grails GORM Automatische Instanzmethoden user.save(), user.validate(), user.update(), user.delete() Uni- und Bi-Direktionale Beziehungen id, version, equals, hashCode, toString von Grails generiert Domain-Klasse und anwendungsspezifisch Validatoren class Author { String firstName String lastName def hasMany = [books : Book] static constraints={ firstName( blank:false) lastName( } class Book { String title Author author Publisher publisher def belongsTo = [author:Author] } class Publisher { String name def hasMany = [books:Book] }

29 Grails DataSource - Oracle Datenbanken
pooled = true driverClassName = "oracle.jdbc.driver.OracleDriver" username = "xeuser" password = "xepass" dialect = "org.hibernate.dialect.Oracle9Dialect" } hibernate { cache.use_second_level_cache=true cache.use_query_cache=true cache.provider_class='net.sf.ehcache.hibernate.EhCacheProvider' environments { development { dbCreate = "update" url = test { ... production {

30 Grails und Groovy Server Pages (GSP)
Meta Tags in den HTML-Dateien oder per Konvention angeben Konvention: Decorator in entsprechende Verzeichnisse legen DecoratorMapper Beispielsweise PrintDecoratorMapper GSP ≈ JSP eigenen TagLibs und Integration in Sitemesh Ajax TagLib unterstützt Prototype, Rico, Yahoo UI, Dojo, DWR, OpenLazlo, Wicket

31 Verkürzter Entwicklungszyklus
Code Compile Package Deploy Test Debug Entwicklungszyklus Grails Entwicklungszyklus JEE Code Test Debug

32 Deployment-Matrix Mögliche Application Container ab Grails 1.0
Oracle AS GlassFish v3 Prelude v3 "Prelude“ Weblogic 8.1.2 IBM Integrated Web Application Server for i 7.1 Weblogic 9.2 Weblogic 10 Sun App Server 8.2 Resin 3.2 Tomcat 5.5 JBoss 4.2 Tomcat 6.0 Jetty 6.1 JOnAS 5.1 SpringSource Application Platform 1.0 beta JOnAS 5.2 Websphere Application Server Community Edition 2.0 (WAS CE) Geronimo 2.1.1 GlassFish v1 (Sun AS 9.0) and v2 (Sun AS 9.1) Websphere 6.1

33 Grails Application on Oracle WebLogic
<?xml version="1.0" encoding="UTF-8"?> <weblogic-web-app xmlns=" xmlns:xsi=" xsi:schemaLocation=" <container-descriptor> <prefer-web-inf-classes>true</prefer-web-inf-classes> </container-descriptor> </weblogic-web-app>

34 Plug-Ins – die Welt liegt Grails zu Füssen
Grails ist eine Plugin-Laufzeit-Umgebung Der Grails Kern besteht aus Plug-Ins (im Standard MVC, GORM etc.) Macht Grails sehr flexibel und Umfangreich Grails-Plugin-Community > 390 Plug-Ins Apache Camel Google Analytics Comet Google Maps Cloud Foundry JPA DataSources JMS Facebook LDAP Feeds Twitter Flex/BlazeDS ...

35 Grails Performance und Zukunft
Problem Groovy bisher Faktor 5x bis 15x langsamer als Java!!! Abhilfe JRockit JVM * InvokeDynamic (Java7) Groovy Optimizations (Loop unrolling, etc) Groovy++

36 Grails Integration Grails auf der Grünen Wiese?
Grails Integration in existierende Umgebungen? Wiederverwendung von existierenden Anwendungen? Ist Grails Enterprise-Ready?

37 Erfahrungsberichte Brasilianische Entertainment-Seite 1 Million Seitenzugriffe im Monat Travel Community 1 Million Benutzer und 3 Millionen Photos Multi-Channel Television Service mit nahezu 10 Millionen Kunden Persönliches Finanz-Tracking in kürzester Zeit realisiert

38 Demo Teil II Grails on Oracle

39 Kontakt Frank Szilinski Bachelor of Science in Computer Science Stephanienstr. 36 76133 Karlsruhe Tel 0721 / Fax 0721 /


Herunterladen ppt "DOAG SIG Java: Grails und Oracle"

Ähnliche Präsentationen


Google-Anzeigen