G* on GAE/J 挑戦編
Upcoming SlideShare
Loading in...5
×
 

G* on GAE/J 挑戦編

on

  • 2,931 views

 

Statistics

Views

Total Views
2,931
Views on SlideShare
2,464
Embed Views
467

Actions

Likes
1
Downloads
12
Comments
0

4 Embeds 467

http://d.hatena.ne.jp 454
http://webcache.googleusercontent.com 6
http://www.slideshare.net 5
http://hatenatunnel.appspot.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

G* on GAE/J 挑戦編 G* on GAE/J 挑戦編 Presentation Transcript

  • 2009/08/22 @Tokyo def speaker = new Cast(name:”T.Yamamoto”,version:”G*S-2009-08-22”)
  • ( ) DTP Web 90%Grails JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/
  • $ grails create-app eventer $ cd eventer grails.project.plugins.dir="work_tmp/plugins" grails.project.work.dir="work_tmp/work" development { dataSource { dbCreate = "update" url = "jdbc:hsqldb:file:work_tmp/devDB;shutdown=true"
  • $ grails run-app
  • $ grails create-domain-class org.jggug.Event $ grails create-controller org.jggug.Event
  • package org.jggug class Event { /** */ String eventName /** */ Date eventDate /** */ String eventDesc /** */ String place /** */ String groupName /** */ package org.jggug String content class EventController { def scaffold = true Date dateCreated } Date lastUpdated static constraints = { } }
  • $ grails run-app
  • class Event implements Serializable { static mapping = { id generator:'uuid.hex', params:[type:'string'] } String id ... static constraints = { eventName nullable:false,blank:false eventDate nullable:false,blank:false eventDesc nullable:false,blank:false place nullable:false,blank:false groupName nullable:false,blank:false content nullable:false, blank:false,maxSize:4000 dateCreated display:false lastUpdated display:false }
  • event.label = event.eventName.label = /** */ String eventName /**(.*)*/n(.*) (.*) /** */ event.$3.label = $1 Date eventDate /** */ String eventDesc event.eventName.label = event.eventDate.label = event.eventDesc.label =
  • $ grails generate-all org.jggug.Event $ grails run-app
  • $ grails install-plugin calendar <head> <calendar:resources lang="en" theme="tiger"/> <calendar:datePicker name="eventDate" defaultValue="${eventInstance?.eventDate}" dateFormat="%Y/%m/%d" />
  • yui-css ( ) grails install-plugin http://grails.jp/sample/grails-yui-css-2.7.0-M2.zip grails yui-css <head> content=”main” “yui-t1” <meta name="layout" content="main" /> <meta name="layout" content="yui-t1" />
  • export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.2 google.appengine.sdk='/opt/appengine-java-sdk-1.2.2'
  • $ grails install-plugin app-engine Do you want to use JPA or JDO for persistence? (jpa, jdo) jpa grails-app/conf/ datastore-indexes.xml persistence.xml grails-app/conf/Config.groovy GAE google.appengine.application="jggugv4" Grails
  • $ grails install-plugin gorm-jpa resources.groovy entityManagerFactory transactionManager entityManagerFactory(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) { beanClassLoader = ref("classLoader") } transactionManager(org.springframework.orm.jpa.JpaTransactionManager) { entityManagerFactory = entityManagerFactory } datanucleus-enhancer*.jar cp $APPENGINE_HOME/lib/tools/orm/datanucleus-enhancer-1.1.4.jar lib
  • import org.datanucleus.jpa.annotations.Extension import javax.persistence.*; @Entity class Event implements Serializable { @Id @GeneratedValue (strategy = GenerationType.IDENTITY) @Extension (vendorName = "datanucleus", key = "gae.encoded-pk", value = "true") String id /** */ @Column // String eventName
  • def save = { def eventInstance = new Event(params) Event.withTransaction{ if(eventInstance.save(flush:true)) { flash.message = "Event ${eventInstance.id} created" redirect action:"show", id:eventInstance.id } else { render view:'create', model:[eventInstance:eventInstance] } } }
  • $ grails set-version 1 $ grails app-engine run
  • $ grails app-engine package $ rm target/war/WEB-INF/lib/jul-to-slf4j-1.5.6.jar $ appcfg.sh update ./target/war
  • export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.2 export PATH=$PATH:$APPENGINE_HOME/bin $ dev_appserver.sh -h $ appcfg.sh -h ※Windows .sh→.cmd
  • $ dev_appserver.sh ./war ※Windows .sh→.cmd
  • View request.setAttribute 'list', [1, 2, 3, 4] request.setAttribute 'date', new Date()   forward 'display.gtpl'
  • import com.google.appengine.api.datastore.Entity def person = new Entity("person") person['name'] = " " println person['name'] person.age = 31 println person.age // person.save() // person.delete() // def q = new Query('person') def list = datastoreService.prepare(q).asList( Builder.withLimit(20).offset(0) )
  • <system-properties> <property name="file.encoding" value="UTF-8"/> <property name="groovy.source.encoding" value="UTF-8"/> </system-properties>
  • Grails/Groovy http://www.jggug.org/