Posts Tagged ‘Google App Engine’

Google Wave Robots: A Pictured Java Tutorial

September 24th, 2009

This post is a reference to Google’s own Java Tutorial for Google Wave Robots with an example of robot code that performs word replacement.

In my previous post, I have also briefly explained what Google Wave is about.

What you need to run a simple Java Wave Robot.

1) Eclipse IDE + JDK 6
2) Google Wave Java Client libraries
3) Google App Engine Account

Yes, you only require 3 items but most importantly, to access Google Wave, you need a Google Wave Id.

1) Eclipse IDE + JDK 6

Download Eclipse IDE here :


Download JDK 6 here :


Install the Google Plugin and the App Engine SDK:


Depending on the version of Eclipse IDE you downloaded, you will need to follow Google Wave’s guide to update using either one of the following URL:


2) Google Wave Java Client libraries
Download the Java client libraries from
Jar files required are :

  • wave-robot-api-.jar
  • json.jar
  • jsonrpc.jar

Save those files to your project library under \WEB-INF\lib


3) Code your Wave Robot

You can use Google Wave Java Tutorial source code directly if you want to, but I figure that I need to make some difference and hence thought of a simple words replacement robot.



My customization is highlighted in bold, you would want to change it with your own code.

Following is my source code of MarvyServlet (pardon me for the profanity in the source code, but this is a profanity filter robot afterall 🙂 )

package net.marvinlee.marvy;


public class MarvyServlet extends AbstractRobotServlet {

      public void processEvents(RobotMessageBundle bundle) {
        Wavelet wavelet = bundle.getWavelet();

        if (bundle.wasSelfAdded()) {
          Blip blip = wavelet.appendBlip();
          TextView textView = blip.getDocument();
          textView.append("I'm here to ensure you have a nice and polite wave.");

        for (Event e: bundle.getEvents()) {

          if (e.getType() == EventType.WAVELET_PARTICIPANTS_CHANGED) {
            Blip blip = wavelet.appendBlip();
            TextView textView = blip.getDocument();
            textView.append("Hi, everybody! I will be censoring profanities in your conversation.");

          if (e.getType() == EventType.BLIP_SUBMITTED) {
            Blip blip = e.getBlip();
            TextView textView = blip.getDocument();
            String blipText = textView.getText();

        private static String replaceProfanity(String text)
            String[] vulgars = {"shit", "damn", "fark"};
            String[] vulgarReplacement = {"sh#t", "darn", "f##k"};
            String niceText = "";

            System.out.println("Input:" + text);
            for (int i=0; i< vulgars.length; i++)
                String key = vulgars[i];
                if (text.indexOf(key) > 0)
                    text = text.replaceAll(vulgars[i], vulgarReplacement[i]);
                    System.out.println(vulgars[i] + " replaced with " + vulgarReplacement[i] );

                niceText = text;

            System.out.println("Output:" + niceText);
            return niceText;


capabilities.xml file under _wave

<?xml version="1.0" encoding="utf-8"?>
<w:robot xmlns:w="">
    <w:capability name="WAVELET_PARTICIPANTS_CHANGED" content="true" />
    <w:capability name="BLIP_SUBMITTED" content="true" />

web.xml under WEB-INF

<?xml version="1.0" encoding="utf-8"?>
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<web-app xmlns="" version="2.5">

appengine-web.xml – marvinleebot is my application name, and is unique in Google App Engine.
If you do not have a Google App Engine yet, follow step 4) below and come back again.

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="">

    <!-- Configure java.util.logging -->
        <property name="java.util.logging.config.file" value="WEB-INF/"/>


You can make other changes by viewing the Wave JavaDoc.

4) Deploy to Google App Engine
You will need to create an application in your Google App Engine first if you have not.


You might also need to verify your account with a mobile number, just follow through the steps.
Create your app here :
Your app name has to be unique so take some time to figure one or if you’re like me, just a lame bot name like marvinleebot might do the trick.

Once you’re done with your app name and created successfully, make sure that your appengine-web.xml file contains your own app name.


When you’re ready, just hit the Deploy App Engine Project button.


Submit your App Engine Account Email and Password.


5) Test your Wave Robot

As I’ve mentioned earlier, the single most important thing for it to work is to have a Google Wave Id.

If you have one, you can login Wave Sandbox at


If you do not have a Google Wave Id yet, request one here.

Create a new wave, and then add the bot you have created by adding a participant : <your_app_name>

This is how the bot looks like and how my marvinleebot worked (click to enlarge). I was using a test Wave Id from Nazroll.


You can also monitor your bot/app from your App Engine dashboard.

Google, Java, Open Source , , , , ,

Eclipse Day 2009 video presentations

September 14th, 2009

Eclipse Day is not the day the solar eclipse happened.

Eclipse Day 2009 is a full day event for developers to learn about different Eclipse projects and related technologies in Googleplex.

Being a Java Developer, Eclipse is one of the best Java IDE around, and in fact some developer uses Eclipse exclusively.

For non-developers who doesn’t know Eclipse, it is a tool for you to do programming and the tool itself is open source, meaning people can actually read the code on how the program runs, or even build additional tools for it.

Eclipse has grown a lot since founded in 2001, with numerous plugins for various technologies including OSGi, Android, and Google related apps like Google App Engine (GAE), Google Web Toolkit (GWT) and even the upcoming Google Wave (well you can do it on GAE Java ).

Some of the videos recorded from the Eclipse Day 2009.

For the full video listing, visit Google’s Open Source blog.

Google, Open Source, Software , , , , , ,

Build Java web applications and host on Google App Engine for Free

August 18th, 2009


I came to know about Google App Engine (GAE) in 2008 trying to find a host for my OpenSocial app experiment. It boast of a cloud computing architecture, so that when the traffic to your site grows, your application or site will not go down and with Google’s infrastructure, it can accommodate the high traffic.
You do not need to worry about the sudden extreme high load or load balancing for your application.
It is only half true though, read on to know why. 🙂

It sure sounds cool then, but to me the disappointment was it runs only in Python. That was in 2008.

However, there seems to be a lot of Java developers interested with having a Java version for GAE too. I wonder why?

So came the good news, although I came to know about it like a couple of months late. The Java version for GAE indeed has been made available since April 2009.

Official Google App Engine for Java :

The site has everything you need to know and get started on Google App Engine easily, and like any other useful frameworks, they have sample applications with source code bundled together.

Download the Google App Engine SDK for Java here.

In case you would like to have a summary of GAE Java:

JVM Version
App Engine runs on Java 6 virtual machine (JVM), but supports application built on JDK 5 and later. Uses Java Servlet for applications.

Note that not all Java classes are supported but most of them are. See the JRE Class White List here.

As there are so many Java technologies and frameworks, so by default with Google App Engine Java, it basically supports a huge list of libraries and frameworks including GWT (of course), Grails, JSF, MyFaces, Spring MVC, Struts, Tapestry, Tiles and some say OSGI.
For the full list, go here.

App Engine supports 2 standard Java interfaces: Java Data Objects (JDO) 2.3 and Java Persistence API (JPA) 1.0.

These interfaces are implemented using DataNucleus Access Platform, the open source implementation of these standards.

Access to database is via JDOQL using POJO (Plain Old Java Objects).

Other Services
URL Fetch :
Java Mail : (limitation of sending using Google account of the app administrator only)
Also supports application authentication using Google Accounts.
Cron Jobs :

The download for GAE Java includes a development server for your computer and you can run and test your application (war file) locally before uploading it to Google server.

The uploading can also be done with its AppCfg command tool.
Do note though, you need to create your application in App Engine Administration Console first, at :

Limitation of GAE Java
Knowing the features of GAE Java, you should also probably know a bit of its limitation.

1 The Java datastore interface does not support the != and IN filter operators that are implemented in the Python datastore interface. (In the Python interface, these operators are implemented in the client-side libraries as multiple datastore queries; they are not features of the datastore itself.)
2 Due to the way the App Engine datastore executes queries, a single query cannot use inequality filters (< <= >= >) on more than one property.

While you are still excited about the free hosting and the ability to withstand sudden high load for your application, (I’m not sure about DDOS though), there is a quota for the free bandwidth and resources on your Google App Engine Java application.

“App Engine will always remain free to get started. We believe these new levels will continue to serve a reasonably efficient application around 5 million page views per month, completely free.”

So instead of sourcing for web hosting, you get a free hosting for your Java application, which is a good deal considering it’s not easy to find one and to compare them with Google’s infra?
When the need arises and your application is so popular that it gets 5 million page views per month, I guess then it is time you decide to pay for the additional resources, or port your application with funding or sell it to somebody else (or Google?).

CPU Time (billable)

Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
Requests 1,300,000 requests 7,400 requests/minute 43,000,000 requests 30,000 requests/minute
Outgoing Bandwidth (billable, includes HTTPS) 1 gigabyte 56 megabytes/minute 1 gigabyte free; 1,046 gigabytes maximum 740 megabytes/minute
Incoming Bandwidth (billable, includes HTTPS) 1 gigabyte 56 megabytes/minute 1 gigabyte free; 1,046 gigabytes maximum 740 megabytes/minute
CPU Time (billable) 6.5 CPU-hours 15 CPU-minutes/minute 6.5 CPU-hours free; 1,729 CPU-hours maximum 72 CPU-minutes/minute


Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
Datastore API Calls 10,000,000 calls 57,000 calls/minute 140,000,000 calls 129,000 calls/minute
Stored Data (billable) 1 gigabyte None 1 gigabytes free; no maximum None
Data Sent to API 12 gigabytes 68 megabytes/minute 72 gigabytes 153 megabytes/minute
Data Received from API 115 gigabytes 659 megabytes/minute 695 gigabytes 1,484 megabytes/minute
Datastore CPU Time 60 CPU-hours 20 CPU-minutes/minute 1,200 CPU-hours 50 CPU-minutes/minute


Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
Mail API Calls 7,000 calls 32 calls/minute 1,700,000 calls 4,900 calls/minute
Recipients Emailed (billable) 2,000 recipients 8 recipients/minute 2,000 recipients free; 7,400,000 recipients maximum 5,100 recipients/minute
Admins Emailed 5,000 mails 24 mails/minute 3,000,000 mails 9,700 mails/minute
Message Body Data Sent 60 megabytes 340 kilobytes/minute 29 gigabytes 84 megabytes/minute
Attachments Sent 2,000 attachments 8 attachments/minute 2,900,000 attachments 8,100 attachments/minute
Attachment Data Sent 100 megabytes 560 kilobytes/minute 100 gigabytes 300 megabytes/minute

URL Fetch

Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
UrlFetch API Calls 657,000 calls 3,000 calls/minute 46,000,000 calls 32,000 calls/minute
UrlFetch Data Sent 4 gigabytes 22 megabytes/minute 1,046 gigabytes 740 megabytes/minute
UrlFetch Data Received 4 gigabytes 22 megabytes/minute 1,046 gigabytes 740 megabytes/minute

Image Manipulation

Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
Image Manipulation API Calls 864,000 calls 4,800 calls/minute 45,000,000 calls 31,000 calls/minute
Data Sent to API 1 gigabytes 5 megabytes/minute 560 gigabytes 400 megabytes/minute
Data Received from API 5 gigabytes 28 megabytes/minute 427 gigabytes 300 megabytes/minute
Transformations executed 2,500,000 transforms 14,000 transforms/minute 47,000,000 transforms 32,000 transforms/minute


Resource Free Default Quota Billing Enabled Quota
Daily Limit Maximum Rate Daily Limit Maximum Rate
Memcache API Calls 8,600,000 48,000 calls/minute 96,000,000 108,000 calls/minute
Data Sent to API 10 gigabytes 56 megabytes/minute 60 gigabytes 128 megabytes/minute
Data Received from API 50 gigabytes 284 megabytes/minute 315 gigabytes 640 megabytes/minute

Full Quota listing viewable here.

Google App Engine :
Google Plugin for Eclipse :
Eclipse Quick Start Guide :
Google App Engine FAQs :
Google App Engine SDK Code :
Sample Apps Code :

Sample application and photos:








Google, Internet, Java, Software, Technology , , , ,