Archive

Archive for January, 2010

@ MUST \!A = 4\pi r^2 : Atmosphere 0.5 is released

Atmosphere 0.5 is released. This release includes many new features like Guice Support, asynchronous request processing, JMS support, JQuery support, Events listeners, etc..

IMG_0159.JPG

The community around Atmosphere is shaping and we have received many good feedback, which is reflected by the new features added:

Guice Support: Now quite simple to integrate with Google Guice using the new AtmosphrereGuiceServlet.

As simple a:

     @Override
    protected void configureServlets(){
        Map params = new HashMap();
        params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "org.atmosphere.samples.guice");
        serve("/chat*").with(AtmosphereGuiceServlet.class, params);
    }

New Broadcaster: Easy Asynchronous HTTP Request Processing

The new set of Broadcaster allow you to do full asynchronous http processing, similar to what RESTEasy offer:

@Path("/")
public class SimpleResource
{
   @GET
   @Path("basic")
   @Produces("text/plain")
   @Suspend(period=1)
   public Broadcastable getBasic(final @PathParam("topic") JerseySimpleBroadcaster broadcaster)                    throws Exception
   {
      Thread t = new Thread()
      {
         @Override
         public void run()
         {
            try
            {
               Response jaxrs = Response.ok("basic").type(MediaType.TEXT_PLAIN).build();
               broadcaster.broadcast(jaxrs);
            }
            catch (Exception e)
            {
               e.printStackTrace();
            }
         }
      };
      t.start();       
      return new Broadcastable(broadcaster);
   }
}

New AtmosphereResourceEventListener

You can now listen to events like resume, client disconnections and broadcast.

      @GET
    @Suspend(listeners={EventsLogger.class})
    public Broadcastable subscribe() {
        return broadcast("OK");
    } 

where

public class EventsLogger implements AtmosphereResourceEventListener {

    public EventsLogger() {
    }

    public void onResume(AtmosphereResourceEvent event) {
    }

    public void onDisconnect(AtmosphereResourceEvent event) {
    }

    public void onBroadcast(AtmosphereResourceEventevent) {
    }
  

The Meteor now supports scheduled and delayed events broadcasting

If you want to use Atmosphere without re-writing your Servlet based application (or don’t want to use the Servlet 3.0 Async API), you can use a Meteor instead and do all the same operation as when you use the annotations:

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
        Meteor m = Meteor.build(req, list, null);

        // Log all events on the concole.
        m.addListener(new EventsLogger());
        ....
        m.suspend(-1);

        // Periodic events broadcast
        m.schedule("Atmosphere is cool", 10, TimeUnit.SECONDS);
    }

Build in Framework support for different browser behaviors and proxy

The Framework is now adding the proper headers required to make it work with any proxy. The framework also make sure all browsers work out of the box by writing some default comments when a response get suspended so browser like Chome and Webkit works properly. The framework is also taking care of errant connections when hot deployment happens.

Improved algorithm for WebServer detection like App Engine, Tomcat, Jetty and GlassFish

The Framework is auto detecting which WebServer is running on in a more efficient way. The behaviour is also configurable by adding, in web.xml:

<init-param>                 
  <param-name>org.atmosphere.cpr.cometSupport</param-name>                 
  <param-value>AN EXISTING CometSupport implementation, or a customized one</param-value>  
</init-param>

JMS support

You can now cluster your application using JMS, Shoal or JGroups

    @POST
    @Broadcast
    @Cluster(
        name="chat",
        value=JMSFilter.class
    )
    public Broadcastable publish(@FormParam("message") String message){
        return broadcast(message);
    }

Annotation improvements

All annotations has been reviewed and some cool functionality added like resumeOnBroadcast, event listeners, etc. See the API for more information.

JQuery Support

See how simple it can be here.

Better Control of BroadcastFilter state, allowing easier agreggation/filtering/runing of events

If your application extensively broadcast events, it is important to pick up the right strategy to make sure all events reach your clients as fast as possible, even under high load. BroadcastAction has been added to make the writing BroadcastFilter’s aggreagation/filtering/pruning of events really simple.  Simple as

    public BroadcastAction filter(Object message) {
        if (message instanceof String){
            bufferedMessage.append(message);
            if (bufferedMessage.length() < maxBufferedString){
                return new BroadcastAction(ACTION.ABORT,message);
            } else {
                message = bufferedMessage.toString();
                bufferedMessage = new StringBuilder();
                return new BroadcastAction(ACTION.CONTINUE,message);
            }
        } else {
            return new BroadcastAction(message);
        }
    }

Powerful PubSub sample

Take a look at our PubSub sample that demonstrate all the power of Atmosphere!!! We also improved our white paper (PDF).

Woooooo!

As usual, Thanks to Matthias (ADF Faces), Paul (Jersey), Viktor (Akka), Hubert (Grizzly) and Catagay (PrimeFaces) and all the users for their contributions to Atmosphere! Special Thanks to Ning for allowing me to work on this project (and Thanks to Sun before Ning!).

For any questions or to download Atmosphere, go to our main site and use our Nabble forum (no subscription needed) or follow us on Twitter and tweet your questions there!

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.

Join 50 other followers