jsr340-experts@servlet-spec.java.net

[jsr340-experts] Re: Async IO and Upgrade proposal updated

From: Remy Maucherat <rmaucher_at_redhat.com>
Date: Mon, 26 Mar 2012 12:46:24 +0200

On Thu, 2012-03-22 at 14:27 -0700, Shing Wai Chan wrote:
> public class EchoProtocolHandler implements ProtocolHandler {
> public void init(WebConnection wc) {
> wc.getInputStream().setReadListener(new ReadListener() {
> public void onDataAvailable() {
> try {
> ServletInputStream sis = wc.getInputStream();
> byte[] dataBytes = new byte[sis.dataAvailable()];
> sis.read(dataBytes);
> wc.getOutputStream().write(dataBytes);
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>

+1 for it, but it could be nice to avoid using ServletInputStream and
ServletOutputStream for the upgraded connections, it has a lot of extra
methods that are not very useful. [it should only have byte[] based
methods IMO]

-- 
Remy Maucherat <rmaucher_at_redhat.com>
Red Hat Inc