jsr340-experts@servlet-spec.java.net

[jsr340-experts] Proposed changes to upgrade mechanism

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Wed, 28 Nov 2012 16:33:04 -0800

Based on and expert group and other discussions, I propose the following changes to upgrade mechanism.

1. rename ProtocolHandler to HttpUpgradeHandler

2. add a way for the handler code to end a connection
     public interface WebConnection extends java.io.AutoCloseable;
     (In this case, we need JDK 7.)

3. add a way to inform the handler code when the client is disconnected
     Add the following API to ProtocolHandler:
     public void destroy();

4. Change the HttpServletRequest#upgrade from
     public void upgrade(ProtocolHandler handler) throws IOException;
     to
     public<T extends HttpUpgradeHandler> T upgrade(Class<T> handler) throws IOException;
    And we will require that the class passed in has a no ops constructor.
    In this case, the user can configure the HttpUpgradeHandler instance before upgrade processing
    and will be benefited by dependency injection.

Please let me know if you have any comment.
Thanks.
      Shing Wai Chan