Jean-Francois Arcand works for Ning.com. Previously he has worked for Sun Microsystems where he created Grizzly (NIO Framework) , Atmosphere and was a significant contributor to the GlassFish Application Server. Jean-Francois is a DZone MVB and is not an employee of DZone and has posted 23 posts at DZone. You can read more from them at their website. View Full User Profile

Entering the Atmosphere Framework: Comet for Everyone, Everywhere

10.16.2008
| 8388 views |
  • submit to reddit

Introducing Atmosphere, a new framework for building portable Comet based applications. Yes, portable, which means it can run on Tomcat, Jetty, Grizzly/GlassFish or any web server that support Servlet 2.5 ... and without the needs to learn all those private API floating around...

IMG_0090 copy.JPG

Currently, writing a portable Comet application is impossible: JBossWeb has AIO, Tomcat has its a different AIO API, Jetty has its Continuation API and pre Servlet 3.0 API support, Grizzly has its Comet Framework and Grizzlet API, etc. So, framework like DWR, ICEFaces and Bindows all added native support and abstracted a layer in order to support different Comet API. Worse, if your application uses those API directly, then you are stuck with one Web Server. Not bad if you are using Grizzly Comet, but if you are using the competitor, then you cannot meet the Grizzly!

The current Servlet EG are working on a proposal to add support for Comet in the upcoming Servlet 3.0 specification, but before the planet fully supports the spec it may takes ages. And the proposal will contains a small subset of the current set of features some containers already supports like asynchronous I/O (Tomcat, Grizzly), container-managed thread pool for concurrently handling the push operations, filters for push operations. etc. Not to say that using Atmosphere, framework will not longer have to care about native implementation, but instead build on top of Atmosphere. Protocol like Bayeux will comes for free, and will run on all WebServer by under the hood using their native API.

So I'm launching Atmosphere, hoping to close the gap and simplify the creation of Comet based application based on the experience/feedback I got since two year with the Grizzly Comet Framework. Atmosphere is a POJO based framework using Inversion of Control (IoC), trying to bring Ajax Push/Comet to the masses! Atmosphere build on top of Jersey and Grizzly Comet code. Now I've to be honest, the project is just starting (got some troubles internally since I've leaked the information :-)) and it might takes a couple of months before I can support all WebServer. What I'm targeting is to evolve the Grizzlet concept and make the programming model really easy. So far what I have looks like:

 


/**
 * This Grizzlet can only receive push from that application, e.g. from other Grizzlet defined under the myGrizzlet/* path 
 * (defined using the @Path annotation)
 */
@Grizzlet(Grizzlet.Scope.APPLICATION)
@Path("myGrizzlet")
public class MyGrizzlet{
    /**
     * Broadcast notification to all Grizzlet defined inside the current VM.
     */
    @Broadcaster(Grizzlet.Scope.VM)
    private Broadcaster bc;
    
    /**
     * Suspend the connection for 6000 milliseconds on GET request, and push the 
     * return value.
     */
    @Suspend(6000)
    @GET     
    @Push
    public String onGet(){        
        bc.brodcast("A new user has connected");
        return "Suspending the connection";
    }


    /**
     * On POST, push the return value.
     */
    @POST     
    @Push
    public String onPost(@Context HttpServletRequest req,
                         @Context HttpServletResponse res) throws IOException{  
        res.setStatus(200);
        res.getWriter().println("OK, info pushed");
        return req.getParameter("chatMessage");
    }    
    
    /**
     * Resume the connection after one push (long polling), and push the return
     * value.
     */
    @Resume(1)
    @Push
    public String onPush(String event,@Context HttpServletResponse res) throws IOException{
        res.getWriter().println(event);  
        return "Resuming the connection";
    }
}

 

The example above is of course quite simple, but it demonstrate the goal I have with Atmosphere: make it easy for anybody to write Comet application. The above is a ridiculous Chat application which suspend request when a GET is sent, push data on POST and just blindly write the "pushed" data.

So, In the upcoming weeks I will start giving more examples and more important, will push the code to the repository. I'm unfortunately distracted by other projects I'm working on so the project might start slowly, but my goal is to build a strong community like I did with the Grizzly Project, hence the project evolve faster and open of anybody....Interested? Just sign to the Atmosphere mailing list. I've plenty of work for anybody interested to participate!

From http://weblogs.java.net/blog/jfarcand

Published at DZone with permission of Jean-Francois Arcand, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Clemens Eisserer replied on Thu, 2008/10/16 - 10:32am

What would be really great would be if you could refactor out the suspend/resume stuff so that users which would like to use this Servlet-3 functionality but not all the others tuff (Grizzly, Comet, ...) could use it.

I am e.g. only interested in an abstraction layer for the suspend/resume stuff, everything else is overhead for me ;)

jame jack replied on Wed, 2009/06/17 - 7:50pm

تحميل برامج برامج جوالات العاب بنات تكنولوجيا كتب تعليم UltraSurf Internet Download Manager ProgDVB برامج مجانية أفضل المواقع العربية مشاهدة محطات مشفرة Online TV Player 3.0.0.940 Internet Download Manager 5.17 Build 4 رقص شرقي anyTV Pro 4.32 OnLineLive 7.1.1 هزي يانواعم ProgDVB 6.06.2 SopCast 3.0.3 Falco Image Studio 3.6 لعبة تزلج على الجليد UltraSurf 9.4 كاثرين هيغل Katherine Heigl محطة غنوة FreeZ Online TV 1.0 Free Video to Mp3 Converter 3.1.3.51 Advanced MP3 Converter 2.10 Xilisoft Video to Audio Converter 5.1.23.0515 Blaze Media Pro 8.02 AKRAM Media Creator 1.11 DVD Audio Extractor 4.5.4 Free WMA to MP3 Converter 1.16 لعبة نينجا المتقدم لعبة قذف كرة لعبة دراجات البهلوانية لعبة اعداء الغابة تحميل برامج Download DivX Subtitles 2.0 BullGuard 8.5 Google Chrome 2.0.181.1 Dev Dell Studio XPS Desktop 435T Intel Matrix Storage Manager A00 Gigabyte GA-EP45-UD3P Bios F9 Ambush HDConvertToX 1.1.229.1764 MSI Wind Nettop CS 120 Realtek Audio Driver 5.10.0.5618 Biostar T41-A7 6.x Realtek On-Board Audio Driver 5.10.0.5735 for 2000/2003/XP TweakNow RegCleaner 4.1.1 SpeedItup Free 4.97 برامج العاب - Internet Download Manager - برامج جوالات - العاب - محطة غنوة - قنوات فضائية - بنات - تكنولوجيا - كتب تعليم - UltraSurf -

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.