Wednesday, April 14, 2010

jVark - A small Java/XMPP library to play with Aardvark

After spending some time with Aardvark, i found the tool really great to get answers pretty fast. Aardvark provides many ways to interact with the service however there are no APIs available as such to interact with the service programmatically. Meanwhile I was trying to make my hands dirty with Google GTalk service and developed a small and silly utility to interact with Aardvark service through GTalk in Java.

The library is very basic and helps the developer to connect to Aardvark and fire some command and see the response from Aardvark. jVark source is available at

However the library requires significant amount of improvement for extensive use.

Friday, April 9, 2010

Distributed component events

The application is inspired from the Seam Component Events and uses Spring AOP for event trapping and JGroup for event distribution. The system is divided into two parts Event Generation and Event Consumption. Simple POJOs can be turned into event generator or event consumer.

// Event Generator
public class TemperatureManager{
    private Temperature currentTemperature;

    public void temperatureUpdated(Temperature t){
        this.currentTemperature = t;
// Event Consumer
public class GraphGenerator{
    private Temperature currentTemperature;

    public void updateTemperature(){
        // refresh graph

The above two classes can be part of a single JVM or multiple JVM, with JGroup in place Event Consumer will still consume the events generated by the Event Generator running in different JVM. Spring AOP keeps track of the RaiseEvent annotation and does all the distribution and communication stuff.

Full source code and required libraries with NetBeans project is available at : component-events.rar

Wednesday, April 7, 2010

A cool Vaadin application on Google App Engine

Vaadin, as we all know is a rapidly growing GWT based Java Web Framework. The coolest feature of Vaadin is that there is no client/server concept as it is in GWT. The developer can freely code anything "anywhere" and Vaadin will handle all the client/server related stuffs. 

One of our existing in-house production application is built using GWT and causing lot of difficulties for developers in terms of understanding the model and designing the proper application. So to retain all the GWT features and offload the additional burdens we (as such I) have decided to move to the Vaadin and redesign the existing application.

To convince the technical and management team and for demonstration purpose I developed a small application in Vaadin and uploaded it to the Google Application Engine (click here) so that others can also get the idea and at the same time I can load test the application and get all the execution details from the App Engine dashboard.  

The application contains a simple functionality where in which the user can design her custom entry forms, enter/save form data and finally view the saved data in a table. The application was built in few hours only so it doesn't have "next big ground breaking idea" or the nice GUI but Vaadin provides fairly nice UI which can work for any application to start with.

To speed up the development I extended the basic Form functionality to a Generic Form so that UI Forms can be created not only from Java Beans but from java.util.Map also. The reason to choose this is because some of our applications are purely data centric where in which numbers of UI forms are presented to users; however the fields in every form can very even after application deployment so to reduce the repetitive development effort I have taken the model where in which forms not only can be generated at runtime but can behave line a normal pre-coded form in most of the cases.

There are still many points to resolve before we finally switch over to Vaadin as our web application development framework but with the growing popularity of the framework and new initiative like Vaadin Directory acceptance would not be much difficult.

Vaadin demo application url:

Monday, April 5, 2010

gag - Google Annotations Gallery

gag is a new exciting open source library has been released by Google for Java. Google Annotations Gallery contains handful of annotations to spice up the code. This new library is aiming to express the code in the more realistic way than just plain old non-readable Javadoc comments. 
Not only one can leave expressive remarks in the code, but can use these annotations to draw attention to her poetic endeavors. Apart from static documentation some annotations use runtime instrumentation to perform annotated behavior also. The annotations are divided into following different categories:

Disclaimer: Disclaimer annotations allow you to disclose certain relevant facts about your code. If you want to ease your conscience with full transparency, then consider these annotations.

Enforceable: Enforceable Annotations are annotations enforced by dynamic bytecode instrumentation. Use the following annotations, then run your applications with the javaagent:gag-agent.jar option and your annotations get enforced at runtime.

Literary and Literary Verse: Coding is truly an art. These annotations can help you make your code come alive and help the artist within you be recognized. These speak for themselves . . . so to speak. You'll forever be revered for your code style and your code style. Literary Verse is a newly added sub package of Literary.

Remarks: Remarks annotations replaces the conventional Javadoc comments. These annotations helps better expressing the code than usual Javadoc comments.

Team: This is the new category added recently. The annotations express the team behavior and can be used to express events took place during team development.

Follwing is the list of my personal favorite annotations from the gag gallery:

From Desclaimer:"i swear its not my fault")"really, this is the coolest code i have ever written")"i m lost, i m lost, omg i m lost")

From Enforceable:

From Literary:"truly a fine mess")

From Remarks:"this is bullshit")"this is legend...... wait for it ....ary")"groovy", toWit="the method isnt required at all")

From Team:"this will surely put the Internet back in 90's")"asok", reason="well it wasnt his fault")

Well I am enjoying this treat and if you are a gut busting coder I am sure you will also enjoy too. Besides you can also submit your brilliant annotations to the library from the project mailing list.