Monday, December 28, 2009

Google Wave Development - Robots in Netbeans 6.7

In this post I hope to describe how to create Google Wave robots in Netbeans 6.7. The instructions are adapted from a blog post on GAEJ Experiments regarding the use of the WADRobotFramework in Eclipse. Thanks to Romin Irani for the information on GAEJ Experiments and Jerome Baton for the WADRobotFramework.

This post assumes that you have a Google App Engine account and have Netbeans 6.7 setup to allow the deployment of Java applications to the Google App Engine. To deploy to GAE from Netbeans 6.7 you will need the GAE for NB Plugin. To check if it is setup correctly follow the tutorial here.

To begin with download the WADRobotFramework. It is a single JAR that should be copied to a directory on your machine. I used C:\Java_Utils\Wad. You will also need to download the Wave Robot Java Library from Google Code. I place all the files from this location into the directory c:\java_utils\waverobot.

Once we have all the files downloaded and copied to the correct directories I can create a new Web Project in Netbeans.

 

The project should be created with the name you want the robot to be names within Google Wave. I  have called mine CoxyDaveWaveRobot.




Ensure that Google App Engine has been selected as the Server.


Once the wizard has completed creating the project you can delete the index.jsp file as it is not required for the Wave Robot.

The next step is to add the required libraries to the project to allow us to use the WADRobotFramework and the Google Wave Robot Client.



Go to the Project Properties...Libraries panel and add each of the above libraries. Ensure that the Package checkbox is marked.

We can now start to build our Google Wave Robot. Create a new Java Class called MyAppenderRobot and once the wizard has completed add an import for org.wadael.waverobotfrmwrk.simple.BlipAppenderRobot and change the class declaration to extend BlipAppenderRobot. Netbeans will indicate that you need to 'Implement all Abstract Messages'. Use the wizard to implement the abstract methods. Replace the body of the getTextToAppend to the content shown.

public class MyAppenderRobot extends BlipAppenderRobot{

    @Override
    protected String getTextToAppend(String arg0) {
        return "I am replying to your blip!";
    }

Open the web.xml file and add the following servlet details:


        MyAppenderRobot
        coxydave.waverobot.MyAppenderRobot
    
    
        MyAppenderRobot
        /_wave/robot/jsonrpc
    

Add a new directory (_wave) to the WAR file as shown and add a new XML file called capabilities.xml




Add the following content to this file:


  
    
  
  1


Ensure the app-engine.xml file contains the following:


    coxydavewaverobot
    1


At this point you should create a Google App Engine Application with the same name as your project. This will allow Netbeans to automatically deploy the war file to this application.




Once the application has been created it should be possible to 'Build the Main project' and use the 'Deploy to
Google App Engine' on the context menu for the project.

Once the application has been deployed to the Google App Engine, my application  is accessible within Google Wave using the following email address: coxydavewaverobot@appspot.com. Yours will be the ApplicationID@appspot.com. To use the robot just add the address to a new or existing wave. The robot will say hello and then wait for someone to add a new blip. At this point it will return the message in a new reply blip.

Hopefully this was useful. If anything is unclear please leave a comment on the blog and I will respond accordingly. Thank you.



Thursday, December 3, 2009

Google Wave Development

I finally managed to obtain a Google Wave account (thanks Harvey!).

After playing with Google Wave for about an hour I decided to that I should try to develop a robot for Wave. I used the tutorial on the Google Wave site to create a python Wave Robot, deployed it to Google App Engine and tried it in my wave. It works!

Python however is not my language of choice and I am going to learn how to use JAVA to produce Google Wave robots. I have found an article that explains how to use the WadRobotFramework to simplify the creation of JAVA Wave Robots.

If you would like to chat to me on Wave my address is coxydave at gmail dot com.