|
|
|||||||||||||||||||||||||||||||||||||||||||||
Jean-Francois Arcand's Blog
Finally a portable implementation! The Bayeux protocol now supported by the Atmosphere FrameworkPosted by jfarcand on June 18, 2009 at 08:46 PM | Permalink | Comments (1)The work done by the Cometd team, the java implementation of the Bayeux Protocol, can now run on top of the Atmosphere Framework. Under the hood, the proper Comet API is as usual detected!
The default implementation uses Jetty 7 Continuation under the hood...but now if you run it on top of the Atmosphere Framework, it will auto detect the container's native Comet API (or use the Servlet 3.0 async if available)! So you can now run the same application using GlassFish, Tomcat 5/6, Jetty 6, WebLogic, JBossWeb and event Tomcat 4 (happy 10 years!) So for the first time (why? read Matthias here), we have finally a PORTABLE Bayeux protocol implementation! See the official announcement here (and how to try it). For any questions, go to our main site and use our Nabble forum (no subscription needed) or follow us on Twitter and tweet your questions there! technorati: atmosphere framework bayeux protocol comet Atmosphere 0.2 GA now availablePosted by jfarcand on June 12, 2009 at 08:30 PM | Permalink | Comments (0)Finally, Atmosphere 0.2 released with support for annotations for REST application, improved support for Tomcat/Jetty/GlassFish, native support for JBossWeb 2.1.x, and EJB/External components broadcast lookup available.
technorati: atmosphere framework jersey comet Getting started with the Atmosphere Framework part III: Dead Simple async REST applicationPosted by jfarcand on June 10, 2009 at 05:42 PM | Permalink | Comments (0)In that part, I describe a simple asynchronous REST application using behaviors.js, prototype.js and the Atmosphere Framework. As usual, you can deploy the app anywhere! If you interested to look for a complex Atmosphere application, take a look at the Twitter revisited one.
To understand the basic of Atmosphere, I recommend you take a quick look at part I and II. This time I will explains a simple application, which uses long polling for suspending connection. First, let's see what the war file structure looks like: The two important files are the RestLongPolling, which contains the server side code, and the counter.js, which contains the client side code. The client simply looks like: On the screen, it looks like:
As soon as you click, the counter send a request, appending the count value to the URL. Every browser connected will be updated as soon a click event happens. The idea here is to really show something simple. Now, on the server side, we only have (I'm not kidding!): So, when the Browser load the page, the counter.poll will invoke, on the server side the suspend() method. Since that method is annotated with the @Suspend annotation, the connection will be suspended after the method execution, waiting for event. You can see the Browser icon spinning in that demo as the GET has not yet returned. As soon as a click happens (line 8), the POST will invoke the increment(..) (line 26) method, and since the method is annotated with the @ResumeOnBroadcast, then the returned value will be broadcasted to all suspended connections, then written on the wire, and then the connection will be resumed. On the Browser side, the spinning will stop for a few milliseconds, as the Browser will re-issue a GET, which will again be suspended. Note that for that simple demo, I'm not updating the client side using the returned value of the increment(..) method to keep it extremely simple. Now technically this application use the Atmosphere module called core, which build on top of the Comet Portable Runtime (CPR), hence allowing the application to be deployed anywhere. The CPR always auto detect the container is running on top of, like: The two log above are showing that if the framework detect Servlet 3.0 Async Support implementation, it will use it. If not, then it will use the native Comet implementation. Finally, two descriptors are needed to make the application works. The first one, the atmosphere.xml, just tells Atmosphere to use Jersey's Servlet to process request. Under the hood, all annotation processing and REST support comes for free from Jersey: Next, the web.xml The only important line above is the init-param that tells Jersey were to lookup our resources, e.g. under org.atmosphere.samples.rest.counter. That's it. You can download the sample from here (and many more here). For any questions, go to our main site and use our Nabble forum (no subscription needed) or follow us on Twitter and tweet your questions there! technorati: atmosphere framework jersey comet High Five from JavaOnePosted by jfarcand on May 30, 2009 at 07:43 PM | Permalink | Comments (3)High Five from JavaOne, or 5 chances to listen to an ugly Quebecois accent. This year I'm invading JavaOne again, and 5 times...4 times on Tuesday (nice scheduling tool...NOTD!). Which one I would pick? Well the new Atmosphere baby is certainly the one I like the most! This is the last JavaOne as we know it, so don't miss any party :-) See you there :-) Grizzly 2.0.0-M2 released.Posted by jfarcand on May 25, 2009 at 06:36 PM | Permalink | Comments (0)Small entry for those who aren't following us on twitter.com/project_grizzly. Project Grizzly 2.0.0-M2 is now officially available.
The official announcement was posted here or here. Thanks to all the feedback we have got since 2.0.0-M1 release, and don't stop!
technorati: grizzly nio framework embedded Getting started with the Atmosphere Framework part II: Writing a REST application with Comet supportPosted by jfarcand on May 21, 2009 at 05:56 PM | Permalink | Comments (0)This time I will demonstrate how easy and dead simple is to write a REST application using Atmosphere annotations…with the help of Jersey! In part I I’ve described how easy it is to write an asynchronous/comet based application using an AtmosphereHandler. I strongly recommend you first read part I to understand the steps needed to generate the proper layout for your application. I also assume you already know how to write REST application using Jersey. Why? Let me introduce a new module available with the Atmosphere Framework named atmosphere-core. As a reminder, in part I have introduced atmosphere-cpr (Comet Portable Runtime), which allow a developer to write an AtmosphereHandler and deploy it in any Servlet container. Under the hood, the CPR always make sure its use the native comet support available, e.g if deployed on WebLogic, use the AsyncServlet, if deployed in Grizzy/GlassFish, use the Grizzly Comet Framework etc. Yes, you write once and deploy everywhere your Comet application. The atmosphere-core module builds on top of the CPR and Jersey! The aim of Atmosphere is to simplify the development of Comet application, and since every time I’ve used Jersey, I always found it is really easy to write powerful application…then I've decided to build on top of Jersey! So here we come: announcing atmosphere-core v.0.2-M1, powered by atmosphere-cpr and Jersey (including all functionality supported by Jersey!). Like it part I, let’s first define our META-INF/atmosphere.xml: If we compare with part I, this time the class-name we are using is a special AtmosphereHandler called ReflectorServletProcessor (RSP). The RSP listen to AtmosphereEvent like a normal AtmosphereHandler, but delegate the processing on the event to a servlet.service() method (a normal Servlet invocation), with a special addition which consist of storing the AtmosphereEvent as an HttpServletRequest attribute. The idea here is to support existing framework (like Jersey, Strut, JSF, etc.) without the need to modify those to support Atmosphere. Most of those frameworks support extension point, and all of them just need a reference to the AtmosphereEvent in order to suspend, resume and broadcast. Why is it called a Reflector? Mostly because every message broadcasted will be sent back to the client without any filtering or transformation. Say differently all suspended response will write as it is the message they receive (See AtmosphereHandler.onMessage for more info). Anyway as a developer you don’t need to know that…but if you are a framework developer, this is how you can use the Atmosphere Framework easily. In the current case, the RSP is configured using the Jersey’s main Servlet, called ServletContainer. As soon as you deploy your application, the Atmosphere framework will handle the lifecycle of the Jersey Servlet. Next step is to write the web.xml: In short, we define our usual AtmosphereServlet and maps all requests to /resources to it. There is two Jersey related properties defined. The only one you need to care is com.sun.jersey.config.property.packages. The property is required by Jersey to locate where to look for your application. Eventually Atmosphere will auto detect those, but for now you need to add it. In our case, it the fully qualified name of the package of our application. The second property is the Jersey extension point. No need to talk about it this time. We are now ready to re-write the chat demo described in part I, re-using the same javascript code on the client side but this time without using any AtmosphereHandler, AtmosphereEvent, or Broadcaster, but instead using annotation (yeah!). Let’s start with the survival tool of Atmosphere annotation, which are @Suspend, @Resume and @Broadcast. You can write very powerful application by just using those I will talk about more annotations in part III). What the annotations are for:
So without going into the details of REST and Jersey (see this tutorial), writing a chat application just consist of: Simple, is it? The way it works is the cometGet will be invoked, its returned value will be written back to the client and the response suspended. When the cometPost gets invoked, it’s returned value will be broadcasted, e.g. all suspended responses will be invoked and the value written as it is to the client since we are using the ReflectorServletProcessor. That’s it! With the use of two simple annotations, we were able to write our first atmosphere-core REST based application. OK, it's REST twisted, but still :-). You can download the entire application here, or browse the source code. If you are already using Atmosphere, you must upgrade to Atmosphere 0.2-M1 to take advantages of those new functionality. As usual, THANKS to the great feedback I’ve got so far. Early adopter, you make a big difference! For any questions, go to our main site and use our Nabble forum (no subscription needed) or follow us on Twitter and tweet your questions there! And if you are going to JavaOne, don’t miss the Atmosphere BOF on Tuesday @ 8h30pm with Jersey lead and Java Champion’s Paul Sandoz, which is a great speaker without a Quebecois accent technorati: atmosphere comet Atmosphere 0.1 GA available with Twitter, Flickr and Chat samplePosted by jfarcand on April 24, 2009 at 08:07 AM | Permalink | Comments (3)After couple of weeks collecting feedback from the newly created community (THANKS!), Atmosphere 0.1 GA is now available with support for Glassfish 1/2/3, Weblogic 9.x and up, Tomcat 4/5/6, Jetty 4/5/6/7, Grizzly 1.9.x, Winstone, etc. All of the above containers are supported out-of-the-box, e.g. you download our web.xml template, set your servlet-mapping, and you ready to write a portable Comet application. Based on the container you are running on, Atmosphere will auto-detect their native Comet API and uses it, or fake it if not found (like Tomcat 4). The only one "container" that doesn't work is...Servlet 3.0 Async proposal! Why? Because Servlet 3.0 Async is not enabled by default (strange decision ;-)) so you must either annotate your Servlet to tell the container you want to use async features, or you add a special element in web.xml. But since it requires the Servlet 3.0 DTD, Atmosphere cannot support 3.0 Async as an application using a web.xml targeted for 3.0 will not deploy in Servlet 2.5 Container (the majority of them!). Yes, that's bad (to not say that suck..I did try all kind of hack without success!)! So if you want to use Atmosphere with Servlet 3.0, your application will not be portable..unless you switch your web.xml...NOT! Hopefully I can make the Servlet team change their decision as this is really really bad for any framework that want to support 3.0 and existing native Comet implementation. Atmosphere 0.1 natively supports:
How to get started? Read this simple intro (or just drop Atmosphere CPR under WEB-INF/lib) or download one of our samples
What's next? Before 0.2 release my plan is to write a complete tutorial which demonstrate all the Atmosphere powerful features. Even now, it is crystal clear than writing a Comet application is much more easy and fast than using any native implementation, including the upcoming Servlet 3.0. So start today using it! As usual, feedback appreciated by either sending your questions to users@atmosphere.dev.java.net or by tweeting us! technorati: atmosphere comet Grizzly 2.0.0-M1 released! With extra: History of GrizzlyPosted by jfarcand on April 21, 2009 at 02:54 PM | Permalink | Comments (0)Today we are releasing our first Grizzly 2.0 release, which we are working on since almost 2 years. Get ready for the revolution! But how this Grizzly things started? It has been years since I've jumped into the blogosphere and started talking about Grizzly. Officially, Grizzly started in 2004 when Vivek Nagar and I talked about NIO. At that time I wanted to propose a new Tomcat connection based on NIO but got some resistance with the other developers. So we decided to keep it for us, specially after we did some benchmarks against the Netscape's WebServer Sun have :-). Developing Grizzly 0.x was a challenge as it was "sandboxed" by our application server internal API (and gigantic "resistance" from the think thanks ;-)). I wasn't allow to change any API there (quite a challenge)...Grizzly 1.0 was born in a sandbox, and yes some of its design was horrible, but the SJS AS team was happy as no API were changed and Grizzly got finally accepted in SJSAS 8.1 PE (not EE :-)) Then we open sourced what has becomes GlassFish and make a lot of noise about Grizzly/GlassFish. Starting from zero, we then worked hard to build a community around Grizzly inside GlassFish. We got a surprisingly nice numbers of early adopter event if the API were not perfect. Amongst them was Phobos, AsyncWeb, Jetty, Sailfin Convergence Load Balancer (zzzzzz Sailfin uses Grizzly 1.0 and 1.8.6 under the hood, but they don't talk about it;-)), GlassFish v3, and the popular Grizzly JRuby (which is still the foundation of GlassFish v3's JRuby support!). ![]() Over 2006, we worked the next version, called Peregrine, with peoples from MQ, IIOP, Performance, SOA, etc. During that time, we also saw the Grizzly community growing and we've decided to release an intermediate version 1.5, which goal was to not break the compatibility with 1.0. That was an extremely tough decision for me as it left aside a lot of great designs/code Charlie did for Peregrine. But now I think we took the right decision, looking at the adoption and more important, the community around Grizzly. We have then started working on Grizzly 2.0 based on what we have learned from 1.x, 1.5.x, Peregrine, the current community feedback and of course new ideas, without sandboxing ourself (so breaking compatibility with the NIO framework 1.9.x). We also switched the lead so API gets better designed without noise from the pass :-)...we also merged Ken's and John works, let Alexey innovates and now get ready!. With this healthy community we are now ready to make the big step: 2.0.0-M1 is now available for download Read Alexey's blog about what this release include, download it, browse Javadoc or gives feedback on users@grizzly.dev.java.net. Now what will happens with 1.9.15 and up? We will maintain innovations for the 1.9.15 event after 2.0.0 GA as we don't want to force the community to upgrade. More important, we stay untouched the popular APIs like GrizzlyWebServer (I,II,II,IV, V, VI). So we have years before us :-) Also major users of 1.9.x (to name one: GlassFish v3!) will soon be released so we have no plan to stop innovating/fixing bugs with 1.9.x...we still fix issues for 1.0.x users, so no worries! Want to follow more about the monster community? Follow us on Twitter!
technorati: grizzly web server embedded 1.9.11 released! What's cool with Grizzly 1.9.11?Posted by jfarcand on April 08, 2009 at 04:17 PM | Permalink | Comments (0)![]() Grizzly 1.9.11 is freshly released. What's cool? Get ready: Servlet Deployer, HttpService OSGi spec support, XML config a la "Spring", Performance improvement...and a new LOGO. Meet the new monster! ![]() ![]() Here we go with a subset of what WE accomplished since our last release. The difference? Sun representative are now in minority, and we are getting patch after patch after patch for with new feature!. Here is a summary of what's new:
What's next: WebSocket support, http client, leader follower thread pool support, WarAdapter, etc...and Grizzly 2.0 M1 most probably next week! For any questions, post them to users@grizzly.dev.java.net or tweet us here.
technorati: grizzly web server Extending the Grizzly HTTP Runtime VII: Cluster/load balance GrizzlyAdapter using ApachePosted by jfarcand on April 08, 2009 at 03:49 PM | Permalink | Comments (1)With the release of Grizzly 1.9.11, it is now possible to cluster/load balance your GrizzlyAdapter using Apache! As I described in the previous entry on the topic(I,II,II,IV, V, VI), it is quite simple to embed Grizzly using its' extension point: GrizzlyAdapter: Now let's assume you want to add clustering/load balancing support to your GrizzlyAdapter. To add such support, let's use Apache 2 and mod_jk. To install mod_jk and Apache, just install mod_jk module (see here for an example):
With the above, we are telling Apache to forward (via mod_jk) all requests starting with /grizzly to .... GrizzlyWebServer! How? Let's take the previous example and add support for mod_jk: Just compile, java -jar ...That's it! Now any blog talking about mod_jk clustering/load balancing configuration can be used with your GrizzlyAdapter. As an example, take a look at this one For any questions, post them to users@grizzly.dev.java.net or tweet us here.
technorati: grizzly web server embedded |
July 2009
Search this blog:CategoriesCommunity: GlassfishCommunity: Java Enterprise Community: JDK J2EE Archives
June 2009 Recent EntriesFinally a portable implementation! The Bayeux protocol now supported by the Atmosphere Framework Atmosphere 0.2 GA now available Getting started with the Atmosphere Framework part III: Dead Simple async REST application | ||||||||||||||||||||||||||||||||||||||||||||
|
|