名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン

2,655 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,655
On SlideShare
0
From Embeds
0
Number of Embeds
631
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン

  1. 1. JGGUG japan grails/groovy user group DTP Web 80% Grails Struts JGGUG( ) Grails 9-11 Grails Acegi Plugin http://d.hatena.ne.jp/mottsnite/ twitter @tyama
  2. 2. Grails CMS
  3. 3. public class HelloWorld { String name; public void setName(String name){ this.name = name; } public String getName(){ return name; } public String greet(){ return "Hello "+name; } public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld(); helloWorld.setName("Groovy"); System.out.println(helloWorld.greet()); } }
  4. 4. public class HelloWorld { String name; public void setName(String name){ this.name = name; } public String getName(){ return name; } public String greet(){ return "Hello "+name; } public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld(); helloWorld.setName("Groovy"); System.out.println(helloWorld.greet()); } }
  5. 5. public class HelloWorld { String name public void setName(String name){ this.name = name } public String getName(){ return name } public String greet(){ return "Hello "+name } public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet()) } }
  6. 6. public class HelloWorld { String name public String greet(){ return "Hello "+name } public static void main(String[] args){ HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet()) } }
  7. 7. public class HelloWorld { String name public String greet(){ return "Hello "+name } } HelloWorld helloWorld = new HelloWorld() helloWorld.setName("Groovy") System.out.println(helloWorld.greet())
  8. 8. class HelloWorld { String name def greet(){ return "Hello "+name } } def helloWorld = new HelloWorld() helloWorld.setName("Groovy") println(helloWorld.greet())
  9. 9. class HelloWorld { String name def greet(){ return "Hello "+name } } def helloWorld = new HelloWorld() helloWorld.name = "Groovy" println helloWorld.greet()
  10. 10. class HelloWorld { String name def greet(){ "Hello $name"} } def helloWorld = new HelloWorld() helloWorld.name = "Groovy" println helloWorld.greet()
  11. 11. class HelloWorld { String name def greet(){ "Hello $name"} } def helloWorld = new HelloWorld(name: "Groovy") println helloWorld.greet()
  12. 12. def arr = [1,2,3,'hoge'] def map = [a:1,b:2,c:'hoge']
  13. 13. @Grab('net.homeip.yusuke:twitter4j:[2.0,)') import twitter4j.* def user="username",pass="pass" new Twitter(user,pass).friendsTimeline.each { println "${it.user.name}: ${it.text}" } maven
  14. 14. GAE/J+Grails PermGen
  15. 15. http://gist.github.com/263610
  16. 16. grails create-app myapp cd myapp grails create-domain-class jp.grails.Todo grails create-controller jp.grails.Todo
  17. 17. http://gist.github.com/263610
  18. 18. grails install-plugin app-engine jpa/jdo ”jpa”
  19. 19. grails install-plugin gorm-jpa
  20. 20. google.appengine.application="mygaeapp"
  21. 21. http://gist.github.com/263511 @Entity class Chat implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id @Column ... ... String message JPA class Chat { ... ... String message ... ... grails generate-all jp.grails.Chat app-engine
  22. 22. s/Groovy/Grails/ Gr stringchararrayaccessor.disabled=true
  23. 23. grails.project.plugins.dir="plugins"
  24. 24. 11
  25. 25. http://gist.github.com/263509 import groovy.xml.StreamingMarkupBuilder import groovy.xml.MarkupBuilder includeTargets << new File("${appEnginePluginDir}/scripts/_AppEngineCommon.groovy") eventStatusFinal = { msg -> def appXmlFile = new File("$stagingDir/WEB-INF/appengine-web.xml") def xml = new XmlSlurper().parse(appXmlFile) xml."system-properties".appendNode { property(name:"stringchararrayaccessor.disabled",value:"true") } def smb = new StreamingMarkupBuilder() def result = smb.bind{ mkp.declareNamespace("":"http://appengine.google.com/ns/1.0") mkp.yield xml } new FileOutputStream(appXmlFile).withWriter('UTF8'){w-> w << result } } <appengine-web-app xmlns='http://appengine.google.com/ns/1.0'> <application>jggugv4</application> <version>2</version> <sessions-enabled>true</sessions-enabled> <ssl-enabled>true</ssl-enabled> <system-properties> <property name='stringchararrayaccessor.disabled' value='true'/> </appengine-web-app>
  26. 26. $ grails app-engine run = GAE grails set-version 1 GAE grails app-engine package GAE SDK $APPENGINE_HOME/bin/appcfg.sh update ./target/war grails app-engine deploy
  27. 27. APPENGINE_HOME export APPENGINE_HOME=/opt/appengine-java-sdk-1.3.0 grails install-plugin app-engine grails install-plugin gorm-jpa grails app-engine run grails set-version 1 grails app-engine package GAE SDK $APPENGINE_HOME/bin/appcfg.sh update ./target/war grails app-engine package $APPENGINE_HOME/bin/appcfg.sh update ./target/war
  28. 28. Grails/Groovy http://www.jggug.org/

×