dev@glassfish.java.net

Re: multiprotocol listener

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Thu, 20 Jul 2006 15:26:18 -0400

Hi Alexey,

apology for the delay.

Oleksiy Stashok wrote:
> Hi,
>
> i'm working on tcp transport for JAX-WS.
> for now tcp listener is implemented as GF lifecycle module and http
> listener is regular GF http listener, but i need to investingate
> possibility of implementing one listener for both tcp&http transport
> that will listen on single tcp port.
>
> For now i see one possible solution is to extend GF lifecycle module to
> preread first message bytes and if its tcp transport message - process
> it locally, if http - *somehow* transfer to web container for futher
> processing.
>
> The question is...
> 1) Is it possible? :)

Yes, that's possible.

> 2) Probably there are other solutions?

The easiest solution is to combine NIO + SSLEngine (so you can handle
SSL and plain text). With the SSLEngine, you will be able to read the
request line bytes and find if its SSL or not. Next you can look at the
request line bytes and retrieve the protocol. If that's HTTP, then just
return an HTTP redirect:

HTTP/1.1 302 OK
Location: http://<<host>>:<<port>>/originalUrl

to an http-listener listening <<port>> that support HTTP.

For SSLEngine stuff, take a look at:

https://glassfish.dev.java.net/source/browse/*checkout*/glassfish/appserv-http-engine/src/java/com/sun/enterprise/web/connector/grizzly/ssl/SSLReadTask.java

Thanks

-- Jeanfrancois

>
> Thanks.
>
> WBR,
> Alexey.
>