SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Downloaden Sie, um offline zu lesen
Overview of
Grizzly and Grizzly 2.0




Oleksiy Stashok
Jeanfrancois Arcand
Sun Microsystems
                          1
Agenda
• What is project Grizzly
• Grizzly modules
• Grizzly 2.0
• RoadMap
• Summary




Footnote position, 12 pts.

                             2
1. What is Project Grizzly
• Open Source Project https://grizzly.dev.java.net
• Open Sourced under CDDL/LGPL license.
• Very open community policy.
  >  All project communications are done on Grizzly mailing
     list. No internal, off mailing list conversations a-la-Sailfin.
  >  Project meetings open to anyone
• Project decisions are made by project member
  votes. Code contributions frequents.
• Approx ~25 000 download for the last 3 months
• Mailing list quite busy some day!
                                                                       3
1. What is project Grizzly
• Commiters
   >  Oleksiy Stashok (Sun) – Lead (all modules)
   >  Jean-Francois Arcand (Sun)‫( ‏‬all modules)
   >  Shing Wai Chan (Sun)‫( ‏‬http, comet, bayeux)
   >  Ken Cavanaugh (Sun)‫( ‏‬framework)
   >  Charlie Hunt (Sun)‫( ‏‬framework)
   >  John Vieten (Conclude GmbH)‫( ‏‬tutorial, framework)
   >  Sebastien Dionne (Consultant)‫( ‏‬tutorial, framework)
   >  Takai Naoto (ITOCHU Techno-Solution)‫( ‏‬jruby, bayeux)
•  Active users list…the community answer for us!

                                                              4
What is Project Grizzly

   ses Java NIO primitives and hides the complexity
  U
  programming with Java NIO.

   tarted in 2004 (Grizzly 1.0). Own project February 2007
  S
  (Grizzly 1.5)

   .0 represented extracted network layer of Glassfish
  1

   asy-to-use high performance APIs for TCP, UDP and SSL
  E
  communications.

   tilizes high performance buffers and buffer management.
  U

   hoice of several different high performance thread pools.
  C

   hip with an HTTP module which is really easy to embed.
  S
                                                                5
2. Grizzly modules




                     6
2. Framework




               7
2.1 Framework
•  The root of Grizzly. Everything build on top of this module

•  The Grizzly Framework bundles default implementation
   for TCP, UDP and TLS/SSL transports.

•  Used to implement protocol based applications like http,
   sip, custom protocol, etc.

•  In this module, EVERYTHING is customizable. If the
   default isn't doing what you need , customize it!




                                                                 8
Grizzly Framework's Monster face




                                   9
Example: Simple log server over
TCP
Controller controller = new Controller();
controller.setProtocolChainInstanceHandler(new
          DefaultProtocolChainInstanceHandler() {
            ProtocolChain protocolChain;
            // Stateless ProtocolChain
            public ProtocolChain poll() {
              if(protocolChain == null) {
                  protocolChain = new DefaultProtocolChain();
                  protocolChain.addFilter(new ReadFilter());
                  protocolChain.addFilter(new LogFilter());
              }
              return protocolChain;
});
controller.start();                                             10
http’s module
 GrizzlyAdapter




                  11
1. Who?




          12
2.2 Http module




                  13
HTTP modules (http, http-utils)
•  The Grizzly Framework also have an HTTP framework that can be
   used to build Web Server
•  Extremely small, perfect for small devices
   >  Like iPhone, Android, Smart Box, etc.
•  Simple interface to allow customization of the HTTP Protocol
   >  GrizzlyRequest: A utility class to manipulate the HTTP protocol
      request.
   >  GrizzlyResponse: A utility class to manipulate the HTTP protocol
      response.
   >  GrizzlyAdapter: A utility class to manipulate the HTTP request/
      response object.


                                                                         14
2.2 Http module
 public class FileAdapter extends GrizzlyAdapter{
   public void service(GrizzlyRequest req,
                      GrizzlyResponse res){
     ByteChun bc = req.decodedURI();
     // Prevent XSS attack
     HttpRequestDecoded.decode(bc);
     // OK, we are safe
     res.write((loadFile(bc));
     res.flush();
     res.close();


                                                    15
2.2 Who?




           16
2.3 Grizzly Comet Framework




                              17
What is Comet?
Bending the rules of HTTP.




                             18
2.4 Grizzly Comet Framework
• Grizzly Comet is a framework that ship with
  GlassFish v1|2|3, and can also be embedded into
  any application.
  >  One day , the code will be moved to a new project
     called Atmosphere (Atmosphere.dev.java.net)
  >  Grizzly Comet, for all web server!!
• The Grizzly Comet Framework includes a set of
  components that can be used for building Comet
  based application:
  >  Grizzly Comet, Continuation, Grizzlet, Messages Bus,
    Bayeux support
                                                            19
Atmosphere….
Reuse experience and code...from Grizzly Comet to Jersey!

           Grizzlet                      Atmosphere re-usable
      (Atmosphere POJO)‫‏‬                  Components library

           Jersey's Injection Provider, Jersey’s IoC Support

                 Atmosphere Servlet Runtime Engine

  Tomcat Comet    Grizzly Comet       Jetty Comet        Blocking WS

            User defined          Atmosphere Component

                                                                       20
2.4 Who?




           21
2.5 Grizzly Servlet Container




                                22
2.5 Grizzly Servlet Container
• The community started developing a Servlet
  Container
  >  Incomplete, not (*yet*) Servlet compliant
  >  Very small and fast
  >  No extra…just the basic….with power
  >  Easy to embed in any application.


• Really useful for writing unit test.


                                                 23
2.5 Who?




           24
4. Grizzly 2
• Introduction
• Goals
• Architecture
• New features
• Examples
• Roadmap



                 25
4.1 Introduction
• Started in June 2008.
• Completely new Grizzly core API.
• No backwards compatibility requirement.
  >  1.0 suffered design limitation like supporting SJSAS,
     Tomcat API AND Sun Web Server API. This was a major
     restriction and some API are quite ugly.
  >  1.5 was a tentative to keep our 1.0 Community on board,
     and grow.
  >  1.8.x is successful, but is now time to do a revolution,
     e.g. bye bye GlassFish API 

                                                                26
4.2 Goals
• Make framework core API more clear and useful,
  based on earlier experience. Especially client side.
• Performance. Make sure API changes will not affect
  the performance, which is still the main goal for
  Grizzly.
• Introduce unified Buffer/Memory management API.
• Unify ThreadPool implementation. Make it compatible
  with ExecutorService, provided by JDK.
• Reborn a Grizzly based on Community Feedback
  and lessons learned since 2004.!
                                                         27
4.3 Architecture




                   28
4.3 New features
• Filter chain standalone read/write.
• Message parsing using streams.
• Smart message parser




                                        29
4.3.1 FilterChain standalone read/
write
• Leverage filters logic for a client side.
• Minimize the effort to build nice client code.
• Supports blocking and asynchronous modes




                                                   30
4.3.1 FilterChain standalone read/
write
TCPNIOTransport transport =
              TransportManager.instance().createTCPTransport();
transport.getFilterChain().add(new TransportFilter());
transport.getFilterChain().add(new SSLFilter());
transport.getFilterChain().add(new StringFilter());
transport.getFilterChain().add(new EchoFilter());
--- (1) start the “transport” in the server mode
--- (2) connect client the “connection” to the “transport”
Future writeFuture = transport.getFilterChain().write(connection, “Hello
  world”);
Future readFuture = transport.getFilterChain().read(connection);
String result = (String) readFuture.get();
// The result should contain “Hello world”, sent by server
                                                                           31
4.3.2 Message parsing using streams
• Simplify message parsing.
• No ByteBuffer positions, limits, capacities!
• Simple stream API, which supports Java primitive
  types and arrays.




                                                     32
4.3.2 Message parsing using streams
// initialize the filter chain
transport.getFilterChain().add(new TransportFilter());
transport.getFilterChain().add(new StreamFilter());
transport.getFilterChain().add(new CustomProtocolParser());
-------------------------------- cut --------------------------------------
public class CustomProtocolParser extends FilterAdapter {
  public NextAction handleRead(FilterChainContext context) {
      StreamMessage message =
                                  (StreamMessage) context.getMessage();
            Reader reader = message.getReader();
            if (reader.availabe(4)) {
                   int a = reader.getInt();
                   int b = reader.getInt();
                   message.getWriter().putInt(a+b);
                                                                              33
4.3.3 Smart message parser
• Knows how to parse the custom message, based on
  message class structure.
• POJO in enough, however could be driven by
  annotations.
• It's possible to provide custom encoder/decoder for
  complex types.




                                                        34
4.3.3 Smart message parser
transport.getFilterChain().add(new TransportFilter());
transport.getFilterChain().add(new SSLFilter());
// Parse the data according to MyMessage class
transport.getFilterChain().add(new SmartParserFilter(MyMessage.class));
// Echo MyMessage
transport.getFilterChain().add(new EchoFilter());
-------------------------------- cut --------------------------------------
public class MyMessage {
    public MyMessage(int a, int b) { this.a = a; this.b = b;}
    public int a;
    public int b;
}


                                                                              35
4.4 Example #1: Start the echo server
TCPNIOTransport transport =
                    TransportManager.instance().createTCPTransport();
transport.getFilterChain().add(new TransportFilter());
transport.getFilterChain().add(new EchoFilter());
try {
        transport.bind(PORT);
        transport.start();
-------------- wait until server is running ---------
} finally {
        transport.stop();
        TransportManager.instance().close();
}



                                                                        36
4.4 Example #2: Connect the client
TCPNIOTransport transport =
                    TransportManager.instance().createTCPTransport();
try {
        transport.start();
        Future future = transport.connect(HOST, PORT);
        Connectin connection =
                       future.get(connectionTimeout, TimeUnit.SECONDS);
        Future writeFuture = connection.write(message);
        Future readFuture = connection.read();
        System.out.println(“Result: “ + readFuture.get());
} finally {
        transport.stop();
        TransportManager.instance().close();
}
                                                                          37
4.4 Example #3: EchoFilter
public class EchoFilter extends FilterAdapter {

    @Override
    public NextAction handleRead(FilterChainContext ctx,
          NextAction nextAction) throws IOException {
        Object message = ctx.getMessage();
        ctx.getFilterChain().write(ctx.getConnection(), message);
        return nextAction;
    }
}




                                                                    38
5 Roadmap
• 1.8.6 was released 09/24
  >  Biggest tested community release.
• 1.9.0 still discussed
  >  Will include NIO.2 support
  >  May include an http-client new module
     – Depends on the community
  >  Last release for the 1.x branch.
• Release Grizzly 2 framework core: December 2008
• Release Grizzly 2 http module: February 2009
                                                    39
6. Summary
• Project Grizzly is a simple NIO Framework.
  >  With less than 50 lines, you can create power client or
     server side components.
  >  Support Java NIO and NIO.2
  >  Simple, but customizable.
• Grizzly 2.0 will be better than the original! Better
  API, same performance!
• Healthy community: get a response in less than 2
  hours :-)!

                                                               40
For More Information
•  Grizzly Active’s Bloggers:
   >  Alexey: http://blogs.sun.com/oleksiys/
   >  Shing Wai: http://blogs.sun.com/swchan/
   >  John: http://weblogs.java.net/blog/johnmann/
   >  Sebastien: http://www2.sebastiendionne.ca
   >  Jeanfrancois: http://weblogs.java.net/jfarcand
•  News:
   >  Every week or so, a list of interesting blogs talking about us
       http://www.nabble.com/forum/Search.jtp?forum=23249&local=y&query=News

•  Project Grizzly mailing lists,
   >  dev@grizzly.dev.java.net & users@dev.grizzly.java.net

                                                                               41

Weitere ähnliche Inhalte

Was ist angesagt?

Servlet 3.1
Servlet 3.1Servlet 3.1
Servlet 3.1Arun Gupta
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSocketsGunnar Hillert
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...Edureka!
 
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)Shing Wai Chan
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikEdgar Espina
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Arun Gupta
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishArun Gupta
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...Ivan Loire
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppEdureka!
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Yevgeniy Brikman
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystemYukti Kaura
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaYevgeniy Brikman
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to JavaDavid Delabassee
 

Was ist angesagt? (20)

JavaCro'15 - Reactive I/O - Ivan Turčinović
JavaCro'15 - Reactive I/O - Ivan TurčinovićJavaCro'15 - Reactive I/O - Ivan Turčinović
JavaCro'15 - Reactive I/O - Ivan Turčinović
 
Servlet 3.1
Servlet 3.1Servlet 3.1
Servlet 3.1
 
Java EE 6
Java EE 6Java EE 6
Java EE 6
 
Introduction to WebSockets
Introduction to WebSocketsIntroduction to WebSockets
Introduction to WebSockets
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
 
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)
JavaOne San Francisco 2013 - Servlet 3.1 (JSR 340)
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip Hanik
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 
OSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFishOSGi-enabled Java EE Applications using GlassFish
OSGi-enabled Java EE Applications using GlassFish
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
 
HTML5 WebSockets
HTML5 WebSocketsHTML5 WebSockets
HTML5 WebSockets
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
GlassFish Embedded API
GlassFish Embedded APIGlassFish Embedded API
GlassFish Embedded API
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
 
Best node js course
Best node js courseBest node js course
Best node js course
 

Ähnlich wie Grizzly and Grizzly 2.0: An Overview of the Popular Java NIO Framework

FIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Zabbix
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developerPaul Czarkowski
 
Going Live! with Comet
Going Live! with CometGoing Live! with Comet
Going Live! with CometSimon Willison
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rulesFreddy BuenaĂąo
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008Association Paris-Web
 
XS Boston 2008 Network Topology
XS Boston 2008 Network TopologyXS Boston 2008 Network Topology
XS Boston 2008 Network TopologyThe Linux Foundation
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Servicesmattjive
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microserviceGiulio De Donato
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetesWilliam Stewart
 
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTBenjamin CabĂŠ
 
What’s new in cas 4.2
What’s new in cas 4.2 What’s new in cas 4.2
What’s new in cas 4.2 Misagh Moayyed
 
SDN applications with floodlight
SDN applications with floodlightSDN applications with floodlight
SDN applications with floodlightDamascus University
 
FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018Xavier Mertens
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Velocidex Enterprises
 

Ähnlich wie Grizzly and Grizzly 2.0: An Overview of the Popular Java NIO Framework (20)

Grizzly Comet Aquarium Paris
Grizzly Comet Aquarium ParisGrizzly Comet Aquarium Paris
Grizzly Comet Aquarium Paris
 
FIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart SystemsFIWARE Wednesday Webinars - Short Term History within Smart Systems
FIWARE Wednesday Webinars - Short Term History within Smart Systems
 
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
Erik Skytthe - Monitoring Mesos, Docker, Containers with Zabbix | ZabConf2016
 
GlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium ParisGlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium Paris
 
GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6GlassFish v3 : En Route Java EE 6
GlassFish v3 : En Route Java EE 6
 
Kubernetes for the PHP developer
Kubernetes for the PHP developerKubernetes for the PHP developer
Kubernetes for the PHP developer
 
Going Live! with Comet
Going Live! with CometGoing Live! with Comet
Going Live! with Comet
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
 
XS Boston 2008 Network Topology
XS Boston 2008 Network TopologyXS Boston 2008 Network Topology
XS Boston 2008 Network Topology
 
Time for Comet?
Time for Comet?Time for Comet?
Time for Comet?
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoTDevoxx 2015 - Building the Internet of Things with Eclipse IoT
Devoxx 2015 - Building the Internet of Things with Eclipse IoT
 
Kommons
KommonsKommons
Kommons
 
What’s new in cas 4.2
What’s new in cas 4.2 What’s new in cas 4.2
What’s new in cas 4.2
 
SDN applications with floodlight
SDN applications with floodlightSDN applications with floodlight
SDN applications with floodlight
 
FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018FPC for the Masses - CoRIIN 2018
FPC for the Masses - CoRIIN 2018
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3
 

Mehr von Eduardo Pelegri-Llopart

Pelegri Desarrollando en una nueva era de software
Pelegri   Desarrollando en una nueva era de software Pelegri   Desarrollando en una nueva era de software
Pelegri Desarrollando en una nueva era de software Eduardo Pelegri-Llopart
 
Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Eduardo Pelegri-Llopart
 
The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015Eduardo Pelegri-Llopart
 
IOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ ProgressIOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ ProgressEduardo Pelegri-Llopart
 
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...Eduardo Pelegri-Llopart
 
What is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouWhat is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouEduardo Pelegri-Llopart
 
Community Update 25 Mar2010 - English
Community Update 25 Mar2010 - EnglishCommunity Update 25 Mar2010 - English
Community Update 25 Mar2010 - EnglishEduardo Pelegri-Llopart
 
GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010Eduardo Pelegri-Llopart
 
Glass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.MiniGlass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.MiniEduardo Pelegri-Llopart
 
Ehcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEhcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEduardo Pelegri-Llopart
 

Mehr von Eduardo Pelegri-Llopart (20)

Juggling at freenome
Juggling   at freenomeJuggling   at freenome
Juggling at freenome
 
Csumb capstone-fall2016
Csumb capstone-fall2016Csumb capstone-fall2016
Csumb capstone-fall2016
 
Digital activitymanagement
Digital activitymanagementDigital activitymanagement
Digital activitymanagement
 
Progress next iot_pelegri
Progress next iot_pelegriProgress next iot_pelegri
Progress next iot_pelegri
 
Pelegri Desarrollando en una nueva era de software
Pelegri   Desarrollando en una nueva era de software Pelegri   Desarrollando en una nueva era de software
Pelegri Desarrollando en una nueva era de software
 
Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015Market trends in IT - exchange cala - October 2015
Market trends in IT - exchange cala - October 2015
 
The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015The impact of IOT - exchange cala - 2015
The impact of IOT - exchange cala - 2015
 
IOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ ProgressIOT - Presentation to PEP @ Progress
IOT - Presentation to PEP @ Progress
 
Node.js as an IOT Bridge
Node.js as an IOT BridgeNode.js as an IOT Bridge
Node.js as an IOT Bridge
 
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
What is IoT and how Modulus and Pacific can Help - Featuring Node.js and Roll...
 
What is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts YouWhat is the Internet of Things and How it Impacts You
What is the Internet of Things and How it Impacts You
 
Community Update 25 Mar2010 - English
Community Update 25 Mar2010 - EnglishCommunity Update 25 Mar2010 - English
Community Update 25 Mar2010 - English
 
GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010GlassFish Community Update 25 Mar2010
GlassFish Community Update 25 Mar2010
 
Glass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.MiniGlass Fish Portfolio C1 West V3.Mini
Glass Fish Portfolio C1 West V3.Mini
 
Virtual Box Aquarium May09
Virtual Box Aquarium May09Virtual Box Aquarium May09
Virtual Box Aquarium May09
 
Introduction To Web Beans
Introduction To Web BeansIntroduction To Web Beans
Introduction To Web Beans
 
Ehcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage PatternsEhcache Architecture, Features And Usage Patterns
Ehcache Architecture, Features And Usage Patterns
 
OpenDS Primer Aquarium
OpenDS Primer AquariumOpenDS Primer Aquarium
OpenDS Primer Aquarium
 
Fuji Overview
Fuji OverviewFuji Overview
Fuji Overview
 
Nuxeo 5.2 Glassfish
Nuxeo 5.2 GlassfishNuxeo 5.2 Glassfish
Nuxeo 5.2 Glassfish
 

KĂźrzlich hochgeladen

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂşjo
 

KĂźrzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Grizzly and Grizzly 2.0: An Overview of the Popular Java NIO Framework

  • 1. Overview of Grizzly and Grizzly 2.0 Oleksiy Stashok Jeanfrancois Arcand Sun Microsystems 1
  • 2. Agenda • What is project Grizzly • Grizzly modules • Grizzly 2.0 • RoadMap • Summary Footnote position, 12 pts. 2
  • 3. 1. What is Project Grizzly • Open Source Project https://grizzly.dev.java.net • Open Sourced under CDDL/LGPL license. • Very open community policy. >  All project communications are done on Grizzly mailing list. No internal, off mailing list conversations a-la-Sailfin. >  Project meetings open to anyone • Project decisions are made by project member votes. Code contributions frequents. • Approx ~25 000 download for the last 3 months • Mailing list quite busy some day! 3
  • 4. 1. What is project Grizzly • Commiters >  Oleksiy Stashok (Sun) – Lead (all modules) >  Jean-Francois Arcand (Sun)‫( ‏‬all modules) >  Shing Wai Chan (Sun)‫( ‏‬http, comet, bayeux) >  Ken Cavanaugh (Sun)‫( ‏‬framework) >  Charlie Hunt (Sun)‫( ‏‬framework) >  John Vieten (Conclude GmbH)‫( ‏‬tutorial, framework) >  Sebastien Dionne (Consultant)‫( ‏‬tutorial, framework) >  Takai Naoto (ITOCHU Techno-Solution)‫( ‏‬jruby, bayeux) •  Active users list…the community answer for us! 4
  • 5. What is Project Grizzly   ses Java NIO primitives and hides the complexity U programming with Java NIO.   tarted in 2004 (Grizzly 1.0). Own project February 2007 S (Grizzly 1.5)   .0 represented extracted network layer of Glassfish 1   asy-to-use high performance APIs for TCP, UDP and SSL E communications.   tilizes high performance buffers and buffer management. U   hoice of several different high performance thread pools. C   hip with an HTTP module which is really easy to embed. S 5
  • 8. 2.1 Framework •  The root of Grizzly. Everything build on top of this module •  The Grizzly Framework bundles default implementation for TCP, UDP and TLS/SSL transports. •  Used to implement protocol based applications like http, sip, custom protocol, etc. •  In this module, EVERYTHING is customizable. If the default isn't doing what you need , customize it! 8
  • 10. Example: Simple log server over TCP Controller controller = new Controller(); controller.setProtocolChainInstanceHandler(new DefaultProtocolChainInstanceHandler() { ProtocolChain protocolChain; // Stateless ProtocolChain public ProtocolChain poll() { if(protocolChain == null) { protocolChain = new DefaultProtocolChain(); protocolChain.addFilter(new ReadFilter()); protocolChain.addFilter(new LogFilter()); } return protocolChain; }); controller.start(); 10
  • 12. 1. Who? 12
  • 14. HTTP modules (http, http-utils) •  The Grizzly Framework also have an HTTP framework that can be used to build Web Server •  Extremely small, perfect for small devices >  Like iPhone, Android, Smart Box, etc. •  Simple interface to allow customization of the HTTP Protocol >  GrizzlyRequest: A utility class to manipulate the HTTP protocol request. >  GrizzlyResponse: A utility class to manipulate the HTTP protocol response. >  GrizzlyAdapter: A utility class to manipulate the HTTP request/ response object. 14
  • 15. 2.2 Http module public class FileAdapter extends GrizzlyAdapter{ public void service(GrizzlyRequest req, GrizzlyResponse res){ ByteChun bc = req.decodedURI(); // Prevent XSS attack HttpRequestDecoded.decode(bc); // OK, we are safe res.write((loadFile(bc)); res.flush(); res.close(); 15
  • 16. 2.2 Who? 16
  • 17. 2.3 Grizzly Comet Framework 17
  • 18. What is Comet? Bending the rules of HTTP. 18
  • 19. 2.4 Grizzly Comet Framework • Grizzly Comet is a framework that ship with GlassFish v1|2|3, and can also be embedded into any application. >  One day , the code will be moved to a new project called Atmosphere (Atmosphere.dev.java.net) >  Grizzly Comet, for all web server!! • The Grizzly Comet Framework includes a set of components that can be used for building Comet based application: >  Grizzly Comet, Continuation, Grizzlet, Messages Bus, Bayeux support 19
  • 20. Atmosphere…. Reuse experience and code...from Grizzly Comet to Jersey! Grizzlet Atmosphere re-usable (Atmosphere POJO)‫‏‬ Components library Jersey's Injection Provider, Jersey’s IoC Support Atmosphere Servlet Runtime Engine Tomcat Comet Grizzly Comet Jetty Comet Blocking WS User defined Atmosphere Component 20
  • 21. 2.4 Who? 21
  • 22. 2.5 Grizzly Servlet Container 22
  • 23. 2.5 Grizzly Servlet Container • The community started developing a Servlet Container >  Incomplete, not (*yet*) Servlet compliant >  Very small and fast >  No extra…just the basic….with power >  Easy to embed in any application. • Really useful for writing unit test. 23
  • 24. 2.5 Who? 24
  • 26. 4.1 Introduction • Started in June 2008. • Completely new Grizzly core API. • No backwards compatibility requirement. >  1.0 suffered design limitation like supporting SJSAS, Tomcat API AND Sun Web Server API. This was a major restriction and some API are quite ugly. >  1.5 was a tentative to keep our 1.0 Community on board, and grow. >  1.8.x is successful, but is now time to do a revolution, e.g. bye bye GlassFish API  26
  • 27. 4.2 Goals • Make framework core API more clear and useful, based on earlier experience. Especially client side. • Performance. Make sure API changes will not affect the performance, which is still the main goal for Grizzly. • Introduce unified Buffer/Memory management API. • Unify ThreadPool implementation. Make it compatible with ExecutorService, provided by JDK. • Reborn a Grizzly based on Community Feedback and lessons learned since 2004.! 27
  • 29. 4.3 New features • Filter chain standalone read/write. • Message parsing using streams. • Smart message parser 29
  • 30. 4.3.1 FilterChain standalone read/ write • Leverage filters logic for a client side. • Minimize the effort to build nice client code. • Supports blocking and asynchronous modes 30
  • 31. 4.3.1 FilterChain standalone read/ write TCPNIOTransport transport = TransportManager.instance().createTCPTransport(); transport.getFilterChain().add(new TransportFilter()); transport.getFilterChain().add(new SSLFilter()); transport.getFilterChain().add(new StringFilter()); transport.getFilterChain().add(new EchoFilter()); --- (1) start the “transport” in the server mode --- (2) connect client the “connection” to the “transport” Future writeFuture = transport.getFilterChain().write(connection, “Hello world”); Future readFuture = transport.getFilterChain().read(connection); String result = (String) readFuture.get(); // The result should contain “Hello world”, sent by server 31
  • 32. 4.3.2 Message parsing using streams • Simplify message parsing. • No ByteBuffer positions, limits, capacities! • Simple stream API, which supports Java primitive types and arrays. 32
  • 33. 4.3.2 Message parsing using streams // initialize the filter chain transport.getFilterChain().add(new TransportFilter()); transport.getFilterChain().add(new StreamFilter()); transport.getFilterChain().add(new CustomProtocolParser()); -------------------------------- cut -------------------------------------- public class CustomProtocolParser extends FilterAdapter { public NextAction handleRead(FilterChainContext context) { StreamMessage message = (StreamMessage) context.getMessage(); Reader reader = message.getReader(); if (reader.availabe(4)) { int a = reader.getInt(); int b = reader.getInt(); message.getWriter().putInt(a+b); 33
  • 34. 4.3.3 Smart message parser • Knows how to parse the custom message, based on message class structure. • POJO in enough, however could be driven by annotations. • It's possible to provide custom encoder/decoder for complex types. 34
  • 35. 4.3.3 Smart message parser transport.getFilterChain().add(new TransportFilter()); transport.getFilterChain().add(new SSLFilter()); // Parse the data according to MyMessage class transport.getFilterChain().add(new SmartParserFilter(MyMessage.class)); // Echo MyMessage transport.getFilterChain().add(new EchoFilter()); -------------------------------- cut -------------------------------------- public class MyMessage { public MyMessage(int a, int b) { this.a = a; this.b = b;} public int a; public int b; } 35
  • 36. 4.4 Example #1: Start the echo server TCPNIOTransport transport = TransportManager.instance().createTCPTransport(); transport.getFilterChain().add(new TransportFilter()); transport.getFilterChain().add(new EchoFilter()); try { transport.bind(PORT); transport.start(); -------------- wait until server is running --------- } finally { transport.stop(); TransportManager.instance().close(); } 36
  • 37. 4.4 Example #2: Connect the client TCPNIOTransport transport = TransportManager.instance().createTCPTransport(); try { transport.start(); Future future = transport.connect(HOST, PORT); Connectin connection = future.get(connectionTimeout, TimeUnit.SECONDS); Future writeFuture = connection.write(message); Future readFuture = connection.read(); System.out.println(“Result: “ + readFuture.get()); } finally { transport.stop(); TransportManager.instance().close(); } 37
  • 38. 4.4 Example #3: EchoFilter public class EchoFilter extends FilterAdapter { @Override public NextAction handleRead(FilterChainContext ctx, NextAction nextAction) throws IOException { Object message = ctx.getMessage(); ctx.getFilterChain().write(ctx.getConnection(), message); return nextAction; } } 38
  • 39. 5 Roadmap • 1.8.6 was released 09/24 >  Biggest tested community release. • 1.9.0 still discussed >  Will include NIO.2 support >  May include an http-client new module – Depends on the community >  Last release for the 1.x branch. • Release Grizzly 2 framework core: December 2008 • Release Grizzly 2 http module: February 2009 39
  • 40. 6. Summary • Project Grizzly is a simple NIO Framework. >  With less than 50 lines, you can create power client or server side components. >  Support Java NIO and NIO.2 >  Simple, but customizable. • Grizzly 2.0 will be better than the original! Better API, same performance! • Healthy community: get a response in less than 2 hours :-)! 40
  • 41. For More Information •  Grizzly Active’s Bloggers: >  Alexey: http://blogs.sun.com/oleksiys/ >  Shing Wai: http://blogs.sun.com/swchan/ >  John: http://weblogs.java.net/blog/johnmann/ >  Sebastien: http://www2.sebastiendionne.ca >  Jeanfrancois: http://weblogs.java.net/jfarcand •  News: >  Every week or so, a list of interesting blogs talking about us http://www.nabble.com/forum/Search.jtp?forum=23249&local=y&query=News •  Project Grizzly mailing lists, >  dev@grizzly.dev.java.net & users@dev.grizzly.java.net 41