Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet API implementation using Netty

Has anyone made a Servlet API implementation built on top of Netty? I'm tempted to build my own as I can't google an implementation.

  • http://www.jboss.org/netty/community#nabble-td4752485
  • http://markmail.org/message/4qmvuaacxqzevqhc

Basically I'm looking to support just enough to get jersey working (hopefully jersey is not doing any threadlocal stuff).

like image 280
Adam Gent Avatar asked Sep 16 '11 03:09

Adam Gent


People also ask

Does Netty support Servlets?

Netty Servlet Bridge allows integration of existing Servlet API based web-applications into the Netty-backed infrastructure.

Is Netty a webserver?

Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.


4 Answers

Jersey does not require servlet - runs fine even with the lightweight http server included in JDK or even runs with Grizzly NIO framework (which is similar to Netty - see grizzly.java.net). To see what it takes to make it run with Netty, you may want to look at jersey-grizzly2 module in Jersey workspace - would be nice if you would be willing to develop that and contribute to the Jersey project. Now, to disappoint you, Jersey does use ThreadLocals. We have been planning to introduce support for non-blocking async calls, but that requires a fair amount of refactoring, so will only come with 2.0 version (implementing JAX-RS 2.0 once that's final). Anyway, apart from the non-blocking stuff, it is still useful to run it on Grizzly-like framework such as Netty for its "light-weightness".

like image 99
Martin Matula Avatar answered Oct 11 '22 02:10

Martin Matula


If you want use Jersey with Netty, you probably need to be safe and use org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory

not,

org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory

This will allow the ThreadLocal stuff work correctly under load.

Of course, when Jersey upgrades to not use ThreadLocal, but ChannelLocal, this will not longer be needed.

like image 33
Bob Stiles Avatar answered Oct 11 '22 04:10

Bob Stiles


If you want to get Jersey working with Netty you can use the bindings available at https://github.com/cgbystrom/jersey-netty

like image 31
cgbystrom Avatar answered Oct 11 '22 02:10

cgbystrom


Do you looking for Netty-Servlet-bridge?

This project provides a Servlet API implementation for Netty.IO framework (http://netty.io/).

Netty Servlet Bridge allows integration of existing Servlet API based web-applications into the Netty-backed infrastructure.

like image 44
Anton Bessonov Avatar answered Oct 11 '22 03:10

Anton Bessonov