<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Jean-Francois Arcand&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/" />
<modified>2008-07-17T20:20:07Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2008, jfarcand</copyright>
<entry>
<title>Extending the Grizzly HTTP Runtime part IV: Adding native PHP with support for the Bayeux Protocol</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_4.html" />
<modified>2008-07-17T20:20:07Z</modified>
<issued>2008-07-17T20:19:51Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10130</id>
<created>2008-07-17T20:19:51Z</created>
<summary type="text/plain">Before I deep dive into the AsyncFilter API like I&apos;ve proposed in part 3, I&apos;ve decided to show how easy is to add...PHP to your Grizzly based application with support for the Bayeux protocol.</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Before I deep dive into the <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/arp/AsyncFilter.html">AsyncFilter</a> API I've proposed in part 3, I've decided to show how easy is to add...<a href="http://php.org">PHP</a> to your Grizzly based application with support for the <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/02/gcometd_introdu_1.html">Bayeux protocol</a>.</p>
<img alt="IMG_0321.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0321.JPG" width="640" height="400" />
<p>In part <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g.html">one</a>, <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_1.html">two</a> and <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_2.html">three</a>, I have showed how easy is to embed the <a href="http://grizzly.dev.java.net">Grizzly Http Runtime</a> and add JMX and Monitoring support. This time I would like to add PHP to the picture. Yes, PHP! A couple of months ago, my friend Kin-Man blogged about running <a href="http://blogs.sun.com/kchung/entry/native_php_in_glassfish_with">native PHP using the jsr223 Servlet</a>. The PHP Servlet used in Kin-Man's blog uses jsr223 scripting API and JNI to communicate with a native PHP runtime. That's a really good Servlet to serve directly from Grizzly. How, by just doing the following:</p><p><pre><code>   
        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/PHP/Folder");
            <strong>sa.setServlet(new com.sun.script.php.PHPServlet());</strong>
            // PHP requests are serviced under /php/
            sa.setContextPath("/php/");
            ws.addGrizzlyAdapter(sa);
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>That's it. One thing you must make sure is to set the -Djava.library.path to point to your native PHP installation libs directory. Example:</p><p><pre><code> java -Djava.library.path=/path_to_php_installation/php/php-5.0.1/libs/ \ 
          -jar  grizzly-servlet-webserver-1.8.3.jar -p 8080 -a /www/php</code></pre></p><p>will works, assuming you have added the required jars Kin-Man talks about inside the original grizzly-servlet bundle. Now let's add the <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a> based Bayeux protocol to the picture. This is also quite simple:</p><p><pre><code>   
        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/PHP/Folder");
            sa.setServlet(new com.sun.script.php.PHPServlet());
            // PHP requests are serviced under /php/
            sa.setContextPath("/php/");
            ws.addGrizzlyAdapter(sa);

            <strong>// Add Comet Support
            ws.addAsyncFilter(new CometAsyncFilter());
 
            //Now that we have Comet support, 
            CometdAdapter cometdAdapter = new CometdAdapter();
            ws.addGrizzlyAdapter(cometdAdapter);</strong>

            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>That's it! You have now a WebServer that supports PHP and the Bayeux protocol, where some requests are dispatched to PHP, and some to the Bayeux implementation. You can also bridge and <strong>push data</strong> from your PHP application to the Bayeux runtime using the <a href="http://us2.php.net/manual/en/java.examples.php">PHP SAPI</a> and by following Shing Wai's blog on <a href="http://blogs.sun.com/swchan/entry/java_api_for_cometd">Java API to Bayeux</a> we offer in Grizzly. Coucourouquuiquui! Since it's vacation time, post your questions to <a href="https://grizzly.dev.java.net/servlets/SummarizeList?listName=users">users@grizzly.dev.java.net</a> to be sure you get a response :-)</p><p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/web+server" rel="tag">web server</a> <a href="http://technorati.com/tag/embedded" rel="tag">embedded</a> <a href="http://technorati.com/tag/php" rel="tag">php</a></p>




]]>

</content>
</entry>
<entry>
<title>Extending the Grizzly HTTP Runtime part III: Gathering Monster&apos;s Statistics</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_2.html" />
<modified>2008-07-10T00:20:23Z</modified>
<issued>2008-07-10T00:20:09Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10096</id>
<created>2008-07-10T00:20:09Z</created>
<summary type="text/plain">So far we were able to build a WebServer based on Grizzly and add JMX Support to it. Now it is time to gather statistics of what&apos;s happening inside the monster&apos; stomach.</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>So far we were able to build a WebServer based on Grizzly and add JMX Support to it. Now it is time to gather statistics of what's happening inside the monster' stomach.</p>
<img alt="mathieu 009.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/mathieu 009.jpg" width="640" height="480" />
<p><a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g.html">Part I</a> was about building synchronous and asynchronous Web Server using <a href="http://grizzly.dev.java.net">Grizzly</a> Http Engine, <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_1.html">part II</a> demonstrated how to add JMX support and track what's happening. Let's re-use the example we used in part II:</p><p><pre><code> 47         GrizzlyWebServer ws = new GrizzlyWebServer(path);
 48         ServletAdapter sa = new ServletAdapter();
 49         sa.setRootFolder("/Path/To/Exploded/War/File");
 50         sa.setServlet(new MyServlet());
 51         sa.setContextPath("/myServlet");
 52         ws.addGrizzlyAdapter(sa);
 53 
 54         ServletAdapter sa2 = new ServletAdapter();
 55         sa2.setRootFolder("/Path/To/Exploded/War2/File");
 56         sa2.setServlet(new MySecondServlet());
 57         sa2.setContextPath("/mySecondServlet");
 58         ws.addGrizzlyAdapter(sa2);
 59 
 60         ws.enableJMX(new Management() {
 61 
 62             public void registerComponent(Object bean, ObjectName oname, String type)
 63                     throws Exception {
 64                 Registry.getRegistry().registerComponent(bean, oname, type);
 65             }
 66 
 67             public void unregisterComponent(ObjectName oname) throws Exception {
 68                 Registry.getRegistry().
 69                         unregisterComponent(oname);
 70             }
 71         });
 72         ws.start();
</code></pre></p><p>There are two way to add statistics. First, you can just enable it using JMX and click on <strong>enableMonitoring</strong> button:</p>
<img alt="enableMonitoring.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/enableMonitoring.jpg" width="554" height="220" />
<p>Then start doing request, and you can use jconsole to see the statistics:</p>
<img alt="Updates.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/Updates.jpg" width="692" height="483" />
<p>Programmatically, you can enable statistics by just doing:</p><p><pre><code>     56         GrizzlyWebServer ws = new GrizzlyWebServer(path);
     57         ws.enableJMX(new Management() {
     58 
     59             public void registerComponent(Object bean, ObjectName oname, String type)
     60                     throws Exception{
     61                 Registry.getRegistry().registerComponent(bean,oname,type);
     62             }
     63 
     64             public void unregisterComponent(ObjectName oname) throws Exception{
     65                 Registry.getRegistry().
     66                         unregisterComponent(oname);
     67             }
     68         });
     69 
     70         <strong>final Statistics stats = ws.getStatistics();
     71         stats.startGatheringStatistics();</strong>
</code></pre></p><p>The key method is <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/embed/GrizzlyWebServer.html#getStatistics()">GrizzlWebServer.getStatistics()</a>. From the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/embed/Statistics.html">Statistics</a> instance, you can start and stop gathering statistics. Below is an example that use a simple scheduler to output data on the console:</p><p><pre><code>     45     // Simple scheduler that will outpot stats every 5 seconds.
     46     private static ScheduledThreadPoolExecutor ste =
     47             new ScheduledThreadPoolExecutor(1);
     48 
     49     public static void main( String args[] ) throws Exception {
     50         String path = args[0];
     51         if (args[0] == null || path == null){
     52             System.out.println("Invalid static resource path");
     53             System.exit(-1);
     54         }
     55 
     56         GrizzlyWebServer ws = new GrizzlyWebServer(path);
     57         ws.enableJMX(new Management() {
     58 
     59             public void registerComponent(Object bean, ObjectName oname, String type)
     60                     throws Exception{
     61                 Registry.getRegistry().registerComponent(bean,oname,type);
     62             }
     63 
     64             public void unregisterComponent(ObjectName oname) throws Exception{
     65                 Registry.getRegistry().
     66                         unregisterComponent(oname);
     67             }
     68         });
     69 
     70         final Statistics stats = ws.getStatistics();
     71         stats.startGatheringStatistics();
     72 
     73         ste.scheduleAtFixedRate(new Runnable() {
     74             public void run() {
     75                 System.out.println("Current connected users: " +
     76                         stats.getKeepAliveStatistics().getCountConnections());
     77                 System.out.println("How many requests since startup:" +
     78                         stats.getRequestStatistics().getRequestCount());
     79                 System.out.println("How many connection we queued because of all" +
     80                         "thread were busy: " +
     81                         stats.getThreadPoolStatistics().getCountQueued());
     82                 return;
     83             }
     84         }, 0, 10,TimeUnit.SECONDS);
     85         System.out.println("Grizzly WebServer listening on port 8080");
     86         ws.start();
     87     }</code></pre></p><p>Another easy things with the monster! You can download the above example from <a href="http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-embed-samples/1.8.2-SNAPSHOT/">here</a> (bundled as an OSGi bundle if you like OSGi). Next time I will explore ways to write <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/arp/AsyncFilter.html">AsyncFilter</a>, which was partially covered in part 1.</p>

<p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/web+server" rel="tag">web server</a> <a href="http://technorati.com/tag/embedded" rel="tag">embedded</a> <a href="http://technorati.com/tag/jmx" rel="tag">jmx</a></p>
]]>

</content>
</entry>
<entry>
<title>Extending the Grizzly HTTP Runtime part II:  Managing the monster using JMX</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g_1.html" />
<modified>2008-07-09T23:35:36Z</modified>
<issued>2008-07-09T00:07:01Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10087</id>
<created>2008-07-09T00:07:01Z</created>
<summary type="text/plain">Now that we are all able to create Grizzly Web Server in less than 10 lines, let&apos;s complicate our day and add JMX management to the monster.</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Now that we are all able to create <a href="http://grizzly.dev.java.net">Grizzly</a> Web Server in less than 10 lines, let's complicate our day and add JMX management to the monster</p>
<img alt="IMG_0159.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0159.JPG" width="640" height="400" />
<p>In part I, I've described how easy it is to create <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g.html">synchronous and asynchronous http based Web Server</a>. One of the most complicated example was:</p></p><p><pre><code>GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/Exploded/War/File");
            sa.setServlet(new MyServlet());
            sa.setContextPath("/myServlet");
            ws.addGrizzlyAdapter(sa);
  
            ServletAdapter sa2 = new ServletAdapter();
            sa2.setRootFolder("/Path/To/Exploded/War2/File");
            sa2.setServlet(new MySecondServlet());
            sa2.setContextPath("/mySecondServlet");
            ws.addGrizzlyAdapter(sa2);
  
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>That wasn't too difficult, was it? Now let's add JMX support:</p><p><pre><code> 47         GrizzlyWebServer ws = new GrizzlyWebServer(path);
 48         ServletAdapter sa = new ServletAdapter();
 49         sa.setRootFolder("/Path/To/Exploded/War/File");
 50         sa.setServlet(new MyServlet());
 51         sa.setContextPath("/myServlet");
 52         ws.addGrizzlyAdapter(sa);
 53 
 54         ServletAdapter sa2 = new ServletAdapter();
 55         sa2.setRootFolder("/Path/To/Exploded/War2/File");
 56         sa2.setServlet(new MySecondServlet());
 57         sa2.setContextPath("/mySecondServlet");
 58         ws.addGrizzlyAdapter(sa2);
 59 
 60         <strong>ws.enableJMX(new Management() {
 61 
 62             public void registerComponent(Object bean, ObjectName oname, String type)
 63                     throws Exception {
 64                 Registry.getRegistry().registerComponent(bean, oname, type);
 65             }
 66 
 67             public void unregisterComponent(ObjectName oname) throws Exception {
 68                 Registry.getRegistry().
 69                         unregisterComponent(oname);
 70             }
 71         });</strong>
 72         ws.start();
</code></pre></p><p>To enable JMX, you just need to implement the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/Management.html">Management</a> interface, and set it using the <strong>enableJMX</strong> method of the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/embed/GrizzlyWebServer.html">GrizzlyWebServer</a> class. As you can see, you can plug your own JMX implementation easily using the Management interface. In the example above, I've just used the <a href="http://commons.apache.org/modeler/">Apache Commons Modeler</a>, which does all the JMX "bla bla bla" for me via its org.apache.commons.modeler.Registry static class.</p><p>To see it live, I just do:</p><p><pre><code>%  java -Dcom.sun.management.jmxremote.port=1199 -Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false -jar grizzly-embed-samples.jar

// Start jconsole
% jconsole
</code></pre></p><p> Hey hey I can see: </p>
<img alt="jconsole.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/jconsole.jpg" width="694" height="548" />
<p>Miaaaaaam! Next time I will explain how to grab statistics from your embedded GrizzlyWebServer, like number of requests, time spend, thread pool stats, etc. You can download the example above <a href="http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-embed-samples/1.8.2-SNAPSHOT/">here</a>. The binary can be used as it is and include all the Grizzly required classes to run.</p><p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/web+server" rel="tag">web server</a> <a href="http://technorati.com/tag/embedded" rel="tag">embedded</a> <a href="http://technorati.com/tag/jmx" rel="tag">jmx</a></p>
]]>

</content>
</entry>
<entry>
<title>Extending the Grizzly HTTP Runtime</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/extending_the_g.html" />
<modified>2008-07-09T23:04:03Z</modified>
<issued>2008-07-04T04:52:13Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10074</id>
<created>2008-07-04T04:52:13Z</created>
<summary type="text/plain">Project Grizzly provides developers with a simple and consistent mechanism for extending the functionality of the Grizzly HTTP Runtime and for bridging existing http based technology like JRuby-on-Rail, Grail, Servlet, the Bayeux Protocol or any http based protocol. </summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p><a href="http://grizzly.dev.java.net">Project Grizzly</a> provides developers with a simple and consistent mechanism for extending the functionality of the Grizzly HTTP Runtime and for bridging existing HTTP based technologies like <a href="http://recompile.net/2007/09/a_brief_introduction_to_jruby.html">JRuby-on-Rail</a>, Grail, Servlet, the <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/02/gcometd_introdu_1.html">Bayeux Protocol</a> or any http based protocol.</p>
<img alt="IMG_0320.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0320.JPG" width="640" height="400" />
<p>There is three important classes to know when you want to extend (and embed):<ul><li>GrizzlyAdapter: The <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/http11/GrizzlyAdapter.html">GrizzlyAdapter</a> is the main extensible point when you want to write an http based extension. This class is invoked by the Grizzly Http Runtime as soon as the http request has been parsed. It's main method is defined as  <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/http11/GrizzlyAdapter.html#service(com.sun.grizzly.tcp.http11.GrizzlyRequest,%20com.sun.grizzly.tcp.http11.GrizzlyResponse)">service(GrizzlyRequest req, GrizzlyResponse res)</a>. You can get all the http information from the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/http11/GrizzlyRequest.html">GrizzlyRequest</a> and write the response using the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/http11/GrizzlyResponse.html">GrizzlyResponse</a>. Grizzly ships with several implementation of the GrizzlyAdapter: <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/servlet/ServletAdapter.html">ServletAdapter</a>, <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/cometd/standalone/CometdAdapter.html">CometdAdapter</a>, <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/tcp/StaticResourcesAdapter.html">StaticResourceAdapter</a>, etc. You can look at the details by browsing the code from <a href="https://grizzly.dev.java.net/nonav/xref/index.html">here</a></li><li><a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/arp/AsyncFilter.html">AsyncFilter</a>: AsyncFilter are helpful when you want to write an a<a href="http://weblogs.java.net/blog/jfarcand/archive/2006/02/grizzly_part_ii.html">synchronous request processing</a> based web server. AsyncFilter allows you to suspend the processing of an http request, and resume it once you are ready. When suspending the request execution, an AsyncFilter doesn't block on a Thread so you don't waste a Thread until the execution is resumed. AsyncFilter always execute before any GrizzlyAdapter</li><li><a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/embed/GrizzlyWebServer.html">GrizzlyWebServer</a>: The main entry point. You always first create an instance of the GrizzlyWebServer, and then add GrizzlyAdapter(s) and AsyncFilter(s).</li></ul></p><p>Sound complicated? Not at all! Let's describe some really simple examples.</p><p>First, let's create a WebServer that serve static resources:</p><p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>Now let's write a very simple GrizzlyAdapter that return an html page when a static resource is not found.</p><p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ws.addGrizzlyAdapter(new GrizzlyAdapter(){  
                
                public void service(GrizzlyRequest request, GrizzlyResponse response){
                    try {
                        response.getWriter().println("Grizzly is soo cool..but you request cannot be found!");
                    } catch (IOException ex) {                        
                    }
                }
            });
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>Now let's add Servlet support to our WebServer (note that the Grizzly's Servlet support is limited in term of functionalities..no deployment support, all done programatically)<p><pre><code>   
        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/Exploded/War/File");
            sa.setServlet(new MyServlet());
            ws.addGrizzlyAdapter(sa);
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        } </code></pre></p><p>Well, why not adding two Servlet support</p><p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/Exploded/War/File");
            sa.setServlet(new MyServlet());
            ws.addGrizzlyAdapter(sa);
  
            ServletAdapter sa2 = new ServletAdapter();
            sa2.setRootFolder("/Path/To/Exploded/War2/File");
            sa2.setServlet(new MySecondServlet());
            ws.addGrizzlyAdapter(sa2);
  
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>Easy, it is (to speak like Yoda). Now let's go back to basic, which is to serve static resources. Let's assume we want to delay the request processing when we are under load, using an AsyncFilter. Let's assume for now that all requests will be suspended 10 seconds before they get executed by the GrizzlyAdapter.</p><p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ws.addAsyncFilter(new AsyncFilter() {
                private final ScheduledThreadPoolExecutor scheduler = 
                        new ScheduledThreadPoolExecutor(1);
                public boolean doFilter(final AsyncExecutor asyncExecutor) {
                    //Throttle the request
                    scheduler.schedule(new Callable() {
                        public Object call() throws Exception {
                            asyncExecutor.execute();
                            asyncExecutor.postExecute();
                            return null;
                        }
                    }, 10, TimeUnit.SECONDS);
                    
                    // Call the next AsyncFilter
                    return true;
                }
            });
                                        
            ws.addGrizzlyAdapter(new GrizzlyAdapter(){                  
                public void service(GrizzlyRequest request, GrizzlyResponse response){
                    try {
                        response.getWriter().println("Grizzly is soon cool");
                    } catch (IOException ex) {                        
                    }
                }
            });
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p>This is cool, is it? Now let's add Servlet to the picture:</p><p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            ws.addAsyncFilter(new AsyncFilter() {
                private final ScheduledThreadPoolExecutor scheduler = 
                        new ScheduledThreadPoolExecutor(1);
                public boolean doFilter(final AsyncExecutor asyncExecutor) {
                    //Throttle the request
                    scheduler.schedule(new Callable() {
                        public Object call() throws Exception {
                            asyncExecutor.execute();
                            asyncExecutor.postExecute();
                            return null;
                        }
                    }, 10, TimeUnit.SECONDS);
                    
                    // Call the next AsyncFilter
                    return true;
                }
            });
  
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/Exploded/War/File");
            sa.setServlet(new MyServlet());
            ws.addGrizzlyAdapter(sa);
 
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        }</code></pre></p><p> Miam Miam! OK now let do something really really complicated :-). Let's add <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a> into the picture. Naa not enough complicated. Let's add the Bayeux Protocol (cometd) but also be able to serve static resources and Servlet.<p><pre><code>        GrizzlyWebServer ws = new GrizzlyWebServer("/var/www");
        try{
            // Add Comet Support
            ws.addAsyncFilter(new CometAsyncFilter());
 
            //Add Bayeux support
            CometdAdapter cometdAdapter = new CometdAdapter();
            ws.addGrizzlyAdapter(cometdAdapter);
  
            ServletAdapter sa = new ServletAdapter();
            sa.setRootFolder("/Path/To/Exploded/War/File");
            sa.setContextPath("/servlets/");
            sa.setServlet(new MyServlet());
            ws.addGrizzlyAdapter(sa);
 
            ws.start();
        } catch (IOException ex){
            // Something when wrong.
        } </code></pre></p><p>Wow. With just a couple of line we were able to create a Web Server that supports the Bayeux Protocol, a single Servlet and static resources. Now you can do things much more complicated, like writing complex and powerful GrizzlyAdapter, and call it <a href="http://glassfish.dev.java.net">GlassFish v3</a> :-). v3 is a good example of how easy it is to build really powerful HTTP extension using the Grizzly extensible point like the GrizzlyAdapter.</p><p>Want to give it a try? Download the <a href="http://download.java.net/maven/2/com/sun/grizzly/grizzly-servlet-webserver/1.8.1/grizzly-servlet-webserver-1.8.1.jar">Grizzly HTTP extension</a>, add it to your classpath, and look at the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/http/embed/GrizzlyWebServer.html">GrizzlyWebServer API</a>. Now if you want to do things more complicated liked adding JMX support, monitoring, etc, then read that <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/12/understanding_g.html">old blog serie</a> and look at the now infamous <a href="https://grizzly.dev.java.net/nonav/apidocs/index.html">SelectorThread documentation</a> :-). If you have question, just stop by users@grizzly.dev.java.net...we have <a href="https://grizzly.dev.java.net/servlets/BrowseList?listName=users&by=date&from=2008-07-01&to=2008-07-31&first=1&count=72">more and more peoples shaking</a> the Grizzly those days!</p><p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/web+server" rel="tag">web server</a> <a href="http://technorati.com/tag/embedded" rel="tag">embedded</a></p>
]]>

</content>
</entry>
<entry>
<title>Getting started with Comet and GlassFish v2</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/getting_started.html" />
<modified>2008-07-02T17:40:03Z</modified>
<issued>2008-07-02T17:39:50Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10069</id>
<created>2008-07-02T17:39:50Z</created>
<summary type="text/plain">The Grizzly users lists is bombarded with questions about how to start with Comet and GlassFish v2. Here is a quick explanation...</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>The <a href="http://grizzly.dev.java.net">Grizzly</a> <a href="https://grizzly.dev.java.net/servlets/SummarizeList?listName=users&by=subject">users list</a> is bombarded with questions about how to start with <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a> and <a href="http://glassfish.dev.java.net">GlassFish</a> v2. Here is a quick explanation...</p>
<img alt="IMG_0317.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0317.JPG" width="640" height="400" />
<p>GlassFish v2 ships with <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/grizzly_1020_av.html">Grizzly 1.0.20</a> (not <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/06/ursus_arctos_ho.html">Grizzly 1.8.0</a>) so to easily compile your application, just <a href="https://maven-repository.dev.java.net/nonav/repository/grizzly/jars/grizzly-1.0.20.jar">download 1.0.20</a>, and then make sure your add that jar file to your classpath. That steps should be quite trivial if you are using Netbeans or Eclipse. Then you are <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/02/comet_support_i.html">ready to write</a> your <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/06/new_adventures_3.html">first Comet application</a>.</p><p>Now once you are ready to deploy your application using Grizzly Comet or <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/04/the_hitchhikers.html">GlassFish v3</a>, make sure you read <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/04/the_hitchhikers.html">this blog</a>. In short, make sure you add the grizzly-compat.jar to your WEB-INF/lib to be able deploy without having to recompile your application against Grizzly 1.8.0.</p><p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/comet" rel="tag">comet</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a></p>

]]>

</content>
</entry>
<entry>
<title>Porting and Compiling your GlassFish v2 Comet application To v3</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/07/porting_and_com.html" />
<modified>2008-07-01T23:00:18Z</modified>
<issued>2008-07-01T22:18:52Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10065</id>
<created>2008-07-01T22:18:52Z</created>
<summary type="text/plain">Between GlassFish v2 and v3, Grizzly became a project of his own and we renamed its package name, with a side effect of making more complicated to recompile your v2 Comet application against Grizzly standalone or GlassFish v3. Not that complicated....  </summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>When <a href="httpsL//grizzly.dev.java.net">Grizzly</a> became a top level project on java.net, we renamed it's package from <em>com.sun.enterprise.web.connector.grizzly</em> to <em>com.sun.grizzly</em>. For the core package, the transition was quite smooth, but for <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet based application</a>, having to rename the imported packages and then  recompile was painful. Worse, building an application that works for both <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/02/comet_support_i.html">v2 and v3</a> was quite complicated, having to support two version of the same application. That's what we call a backward compatibility!</p><img alt="IMG_0312.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0312.JPG" width="400" height="640" /><p>So why have we changed the package name? Well, the original package name was quite confusing (and we didn't have the choice at that time..in 2006). The web.connector.grizzly didn't make any sense as well. So renaming was the best thing we have to grow our new community. Hence, the Comet package has been renamed from <em>com.sun.enterprise.web.connector.grizzly.comet</em> to <em>com.sun.grizzly.comet</em>. If you are planning to <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/06/new_adventures_3.html">write a Comet based application</a>, I strongly recommend you use the old package name so your Comet application will work on v2 and v3 without the need to changes anything.</p>
<p>How to do that? First, download the<a href="http://download.java.net/maven/2/com/sun/grizzly/grizzly-compat/1.8.0/grizzly-compat-1.8.0.jar"> grizzly-compat</a> package, and use that module to build against it. As an example (much simpler with an IDE like Eclipse or Netbeans, but just for an example):</p><p><pre><code>% javac -classpath grizzly-compat-1.8.0.jar your_classes</code></pre></p><p>This will compile your application and make it work on all <a href="http://glassfish.dev.java.net">GlassFish</a> anf Grizzly version that support Comet. You might also want to put the grizzly-compat jar file under WEB-INF/lib as early versions of GlassFish v3 didn't included this module, hence you application will fail to deploy. That way you are sure your <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/04/the_hitchhikers.html">Comet applications</a> works on all GlassFish flavors without requiring any changes.</p><p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/comet" rel="tag">comet</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a></p>]]>

</content>
</entry>
<entry>
<title>Writing a TCP/UDP stack supporting the SIP protocol using the Grizzly Framework, part II</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/06/writing_a_tcpud_2.html" />
<modified>2008-07-22T20:19:59Z</modified>
<issued>2008-06-25T22:28:43Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.10029</id>
<created>2008-06-25T22:28:43Z</created>
<summary type="text/plain">Finally I&apos;m resuming on that popular topic. Since SIP is a two way protocol, this time I will explain how to build the client side using Grizzly 1.8.0. </summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Glassfish</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Back to technical blog after "<a href="http://blogs.sun.com/theaquarium/entry/grizzly_1_8_is_buzzword">buzzwording</a>" for too long :-). Time to resume the tutorial about <a href="http://grizzly.dev.java.net">Grizzly</a> and SIP.  The first part was explaining <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/02/writing_a_tcpud_1.html">Grizzly's server side components</a>, this time I will concentrate on the client components. Like for the first part, I will not yet jump into the details of the SIP protocol.</p><img alt="IMG_0300.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0300.JPG" width="640" height="400" />
<p>As for the server side, you first need to create the entry point in Grizzly, which is the <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/Controller.html">Controller</a>.</p><p><pre><code> Controller controller = new <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/Controller.html">Controller</a>();</code></pre></p><p>Next, we need to configure which transport we want to support. For this blog purpose, I will only explain how to support UDP and TCP, and talk about TLS later. In Grizzly, a transport is represented using the <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/ConnectorHandler.html">ConnectorHandler</a> interface, and the framework support by default three implementation: <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/TCPConnectorHandler.html">TCPConnectorHandler</a>, <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/SSLConnectorHandler.html">TLSConnectorHandler</a> and <a href="https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/UDPConnectorHandler.html">UDPConnectorHandler</a>. By default, the Controller support TCP, but to help understanding how it works, the code below will explicitly configure the Controller to support TCP and UDP:</p><p><pre><code>ConnectorHandler tcpConnector = controller.acquireConnectorHandler(Controller.Protocol.TCP);

ConnectorHandler udpConnector = controller.acquireConnectorHandler(Controller.Protocol.UDP);</code></pre></p><p>Next we need to decide if we want to use a <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/ProtocolChain.html">ProtocolChain</a> for handling our request/response, or use a <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/CallbackHandler.html">CallbackHandler</a> to experiment with the bytes and the state of the connection. Since SIP is a two way protocol (the client can become the server and vice versa), let's first demonstrate how to use a ConnectorHandler with a ProtocolChain. For the purpose of this blog, let's add  a (<a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/filter/LogFilter.html">LogFilter</a>) that output the bytes sent by the server:</p><p><pre><code>ProtocolChain protocolChain = controller.getProtocolChain();
protocolChain.addFilter(new ReadFilter());
protocolChain.addFilter(new LogFilter());</code></pre></p><p>That means that once we are connected to a remote server, all the bytes we are getting back will be processed by the ReadFilter and LogFilter. So let's connect:</p><p><pre><code>tcpConnector.connect(new InetSocketAddress("localhost",8080),null);
tcpConnector.write(ByteBuffer.wrap(sipRequestBytes));</code></pre></p><p>What is interesting here is the ProtocolChain used for reading the bytes can also be used on the server side. So let's say we wrote a <a href="http://fisheye5.atlassian.com/browse/~raw,r=1.33/sailfin/sip-stack/src/java/com/ericsson/ssa/container/MessageProcessorFilter.java">SipParserProtocolFilter</a>, we can use that ProtocolFilter for parsing the bytes send by a remote client and also we can use it to parse the response we are getting when connecting to a remote server:</p><p><pre><code>
      1 package com.sun.grizzly.utils;
      2 import com.sun.grizzly.ConnectorHandler;
      3 import com.sun.grizzly.Controller;
      4 import com.sun.grizzly.DefaultPipeline;
      5 import com.sun.grizzly.Pipeline;
      6 import com.sun.grizzly.ProtocolChain;
      7 import com.sun.grizzly.ProtocolChainInstanceHandler;
      8 import com.sun.grizzly.TCPSelectorHandler;
      9 import com.sun.grizzly.UDPSelectorHandler;
     10 import com.sun.grizzly.filter.LogFilter;
     11 import com.sun.grizzly.filter.ReadFilter;
     12 
     13 public class SipDemo {
     14 
     15     public void startSIPServerDemo(){
     16 
     17         Controller controller = new Controller();
     18 
     19         TCPSelectorHandler tcpSelector = new TCPSelectorHandler();
     20         tcpSelector.setPort(8080);
     21         controller.addSelectorHandler(tcpSelector);
     22 
     23         UDPSelectorHandler udpSelector = new UDPSelectorHandler();
     24         udpSelector.setPort(8080);
     25         controller.addSelectorHandler(udpSelector);
     26 
     27         Pipeline mySharedPipeline = new DefaultPipeline();
     28         mySharedPipeline.setMaxThreads(5);
     29 
     30         controller.setPipeline(mySharedPipeline);
     31 
     32         ProtocolChainInstanceHandler pciHandler =
     33                 new ProtocolChainInstanceHandler() {
     34 
     35             final private ProtocolChain protocolChain = new DefaultProtocolChain();
     36 
     37             public ProtocolChain poll() {
     38                 return protocolChain;
     39             }
     40 
     41             public boolean offer(ProtocolChain instance) {
     42                 return true;
     43             }
     44         };
     45         controller.setProtocolChainInstanceHandler(pciHandler);
     46 
     47         ProtocolChain protocolChain = pciHandler.poll();
     48         protocolChain.addFilter(new ReadFilter());
     49         protocolChain.addFilter(new LogFilter());
     50 
     51         controller.start();
     52         ConnectorHandler ch = controller.acquireConnectorHandler(Controller.Protocol.TCP);
     53         ch.connect(new InetSocketAddress("localhost",8080),(CallbackHandler)null);
     54     }
     55 
     55 }</code></pre></p><p>Graphically, it looks like the following:</p><img alt="demo1.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/demo1.jpg" width="566" height="206" /><p>Now let's assume we want to use the ConnectorHandler for read and write operations, but this time without using a ProtocolChain. The component we can use in that case is called a <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/CallbackHandler.html">CallbackHandler</a>. In the example above, we haven't created any CallbackHandler, but under the hood, Grizzly created one (the <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/DefaultCallbackHandler.html">DefaultCallbackHandler</a>), which dispatch all connect, read and write operations to the ProtocolChain. By default, the CallbackHandler interface, which is invoked by the Controller every time there is an asynchonous operations ready to be processed, looks like:</p><p><pre><code> 41 /**
 42  * Callback handler for non blocking client operations.
 43  *
 44  * @param E  object containing information about the current
 45  *        non blocking connection
 46  * @author Jeanfrancois Arcand
 47  */
 48 public interface CallbackHandler<E> extends Handler{
 49 
 50     /**
 51      * This method is called when an non blocking OP_CONNECT is ready
 52      * to get processed. This method <strong>must</strong> invoke ConnectorHandler.finishConnect()
 53      * to complete the connection operations.
 54      *
 55      * @param ioEvent an object containing information about the current
 56      *        non blocking connection.
 57      */
 58     public void onConnect(IOEvent<E> ioEvent);
 59 
 60 
 61     /**
 62      * This method is called when an non blocking OP_READ is ready
 63      * to get processed.
 64      * @param ioEvent an object containing information about the current
 65      *        non blocking connection.
 66      */
 67     public void onRead(IOEvent<E> ioEvent);
 68 
 69 
 70     /**
 71      * This method is called when an non blocking OP_WRITE is ready
 72      * to get processed.
 73      * @param ioEvent an object containing information about the current
 74      *        non blocking connection.
 75      */
 76     public void onWrite(IOEvent<E> ioEvent);
 77 
 78 }</code></pre></p><p>As an example, <a href="https://grizzly.dev.java.net/nonav/xref-test/com/sun/grizzly/TCPConnectorHandlerTest.html">here is a simple implementation</a> of a CallbackHandler connect, read and write operations:</p><p><pre><code>274             public void onConnect(IOEvent<Context> ioEvent) {
275                 SelectionKey key = ioEvent.attachment().getSelectionKey();
276                 try{
277                     tcpConnector.finishConnect(key);
278                 } catch (IOException ex){
279                     ex.printStackTrace();
280                 }   
281                 // Register for read events
282                 ioEvent.attachment().getSelectorHandler().register(key,
283                         SelectionKey.OP_READ);
284             }
285             
286             public void onRead(IOEvent<Context> ioEvent) {
287                 SelectionKey key = ioEvent.attachment().getSelectionKey();
288                 SelectorHandler selectorHandler = ioEvent.attachment().
289                         getSelectorHandler(); 
290                 SocketChannel socketChannel = (SocketChannel)key.channel();
291                 
292                 try {
293                     int nRead = socketChannel.read(readBB);
294                     // Do something with the bytes
295                     // ...
296                     // Ask for more bytes
297                     selectorHandler.register(key, SelectionKey.OP_READ);
298                 } catch (IOException ex){
299                     selectorHandler.getSelectionKeyHandler().cancel(key);
300                 }   
301             }   
302 
303             public void onWrite(IOEvent<Context> ioEvent) {
304                 SelectionKey key = ioEvent.attachment().getSelectionKey();
305                 SelectorHandler selectorHandler = ioEvent.attachment().
306                         getSelectorHandler();
307                 SocketChannel socketChannel = (SocketChannel)key.channel();
308                 try{
309                     while(writeBB.hasRemaining()){
310                         int nWrite = socketChannel.write(writeBB);
311                         
312                         if (nWrite == 0){
313                             selectorHandler.register(key, SelectionKey.OP_WRITE);
314                             return;
315                         }   
316                     }
317                 } catch (IOException ex){
318                     selectorHandler.getSelectionKeyHandler().cancel(key);
319                 }   
320 
321             }</code></pre></p><p>With the example above, you can always decide to delegate the processing of the bytes to your ProtocolChain, which wasn't the case with my first example. Graphically, it looks like:</p><img alt="demo3.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/demo3.jpg" width="626" height="206" /><p>To configure your CallbackHandler, you just need to pass an instance when executing the asynchronous connect operation:</p><p><pre><code>tcpConnector.connect(new InetSocketAddress("localhost",8080),new MyConnectorHandler());</code></pre></p><p>The only difference here is instead of passing a <strong>null</strong>, we are passing an instance of <strong>CallbackHandler</strong>. What I like with CallbackHandler is that I can decide when I want to delegate the processing to a ProtocolChain, and completely ignore that component if I don't want to write ProtocolFilter. And when I write a non blocking client, I can always decide to either write a CallbackHandler, or a simple ProtocolFilter.</p><p>OK, hopefully the next blog for that serie will happens sooner. Next time I will start digging about SIP and how we have implemented it in <a href="http://sailfin.dev.java.net">Sailfin</a>.</p></p>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a>  <a href="http://technorati.com/tag/sailfin" rel="tag">sailfin</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a></p>


]]>

</content>
</entry>
<entry>
<title>Ursus arctos horribilis: Grizzly 1.8.0 released (Community release!)</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/06/ursus_arctos_ho.html" />
<modified>2008-06-12T02:45:35Z</modified>
<issued>2008-06-11T23:25:51Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9956</id>
<created>2008-06-11T23:25:51Z</created>
<summary type="text/plain">Our biggest release ever? Until Grizzly 2.0! Well, 1.8.0 contains a lot of bug fixes, performance improvements, cool new technologies support (GWT, iPhone, etc.), new Comet components, etc.</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Our biggest release ever :-)...OK last time I've claimed the same fact..naaaa our biggest one will be <a href="http://www.nabble.com/-Community-Feedback--Grizzly-2.0-to17508295.html">Grizzly 2.0</a>! Well, <a href="http://www.nabble.com/-VOTE--Release-Grizzly-1.8.0-td17739314.html">1.8.0</a> contains a lot of bug fixes, performance improvements, cool new technologies support (GWT, <a href="http://weblogs.java.net/blog/brunogh/archive/2008/05/java_on_iphone.html">iPhone</a>, etc.), new Comet components, new embeddable features, etc.</p>
<img alt="IMG_0283.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0283.JPG" width="640" height="400" />
<p>This release fix multiples bugs and RFE:<ul><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=159">Issue 159</a>: GWT servlet is missing *.rpc file from ServletContext.getResourceAsStream: You can now <a href="http://www.nabble.com/GWT-running-in-grizzly-http-servlet---working-tc17763825.html">replace Tomcat</a> with <a href="http://grizzly.dev.java.net">Grizzly</a> in <a href="http://code.google.com/webtoolkit/">GWT</a> and get <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/building_gwt_co.html">GWT Comet</a> a ride.</li><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=89">Issue 89</a>: Remove the asymmetry in channel event handling in Grizzly. Now a <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/ProtocolChain.html">ProtocolChain</a> can be used for both client and server event handling.</li><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=158">Issue 158</a>: OSGi not properly implemented for all modules (since OSGi is the buzz on the month)</li><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=122">Issue 122</a>: Add Messages Bus support to <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a>. A very <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/messagesbus/MessagesBus.html">simple Servlet</a> that can be used to add <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a> support to any existing application</li><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=101">Issue 101</a>: Add support for suspendable connection at the transport level: Adding asynchronous request processing to any Grizzly based application using a <a href="https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/suspendable/SuspendableFilter.html">ProtocolFilter</a>.</li><li><a href="https://grizzly.dev.java.net/issues/show_bug.cgi?id=149">Issue  149</a>: It's tricky to use <a href="http://weblogs.java.net/blog/sdo/archive/2007/12/grizzly_protoco.html">ParserProtocolFilter</a> with <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/11/one_port_to_rul.html">port unification</a></li><li><a href="http://tinyurl.com/5poa7d">And many more</a>!</li></ul></p><p>More important, the community keep growing and we are getting more and more <a href="http://www.nabble.com/Serial-com-port-communication-tc17635000.html">feedback</a>, <a href="http://www.nabble.com/Re%3A-ProtocolParser-Advice-to17612227.html">test cases</a>, <a href="https://grizzly.dev.java.net/servlets/ReadMsg?list=users&msgNo=1006">code donation</a>, <a href="http://www.javascriptr.com/2008/05/28/gwt-grizzly-comet/">tutorials</a>, <a href="http://www.nabble.com/1.7.3.3-drop-connection-every-30-seconds-to17674241.html">help</a>....this is just amazing :-). On the performance side, we have compared with Grizzly <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/grizzly_1020_av.html">1.0.20</a> using <a href="http://weblogs.java.net/blog/sdo/archive/2007/04/simple_benchmar.html">Faban (2000 simultaneous connections)</a>:</p><p><pre><code>1.8.0:

  ops/sec: 3094.108
  % errors: 0.0
  avg. time: 0.059
  max time: 13.208
  90th %: 0.10

1.0.20:

  ops/sec: 2510.742
  % errors: 0.0
  avg. time: 0.143
  max time: 12.796
  90th %: 0.25   </code></pre></p><p>Looks like we are also improving performance of our http extension. Try it using embeddable/OSGi bundles by downloading them from <a href="http://grizzly.dev.java.net">here</a>! And finally, there are some rumors Grizzly works like a charm on the <a href="http://weblogs.java.net/blog/brunogh/archive/2008/05/java_on_iphone.html">iPhone</a>...is that cool?</p><p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/iphone" rel="tag">iphone</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>AjaxPush/Comet Webinar next June 02 @ 9h00 PST</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/ajaxpushcomet_w.html" />
<modified>2008-06-12T02:00:41Z</modified>
<issued>2008-05-30T22:58:38Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9907</id>
<created>2008-05-30T22:58:38Z</created>
<summary type="text/plain">If you have missed our JavaOne session on Ajax Push/Comet, don&apos;t miss the upcoming Webminar on June 02. Tomcat, Jetty and GlassFish with a taste of Bayeux Protocol are discussed...</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>If you have missed our <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/javaonecometbuf.html">JavaOne session</a> on Ajax Push/Comet, don't miss the upcoming Webminar. <a href="http://tomcat.apache.org">Tomcat</a>, <a href="http://www.mortbay.org/jetty-6/">Jetty</a> and <a href="http://glassfish.dev.java.net">GlassFish</a> with a taste of <a href="http://cometdaily.com/2008/02/07/colliding-comets-battle-of-the-bayeux-part-1/">Bayeux Protocol</a> are discussed... Register <a href="https://www1.gotomeeting.com/register/165128562">here</a>.</p>
<p>
I'm really becoming a bad evangelist will all those talks :-)...fortunately <a href="http://www.jroller.com/tedgoddard/">Ted</a> is there to patch :-)</p>

<p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>Les presentations de Open Tech Days sont disponibles...</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/les_presentatio_1.html" />
<modified>2008-06-12T01:59:41Z</modified>
<issued>2008-05-30T20:59:01Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9903</id>
<created>2008-05-30T20:59:01Z</created>
<summary type="text/plain">Les hyperliens pour les presentations de Montreal et Toronto sont disponibles....</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Les présentations de Montréal et Toronto: La <a href="http://weblogs.java.net/blog/jfarcand/archive/AsynchronousRevolution.pdf">première</a> ainsi que la <a href="http://weblogs.java.net/blog/jfarcand/archive/2008_Montreal.pdf">seconde</a>. La prochaine fois, on ne parle qu'en français :-). Pour que l'on rigole un peu, j'invite <a href="http://blogs.sun.com/alexismp/">Alexis</a> pour qu'il nous apprenne a bien utiliser des mots anglais en francais  (comme mail, shopping, playback, browser, slides, etc.) :-). En plus on fait cela ici...</p>
<img alt="IMG_0284.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0284.JPG" width="640" height="400" />
<p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>Grizzly &amp; Comet JavaOne&apos;s sessions online...with bofs slides as well</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/grizzly_comet_j.html" />
<modified>2008-06-12T01:59:20Z</modified>
<issued>2008-05-30T16:46:23Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9900</id>
<created>2008-05-30T16:46:23Z</created>
<summary type="text/plain">My JavaOne 2008 sessions and BOFs are now online...I&apos;ve survived JavaOne 2008!</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<img alt="IMG_0286.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0286.JPG" width="640" height="400" />
<p>The <a href="http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-5250&yr=2008&track=nextweb">AjaxPush/Comet session</a> is now available, as well as the <a href="http://blogs.sun.com/oleksiys/entry/grizzly_javaone_2008">Grizzly session</a>. I've already talked about the <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/building_gwt_co.html">GWT and Grizzly Comet bof</a>, and a demo is now <a href="http://www.javascriptr.com/2008/05/28/gwt-grizzly-comet/">online</a>...the last bof I've had was with <a href="http://weblogs.java.net/blog/driscoll/">Jim</a>, Using Comet to Create a Two-Player Web Game, and here are the <a href="http://weblogs.java.net/blog/jfarcand/archive/JavaOne2008_CometTictactoe.pdf">slides</a>.</p>

<p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>Grizzly 1.0.20 available for the old bear&apos;s lover..with an updated Bayeux Implementation</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/grizzly_1020_av.html" />
<modified>2008-05-23T02:24:58Z</modified>
<issued>2008-05-23T02:24:23Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9853</id>
<created>2008-05-23T02:24:23Z</created>
<summary type="text/plain">For the old timer 1.0.x users, I&apos;ve just uploaded the latest Grizzly 1.0.20 binaries from the upcoming GlassFish v2.1 release. This new release contains the latest implementation of the Bayeux Protocol (cometd) specification. Of course, you are welcome to upgrade to our 1.7.x binary....</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>For the old timer <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/12/understanding_g.html">Grizzly 1.0.x users</a> (like <a href="http://wiki.open-esb.java.net/Wiki.jsp?page=JavaSEIncubator#section-JavaSEIncubator-RunningTheHTTPBCInJavaSE">open-esb</a>), I've just uploaded the latest grizzly 1.0.20 binaries from <a href="http://glassfish.dev.java.net">GlassFish</a> v2.1. You can download them from <a href="https://maven-repository.dev.java.net/nonav/repository/grizzly/jars/">here</a>. Of course, you are welcome to try our latest release, which is <a href="http://grizzly.dev.java.net">1.7.3.3</a>!</p>
<img alt="david_essai.jpg" src="http://weblogs.java.net/blog/jfarcand/archive/david_essai.jpg" width="640" height="400" />
<p>1.0.20 contains bug fixes and a back port of <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Grizzly Comet</a> and its <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/02/gcometd_introdu_1.html">Bayeux Protocol</a> (cometd) implementation from 1.7.3.3. This allow GlassFish v2 users to have the latest and greatest <a href="http://svn.xantus.org/shortbus/trunk/bayeux/bayeux.html">Bayeux</a> implementation! You can download Bayeux example from <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/04/the_hitchhikers.html">here</a>. 1.0.20 should be the latest release...snif snif snif for the now old <a href="http://weblogs.java.net/blog/jfarcand/archive/2005/06/grizzly_an_http.html">Grizzly 1.0</a>!</p>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/grizzlet" rel="tag">grizzlet</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>Building GWT Comet based web app using Grizzly Comet</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/building_gwt_co.html" />
<modified>2008-05-20T20:59:02Z</modified>
<issued>2008-05-20T20:58:50Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9839</id>
<created>2008-05-20T20:58:50Z</created>
<summary type="text/plain">I&apos;m getting a lot of requests to share our JavaOne BOF slides where we have demonstrated the use of GWT + Grizzly Comet. Here is the link....</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>I'm getting a lot of requests to share our <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/04/grizzly_related_1.html">JavaOne BOF</a> slides where we have demonstrated the use of GWT + <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Grizzly Comet</a>.</p>
<img alt="IMG_0268.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0268.JPG" width="640" height="400" />
<p> Download the presentation <a href="http://weblogs.java.net/blog/jfarcand/archive/Grizzly_GWT_BOF-4922.pdf">here</a>. We are still working on cleaning up the demo (and make sure I can commit the GWT code inside the <a href="http://grizzly.dev.java.net">Grizzly</a> workspace). So stay tuned for the demo, but it is so simple to use <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/02/comet_support_i.html">Grizzly Comet</a> + GWT you might not even need a demo :-). Unlike <a href="http://docs.codehaus.org/display/JETTY/GWT">Jetty</a>, you don't need any changes to GWT core classes to make it work :-) I was thinking to start blogging about GWT + Grizzly Comet integration, but I still need to write the follow up to my <a href="http://weblogs.java.net/blog/jfarcand/archive/2008/02/writing_a_tcpud_1.html">Grizzly SIP implementation</a> first, so the preso should be a good startup. If you have questions, post them here or send an email to users@grizzly.dev.java.net</p>

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>
<entry>
<title>Bye Bye Grizzly&apos;s JRuby extension, long live inside glassfish-scripting project.</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/bye_bye_grizzly.html" />
<modified>2008-05-20T19:32:47Z</modified>
<issued>2008-05-20T19:32:31Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9838</id>
<created>2008-05-20T19:32:31Z</created>
<summary type="text/plain">Starting today, we have voted to move out of the Grizzly umbrella the grizzly-jruby extension and its OSGi module. Where the code is going? Under the new glassfish-scripting project....</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>
<dc:subject>Community: Java Enterprise</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p>Starting today, we have voted to move out of the <a href="http://grizzly.dev.java.net">Grizzly</a> umbrella the grizzly-jruby extension and its OSGi bundle. Where the code is going? Under the new <a href="https://glassfish-scripting.dev.java.net/">glassfish-scripting</a> project.</p>
<img alt="IMG_0255.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/IMG_0255.JPG" width="640" height="400" />
<p>The <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/05/jruby_on_grizzl_1.html">grizzly-jruby module</a> is the foundation for the JRuby support in GlassFish v3 (aka <a href="http://rubyforge.org/projects/glassfishgem/">GlassFish gem</a>). Originally donated by <a href="http://recompile.net/">TAKAI Naoto</a> and maintained by the community, this Grizzly extension has grown enough to live outside the bear territories.....and have fun with other Grizzly based scripting extension like <a href="http://weblogs.java.net/blog/vivekp/archive/2008/05/embedding_glass.html">Groovy/Grails</a> :-)</p> 

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/jruby" rel="tag">jruby</a></p>]]>

</content>
</entry>
<entry>
<title>Grizzly&apos;s OSGi bundles</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/jfarcand/archive/2008/05/grizzlys_osgi_b_1.html" />
<modified>2008-05-15T22:10:43Z</modified>
<issued>2008-05-15T21:23:30Z</issued>
<id>tag:weblogs.java.net,2008:/blog/jfarcand/258.9816</id>
<created>2008-05-15T21:23:30Z</created>
<summary type="text/plain">Grizzly has OSGi bundles available for a while, but we haven&apos;t made any noise about it yet. Since OSGi is the current buzz, let&apos;s the monster enter the buzz circus...</summary>
<author>
<name>jfarcand</name>

<email>Jeanfrancois.Arcand@Sun.COM</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/jfarcand/">
<![CDATA[<p><a href="http://grizzly.dev.java.net">Grizzly</a> has <a href="http://www.osgi.org/Main/HomePage">OSGi</a> bundles available for a while, but we haven't made any noise about it yet to let the spotlight on <a href="http://blogs.sun.com/dochez/entry/glassfish_v3_runs_on_osgi">GlassFish v3</a>. Since OSGi is the current buzz, let's the monster enter the buzz circus...</p>
<img alt="DSC_0162.JPG" src="http://weblogs.java.net/blog/jfarcand/archive/DSC_0162.JPG" width="640" height="480"/>
<p>Since release <a href="http://weblogs.java.net/blog/jfarcand/archive/2007/12/hohohoho_grizzl_1.html">1.7.0</a> (we are now shipping 1.7.3.3), Grizzly ships with jar file manifests that include appropriate OSGi bundle information. This means that you can import the Grizzly jars into an OSGi framework and use them, for example, to build a I/O application using the <a href="http://download.java.net/maven/2/com/sun/grizzly/grizzly-framework/1.7.3.3/grizzly-framework-1.7.3.3.jar">framework classes</a>, to build a static Web Server or a <a href="http://weblogs.java.net/blog/jfarcand/archive/2006/07/the_grizzly_com.html">Comet</a> messages bus. Those jars are currently self-contained for the reason that you can use them for testing using a simple command like:</p><p><pre><code>java -jar [bundle-name] -p [port] -a [war|jar|directory location] [Component_name]

As an example, you can:

% java -jar grizzly-messagesbus-webserver-1.7.3.3.jar -p 8080 -a jmaki-messagesbus-demo.war</code></pre></p><p>
which start a simple Comet messages bus (I will soon blog about this new module). As usual, let us know what you think about those OSGi bundles, if they are ok or not, as none of us are OSGi expert. You can download those OSGi bundles from <a href="http://grizzly.dev.java.net">here</a>...</p>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3111670-1";
urchinTracker();
</script> 
<p>technorati: <a href="http://technorati.com/tag/grizzly" rel="tag">grizzly</a> <a href="http://technorati.com/tag/glassfish" rel="tag">glassfish</a> <a href="http://technorati.com/tag/comet" rel="tag">comet</a></p>]]>

</content>
</entry>

</feed>