Grails Overview

  • View
    2.004

  • Download
    0

Embed Size (px)

DESCRIPTION

Overview of Grails, a Groovy and Java based web development platform.

Transcript

  • 1. WhatisGrailsandwhyshouldIcare? BuildingonJavasstrengths TheGroovylanguage AtourofGrails AncillarytoolsusefulinGrails 2009DevJamAllrightsreserved.

2. Webapplicationdevelopmentenvironment BuiltontheJavaPlatform Groovyastheprimarylanguage JavacanalsobeusedandintermixedwithGroovy seamlessly FavorsConventionoverConguration SimilarinspirittoRubyonRails 2009DevJamAllrightsreserved. 3. Javawebdevelopmentcanbetedious TheJVM,classlibraries,andframeworksaretherealstrengthoftheJavaPlatform GroovyisanexcellentdynamiclanguagefortheJVM CompilestoJavabytecode(.classles) Favorconventionoverconguration Grailsisanopinionatedframework Enhancesproductivity 2009DevJamAllrightsreserved. 4. BuiltontopoftheJavaVirtualMachine Maturity Optimizationandperformance Runtimefamiliarity IntegrationwithJavaapplications GroovyclassesareJavaclasses ReusewhatworksfromtraditionalJavastack JavaEE:ServletAPI,JDBC,JMS Hibernate,SpringFramework,SpringMVC,SiteMesh2009DevJamAllrightsreserved. 5. 2009DevJamAllrightsreserved. 6. Hibernate Object/relationalmapping(ORM) SpringFramework Dependencyinjectionservices Applicationlifecyclefacilities SpringMVC Webframework SiteMesh Userinterfacelayoutandthemingfacilities 2009DevJamAllrightsreserved. 7. Grailsconventiondictates Wherecomponentsresideintheapplication Howthecomponentisnamed Howthecomponentiswiredandcollaborateswithotherapplicationcomponents Howapplicationscanbeextendedthroughtheuseofthirdpartyplugins 2009DevJamAllrightsreserved. 8. Standardizedconguration Log4j,databasedatasources Autowiringanddependencyinjectionof components Standardizedbuild Gantscripts Standardizeddomainmodel GORMfacilitiesinjectedintodomainobjects Standardizedservices Automatictransactionsupport 2009DevJamAllrightsreserved. 9. FeaturesinspiredfromPython,Ruby,andSmalltalk CanbecompiledtoJavabytecode GroovyclassesareJavaclasses GroovycanseamlesslyuseJavaclasses JavacanseamlesslyuseGroovyclasses* Lotsofnewlanguagesfeatures GPath,GString,internaliterators,closures,Meta ObjectProtocol(MOP),andmanyothers 2009DevJamAllrightsreserved. 10. JDBCisusedforcommunicatingwithdatabases HSQLDB:defaultdatasource DataSource.groovy CongurationofDataSourcesforallyourenvironments Easytoswitchtoadierentdatabase,evenacrossdierentdeployments 2009DevJamAllrightsreserved. 11. DomainclassesarecentraltoaGrailsapplication Locatedingrailsapp/domain Allattributespersistentunlessmarkedinthetransientsproperty Nogettersandsettersnecessary Validators:speciedinconstraintsproperty GORMmapping:customizedinthemappingproperty2009DevJamAllrightsreserved. 12. GrailsObjectRelationalMapping LeveragesHibernate Automaticallymapsdomainobjectstodatabase Providesqueryandupdatefacilities Findingobjectsinthepersistencestore(ndBymethods). Persistencelifecyclemethods(save,update,delete). CriteriaandHQLqueryfacilities. 2009DevJamAllrightsreserved. 13. Noneedtoextendacommonpersistentbase class GrailsinjectsGORMfunctionalityintoobjectsat runtime. Declarepropertiesforyourdomainobjects Theidorversionpropertiesareinjectedautomatically. Allpropertiesarenotnull/requiredbydefault 2009DevJamAllrightsreserved. 14. Associations Onetoone,onetomany,manytomany Unidirectionalandbidirectional OwnersdenedbyusingbelongsToproperty Inheritancehierarchies Tableperhierarchy:Allclassesmaptoasingletable Tablepersubclass:EachclassmapstoitsowntableandJOINsareused 2009DevJamAllrightsreserved. 15. Retrievingobjects get(), getAll(), read() Listingobjects list(), listOrderBy*() methods order, sort, offset, andmaxnamed arguments Dynamicnders(findBy*()) Usepropertynamesoftheclass Supportformanyexpressionsinndermethod 2009DevJamAllrightsreserved. 16. BuiltonHibernatesCriteriaAPI Groovybuilderisusedtobuildupthecriteria Hierarchyofmethodcallsandclosuresfor buildingtreelikestructures EachdomainclasshasacreateCriteria() method Callget,list,scroll,orcountoncriteria Thecriteriabuilderisusedtorestrictthequery Supportsassociationsandprojections2009DevJamAllrightsreserved. 17. SupportforHibernateQueryLanguage find(hql), findAll(hql), and executeQuery(hql) forqueries executeUpdate(hql)forDMLstyle opera3ons(setsofupdatesordeletes) Supportforpositionalandnamedparameters 2009DevJamAllrightsreserved. 18. HandlesHTTPrequestsanddeterminesrenderingresponsibility Manyobjectsareavailabletoyourcontrollerclosures log,params,request,response,session, servletContext,ash Interceptorsonacontroller beforeInterceptorandafterInterceptorclosures2009DevJamAllrightsreserved. 19. Fileupload/multipartrequests Automaticbindingtodomainobjects Binaryresponsewriting response.outputStream response.contentType Overloaded