GoogleWebToolkit example plugin

Document created by Coolcat Champion on May 8, 2008Last modified by Coolcat Champion on Oct 13, 2008
Version 8Show Document
  • View in full screen mode

What is GoogleWebToolkit?

GoogleWebToolkit (GWT) is a framework, that allows to develop AJAX applications. It provides a compiler that compiles Java code into JavaScript code. You can write your  application, under some restrictions, in Java. That enables you to share code between client and server side, and remote calls can easily done by an method call. You can build your web page using several AWT like widgets, which make your webpage look identically, regardless which browser you are using.

I recommend you familiarize with GWT, before trying to use it with Openfire.


Integrating GWT into Openfire

Openfire makes internally use of Jetty, with provides an servlet container. So it is possible to run an GWT servlet with openfire. However, it's a bit tricky.


I have written an minimal plugin as example. It uses AJAX to retrieve the current date and time from the server. My implementation has probably bad performance (*). If you come up with an better solution, please let me know.


(*) It's synchronized for thread safety, so it can only process one remote call at once.



  • Obviously you will need a current version of GoogleWebToolkit.

    You will need to copy gwt-servlet.jar from your GWT installation into plugins lib directory. It's not included, because it's "big" and part of GWT, so you have it already.
  • I supply two scripts for easy compiling client and server side code. Both are written in usual Linux Bash-shell. Nothing complicated, you will be able to translate it easily to your systems shell language. In any case you should take a quick look at it, probably you want to change the path to your GWT installation.

  • You can not licence your plugin under GPLv2, because GWT is under Apache License 2.0. GPLv2 is not compatible with Apache License 2.0. You could licence your plugin for example under GNU General Public License Version 3.


Directory structure

 |- lib
 |   |- gwt-servlet.jar  <- NOT SUPPLIED, copy it from your GWT installation
 |- scripts              <- (ant script does ignore this directory)
 |   |- gwt-client       <- compile Java client code to JavaScript and place it in 'src/web/gwt'
 |   |- gwt-server       <- compile Plugin to JAR file (call 'ant plugins')
 |- src
 |   |- gwt/org/jivesoftware/openfire/plugin <- (ant script does ignore this directory)
 |   |   |- gwt
 |   |       |- Test.gwt.xml    <- client side module config
 |   |       |- public          <- content of this directory is copied to 'src/web/gwt'
 |   |       |   |- Test.html   <- JavaScript code from will be included here.
 |   |       |- client          <- directory for client side code
 |   |           |-   <- entry point for client
 |   |           |-   <- remote service: asynchronous Interface
 |   |- java/org/jivesoftware/openfire/plugin
 |   |   |- gwt
 |   |   |   |- server     <- directory for server side code
 |   |   |   |   |-  <- remote service: Servlet           (here is the tricky part...)
 |   |   |   |- client     <- directory for shared code
 |   |   |       |-      <- remote service: Interface
 |   |   |-       <- basic plugin
 |   |- web
 |       |- WEB-INF
 |       |   |- web-custom.xml <- servlet config
 |       |- gwt            <- compiled JavaScript code for clients is placed here
 |- plugin.xml         <- basic plugin config, integration into admin console