Overview of GWT Framework
What is Google?
Via John Battelle, Rick Skrenta’s remarkable piece on what Google have actually built. They don’t just have the world’s best search engine, they have the world’s largest and most scalable platform for developing huge web-based applications.
Google has taken the last 10 years of systems software research out of university labs, and built their own proprietary, production quality system. What is this platform that Google is building? It’s a distributed computing platform that can manage web-scale data sets on 100,000 node server clusters. It includes a petabyte, distributed, fault tolerant file system, distributed RPC code, probably network shared memory and process migration. And a data center management system which lets a handful of ops engineers effectively run 100,000 servers. Any of these projects could be the sole focus of a start up.
While competitors are targeting the individual applications Google has deployed, Google is building a massive, general purpose computing platform for web-scale programming.
Google App Engine
Google App Engine lets you run your web applications on Google's infrastructure. App Engine applications are easy to build, easy to maintain, and easy to scale as your traffic and data storage needs grow. With App Engine, there are no servers to maintain.
What is GWT(Google Web ToolKit ) ?
Writing browser based AJAX (Asynchronous JavaScript and XML) web applications can be very tedious and requires in depth knowledge of both JavaScript, and myriad browser quirks and incompatibilities. The Google Web Toolkit (GWT) is an open source framework that allows Java developers to easily develop AJAX web applications without learning the ins and outs of JavaScript and browser development.
GWT provides a Java API that lets you build component based GUIs while avoiding JavaScript, and abstracting the HTTP protocol and underlying browser DOM model. All of this achieved using the GWT compiler, which does not generate Java bytecode, rather it generates JavaScript! The GWT compiler takes your client side Java code and generates JavaScript. A compiled GWT application consists of fragments of HTML, XML and JavaScript. If you want to have your web application communicate with a web server, GWT has you covered as well. GWT has a Remote Procedure Call (RPC) mechanism that makes it easy for the client and server to pass Java objects back and forth.
The GWT Compiler
The GWT compiler converts Java source code into JavaScript. The GWT compiler supports most of the Java language and emulates a subset of the Java runtime library.
Language support
As of GWT version 1.7.1, the GWT compiler can compile source code that is compatible with J2SE.
Runtime Library Emulation
GWT provides a JRE emulation library. This library does NOT emulate all the J2SE and J2EE classes.
The GWT JRE emulation library supports some classes from java.lang and java.util packages. Find out which classes are supported here
Java regular expressions aren’t completely supported in GWT. If you are going to use regular expressions in your GWT application, you need to ensure that you only use Java regular expressions that have the same meaning in JavaScript.
The GWT JRE emulation library does not support Java Serialization. In its stead however, GWT has and RPC facility that provides automatic object serialization. This RPC facility allows client-side code to make remote method calls and pass GWT serialized objects as parameters.
GWT web applications are made up of two distinct pieces. The piece of your application that is sent across the network to a user, where it runs as JavaScript inside of a web browser, is referred to as client-side code. When writing client-side code it is important to keep in mind that this code will ultimately be turned into JavaScript. So make sure to only use libraries and Java language constructs that can be translated.
Deferred Binding
Deferred Binding is one of the key features that lets GWT produce well-optimized JavaScript code. As you saw earlier, the GWT compiler doesn’t support Java Reflection or dynamic class loading (also referred to as dynamic binding). This is because the JavaScript environment in which GWT applications run in doesn’t support it. Because dynamic binding is unavailable to GWT, GWT instead uses something called deferred binding. Deferred Binding is similar to dynamic class loading. While dynamic class loading occurs at runtime, Deferred Binding occurs at compile-time.
When the GWT Compiler compiles your client-side code, it determines all of the different “browser idiosyncrasies” it must support, and generates a separate, highly optimized version of the application for every specific configuration. So at the end of the day the compiler will generate a different version of your application for each different supported browser. But there is more to Deferred Binding than just multi-browser detection and support. Deferred Binding is a fully generic mechanism for handling context sensitive features.
A good example of where Deferred Binding is useful is Internationalization. The GWT Compiler uses Deferred Binding to generate completely separate versions of your application for each language. So if GWT supports 4 browsers, and you write your application in 4 languages, GWT will generate a 16 different permutations of your application at compile-time. During bootstrapping, at runtime, GWT picks the appropriate version of your application to show the user.
Project Structure
A GWT project must comply with a pre-defined structure in order to be accepted by the compiler. Thus, it’s mandatory that you define a global package for your application. The last part of the package name must be the name of the application (such as package.yourApplicationName). The XML file describing your application must be found at the root of this global package. The name of this file must be the name of the application followed by the .gwt.xml extension (for example, ApplicationName.gwt.xml). In addition, you must create three sub-packages:
client, which contains the Java code of the client side (this code must comply with the restrictions mentioned earlier)
server, which contains the Java code of the server side (you can use the full J2SE/J2EE API here)
public, which contains the HTML pages, CSS, and images of your application
Your project must declare several jars:
* gwt-dev-windows.jar or gwt-dev-linux.jar: Programming tools including the compiler. The embedded Web browser provided by GWT is platform-dependent.
* gwt-user.jar: The GWT runtime.
* gwt-servlet.jar: The jar to deploy on your application server with the code generated by the GWT compiler. It contains the RemoteServiceServlet.
The result of the compilation is stored in a single directory whose name is the name of the global package of your application. This directory contains all the elements (such as HTML pages, CSS, and JavaScript files) that comprise the client side of your application. These elements must be deployed inside your Web application, as usual.
Features of GWT
• Reusable UI Components
• Really Simple RPC
• Cross Browser Compatible
• Java script Native Interface(JSNI)
• Real Debugging
• Internationalization
• JUnit Integration’
• Completely Open Source
No comments:
Post a Comment