The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


Atmosphere 0.1-ALPHA2 released with support for any WebServer (WebSphere,WLS, etc.), and Servlet 3.0 Async

Posted by jfarcand on April 1, 2009 at 8:52 PM PDT

Second release (thanks for the feedback so far!), this time with support for any WebServer and the few one that support the Servlet 3.0 Async API.

IMG_2439.JPG

What's new since our last release? First, if the WebServer you deploy on support the Servlet 3.0 Async specification, the Atmosphere runtime will detect it and will run using those API. Note that your AtmosphereHandler doesn't have to use the new API to keep portability with other WebServer that aren't yet supporting those API. Second, if the WebServer you deploy on doesn't support Comet, the Atmosphere runtime will emulate Comet support by optimally blocking threads when needed. So it means GlassFish v1, Jetty 4/5, Tomcat4/5, BEA's WLS, WebSphere etc. can now be used with Atmosphere. Finally, the Broadcaster now support custom thread pool (ExecutorService), which you can configure from your AtmosphereHandler:

    public AtmosphereEvent
            onMessage(AtmosphereEvent event) throws IOException {
        HttpServletRequest req = event.getRequest();
        HttpServletResponse res = event.getResponse();

        event.getBroadcaster().setExecutorService(
                    Executors.newCachedThreadPool());
        if (event.isResuming()) {
            String script = BEGIN_SCRIPT_TAG + "window.parent.app.listen();\n" + END_SCRIPT_TAG;

            res.getWriter().write(script);
            res.getWriter().flush();
        } else {
            res.getWriter().write(event.getMessage().toString());
            res.getWriter().flush();
        }
        return event;
    }

Using a thread pool when broadcasting messages can save your life and greatly improve scalability of your application!

Ready to write your first AtmosphereHandler? Download the latest release from here. As usual, feedback appreciated by either sending your questions to users@atmosphere.dev.java.net or by tweeting us!

technorati:

Related Topics >> Glassfish      
Comments
Comments are listed in date ascending order (oldest first)