G*なクラウド ~雲のかなたに~

3,260 views

Published on

日本 Java ユーザグループ CCC Fall 2009 でのスライドです。
「G*なクラウド ~雲のかなたに~」
まわりを見渡せばクラウドの話で持ちきりです。様々なフレームワークがクラウドに対応するなか、もちろんG*なクラウド活用法も存在します。Grails でプラグインを使ってGAE/Jに対応や、Cloud Foundry(EC2)、GroovyでのGAE/J「Gaelyk」など、Grails/Groovyでのクラウドを紹介・解説します。

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,260
On SlideShare
0
From Embeds
0
Number of Embeds
783
Actions
Shares
0
Downloads
23
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

G*なクラウド ~雲のかなたに~

  1. 1. 2009/10/08 @JJUG CCC def speaker = new Cast(name:”T.Yamamoto”,version:”G*C-2009-10-08”)
  2. 2. ( ) DTP Web 75%Grails JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/ twitter @tyama
  3. 3. JGGUG japan grails/groovy user group
  4. 4. JGGUG japan grails/groovy user group
  5. 5. Grails CMS
  6. 6. JGGUG japan grails/groovy user group
  7. 7. Grails PaaS
  8. 8. # curl -L http://stax-downloads.s3.amazonaws.com/sdk/ stax-sdk-0.3.6-dist.zip > stax_sdk.zip # unzip stax_sdk.zip # rm stax_sdk.zip # cd stax-sdk-0.3.6 export STAX_HOME=/opt/stax-sdk-0.3.6 export PATH=$PATH:$STAX_HOME
  9. 9. ... ... dataSource { dbCreate = "update" driverClassName = "com.staxnet.jdbc.Driver" url = "jdbc:stax://jggug" username = "tyama" password = "*****" } ... ...
  10. 10. ... log4j = { appenders { null name:'stacktrace' ... ...
  11. 11. Cloud Tool grails create-app demo cd demo grails install-plugin cloud-tool.zip Config.groovy import aws.properties grails cloud-tools-deploy grails cloud-tools-describe grails cloud-tools-stop
  12. 12. war DB
  13. 13. IP
  14. 14. DB EBS
  15. 15. UPTIME
  16. 16. Apache tc Server MySQL
  17. 17. HTTPD TC
  18. 18. AWS ACCESS KEY ID KEY PAIRS
  19. 19. SSH
  20. 20. export APPENGINE_HOME=/opt/appengine-java-sdk-1.2.5 google.appengine.sdk='/opt/appengine-java-sdk-1.2.5'
  21. 21. $ 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
  22. 22. $ 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
  23. 23. 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
  24. 24. 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] } } }
  25. 25. $ grails set-version 1 $ grails app-engine run
  26. 26. $ grails set-version 1 $ grails app-engine deploy $ grails app-engine package $ rm target/war/WEB-INF/lib/jul-to-slf4j-1.5.6.jar $ appcfg.sh update ./target/war
  27. 27. $ dev_appserver.sh ./war ※Windows .sh→.cmd
  28. 28. View request.setAttribute 'list', [1, 2, 3, 4] request.setAttribute 'date', new Date()   forward 'display.gtpl'
  29. 29. mailService.send to: 'foobar@gmail.com', subject: 'Hello World', htmlBody: '<bold>Hello</bold>' datastoreService.withTransaction { // your code }
  30. 30. 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) )
  31. 31. <system-properties> <property name="file.encoding" value="UTF-8"/> <property name="groovy.source.encoding" value="UTF-8"/> </system-properties>
  32. 32. $ ./gaelyk-setup.sh myapp001
  33. 33. Grails/Groovy http://www.jggug.org/

×