GWT GIN and Dependency Injection

gwt gin

The best book on the market for learning Google Guice

 

History and Theory of GIN

Several years ago, the Google Brainiacs delivered a dependency injection framework called Guice. The idea behind Guice is to let the framework create all of your dependencies and you simply tell it what types of objects you would like to have to do your job. The Guice system will determine the correct implementation classes for your requested interfaces and give them to you when appropriate.

This works extremely well in production mode, but it actually gives other benefits. This way of development helps you to design your software in a much more decoupled and modular way. You begin to lean on interfaces instead of concrete classes which is usually a very good thing. Because you are dependent on interfaces, your code becomes much easier to test.

Now fast forward a bit and you find yourself in a development group writing large systems with the Google Web Toolkit. You have read all about how Guice makes life easier and you are struggling to write unit tests for your GWT based code. You think to yourself, “Geez, wouldn’t it be nice if I could just use Guice?” Now you can do just that, GWT GIN (GWT INjection) brings automated dependency injection into the client side of development. It is based on Guice and uses the same annotations for its dependency injection. Continue reading

Technorati Tags: , , , , , , , , , , , , , , , , ,

Using GWT Autobeans in JUnit Tests

gwt autobeans

Using GWT AutoBeans in JUnit Test Cases

GWT AutoBeans

Where GWT AutoBeans Started

GWT has created an awesome framework called AutoBeans. It was originally created to be part of the backing to the GWT RequestFactory change management. The basics is that given an interface that extends ValueProxy which represents a bean (using the typical getters and setters), AutoBeans does the actual creation and managing of that bean.

The details aren’t really that important, just push the I believe button if you are using GWT’s Request Factory. AutoBeans is used to bridge the gap between the server side Entity beans and the GWT front end’s Data Transfer Objects. The problem that is introduced when using AutoBeans is using the interfaces in your JUnit Tests.

The Google Wizards actually made AutoBeans so that it can be used in GWT Applications as well as out of them, such as desktop and server apps. Due to this feature, you can also use them in your JUnit tests. Here is an example on how to do just that. Continue reading

Technorati Tags: , , , , , , , , ,

GWT UIBinder Basics

GWT UIBinder Basic Concepts

This GWT Tutorial is regarding the basics of the GWT UIBinder technology.  If there is one thing that I can warn you about using this tool it would be to not over complicate it.  It can seem to be much more than it really is.  You can take a look at this Overview of GWT UIBinder to see what it really is.
Continue reading

Technorati Tags: , , , , , , ,