Sunday, December 20, 2009

Real Time Web Application Development Challenges and HTML 5


In the traditional web architecture the reliable message flow between the server and the browser is a problem , as the server is not only forwarding the message but also most of the other work like translating the messages. This might result in Server becoming non scalable.

There were many attempts to simulate two way communication initiated by the server towards the client. One of the most notable approach is Comet.

Comet uses a technique referred as hanging GET or pending POST. In this the completion of an HTTP response is delayed until the server has something to send. This is generally implemented in JavaScript.

But there are some problems with this approach -
-Resource consumption is high as many connections are opened and closed.
-Setup and teardown of connections will consume more resources if secure connections are used.

HTML 5 may be the answer to these issues.

This provides many enhancements to the browsers and will redefine how internet communicates. The communication section of HTML 5 specification defines WebSockets and ServerSentEvents. These features will enable two way communication a reality for browsers. This will change the way in which real time web applications are created.

The main features are

  1. Web Sockets : Usually most of what is transmitted in web will be protocol information and padding. Web Sockets establishes a true two-way connection between server and the browser. This is essentially a pure TCP socket through which any application data can flow in either direction. This is more efficient than traditional HTTP requests as the non payload information is not required.
  2. Server sent Events : Two-way real time communication pattern common in web today is not taken into account in traditional HTTP. Through Sever Sent Events, a server can initiate the transmission of data. This is a standard describing how servers can initiate transmission of data to client once the initial connection with client is established.
  3. Cross Document Messaging : This provides a system in which different documents are allowed to securely communicate across different origins. This will allow an application to communicate with server over many different channels.
  4. Cross Origin resource Sharing : This will allow browsers to do site aggregation. Result may be better performance.







Monday, December 14, 2009

Java EE 6 Features

Lets look at the new sexy Java EE6 features

EJB Lite

EJB Lite is coming from the fact that- most of the ejb applications simply use features like persistence management, declarative transaction, stateless session beans etc.

EJB Lite will allow simple , lightweight implementations. This will also reduce the learning curve required (It might be just learning a handful of annotations). Very soon there may be Java EE application servers which implement EJB Lite instead of the complete Ejb3.1 spec.

Some of the features in the EJB Lite are
  1. Stateless, State full, Singleton session beans
  2. Interceptors
  3. Declarative Security
  4. Declarative Transactions etc
EJB Lite does not have the following features
  1. Message driven beans
  2. Remote interfaces
  3. Asynchronous invocation
  4. Corba interoperability etc.

Managed Beans 1.0

This is simply a POJO which is treated as a managed component by the container.
It can make use of some of the predefined Java EE features like lifecycle management and injection.

  1. @Resource
  2. @PostConstruct
  3. @PreDestroy etc

More Later...

Sunday, December 6, 2009

Project COIN

Project coin is aiming to find out the small language changes that should be added to the JDK.
Around 70 proposals were submitted in the period of Feb-27, 2009 to Mar-30, 2009 and discussed in coin developer forum.

Out of these proposals 5 or so are selected for including in Jdk7.

Some of the accepted proposals are -

1. Using Strings in switch
- Ability to switch on string values

2. Automatic resource management
- Having try like statement to declare one or more Resources. Scope of the resource is limited by that of the statement. When the statement completes normally or abruptly , all the resources are closed automatically.

3. Improved Type Inference for Generic Instance Creation
- When the full parameterized type is obvious from the context, then the parameterized type of the constructor could be replaced with empty set of type parameters.

4. Simplified Varargs method invocation.
- Reduces the total number of warnings reported to and suppressed by programmers.

5. Language support for JSR 292

Some of the proposals which are considered but not accepted are



This project is sponsored by The Compiler Group


Wednesday, December 2, 2009

Project Lombok


How much boilerplate code we write in our Java classes? Most of the time it will be minimum 100 lines. Even if we have a simple pojo - we have to write all the getters and setters, toString, equals, hashcode method etc.
Finally with all these code it will be easy to lose any bug which is hidden in the code.

Project Lombok is the answer to this problem (if you think this is a problem :) )

Instead of writing all these boilerplate code we can just give the annotation @Data.
Lombok is completely integrated with Eclipse , so all these generated methods will be visible in the outline view.

To make Lombok work with Javac, just add lombok.jar to the classpath.
Other annotation provided by Lombok is @Getter and @Setter.

Another interesting annotation is @Cleanup - this will help by automatically generate try finally blocks to call close on resource objects.

The full list can be found here - Project Lombok Overview


Project Jigsaw

Project Jigsaw is focused on the goal of modularizing JDK. Such a thing will allow applications to be installed with only the required components of JDK.

In the upcoming Jdk7 SUN's primary goal is to modularize jdk.