Saturday, October 24, 2009

Create google wave robot from grails

1. use grails 1.1.1 (1.2.M3 does not work yet!!!)
2. create a grail project gswordwave
grails create-app gswordwave
3. uninstall hiberante
grails uninstall-plugin hibernate

4. install app engine plugin, selected jdo ( default)
grails install-plugin app-engine
5. run the app with this command:
grails app-engine
6. kill it
7. do initial deployment and make sure it works without wave stuff
  • Register your application on appengine site. gswordwave
  • grails set-version 1
  • grails app-engine package
  • %APP-ENGINE-HOME%/bin/appcfg.cmd update ./target/war


8. download the google wave client jars from
  • http://code.google.com/p/wave-robot-java-client/downloads/list and copy all the wave client jar to the lib directory in the grails root dir, also download servlet.api.2.5.jar into lib
  • Bulleted List mkdir src/java/parroty/server
  • copy http://code.google.com/apis/wave/extensions/robots/java-tutorial.html src/parroty/ParrotyServlet.java into the above directory src/java/parroty/server and name it ParrotyServlet.java and update the package to parroty.server.
  • Make a web-app/_wave dir. Create in it a capabilties.xml file and copy paste the code

<?xml version="1.0" encoding="utf-8"?>

<w:robot w="http://wave.google.com/extensions/robots/1.0">
<w:capabilities>
<w:capability name="WAVELET_PARTICIPANTS_CHANGED" content="true">
</w:capability>
<w:version>1</w:version>
</w:capabilities>
</w:robot></pre>

9. In your appengine-web.xml (mine is in
c:\users\yiguang\.grails\1.1.1\projects\gswordbible\stage)file
you will find your application id is there already(mine, "gswordwave").


<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>gswordwave</application>
<version>0.1</version>
<sessions-enabled>true</sessions-enabled>
<ssl-enabled>true</ssl-enabled>
<system-properties>

</system-properties>

</appengine-web-app>


10. add your ParrotyServlet config into src\templates\war\web.xml :

<servlet>
<servlet-name>Parroty</servlet-name>
<servlet-class>parroty.server.ParrotyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Parroty</servlet-name>
<url-pattern>/_wave/robot/jsonrpc</url-pattern>
</servlet-mapping>


11. do redeployment

  • grails app-engine package
  • %APP-ENGINE-HOME%/bin/appcfg.cmd update ./target/war
12. check it out

http://gswordwave.appspot.com/_wave/capabilities.xml
13. goto your wave account and add gswordwave@appsport.com onto
your contact list and start to communicate with it

1 comment:

  1. Right after I release my first version bot with this process, grails wave plugin 0.3 is published. With the grails wave plugin, the process is much simplified to create bot. Step 8,9,10 are replaced
    8. grails install-plugin wave
    9. cd grails/services and work on the generated service class and implement the event handling method.
    no need to configuring servlet etc.
    Cheers!

    ReplyDelete