X-Mozilla-Keys:                                                                                 
Received: from ucsinet22.oracle.com (/156.151.31.94)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Wed, 21 May 2014 13:48:36 -0700
Received: from ucsinet41.oracle.com (ucsinet41.oracle.com [156.151.31.69])
	by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s4LKmZo2005595
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL);
	Wed, 21 May 2014 20:48:35 GMT
Received: from mail01.java.net (unknown [137.254.58.23]) by ucsinet41.oracle.com with smtp
	 id 1322_0088_b60b2dde_9ef7_4e3a_9e65_f819c8d19832;
	Wed, 21 May 2014 20:48:24 +0000
Received: from localhost (akxmz006 [127.0.0.1])
	by mail01.java.net (Postfix) with ESMTP id B07F347722;
	Wed, 21 May 2014 20:48:23 +0000 (UTC)
X-Virus-Scanned: amavisd-new at oracle.com
Received: from mail01.java.net ([127.0.0.1])
	by localhost (akxmz006.oracle.com [127.0.0.1]) (amavisd-new, port 10025)
	with ESMTP id DiKehFJG2QH2; Wed, 21 May 2014 20:48:00 +0000 (UTC)
Received: by mail01.java.net (Postfix, from userid 60005)
	id DD3E6476FA; Wed, 21 May 2014 20:48:00 +0000 (UTC)
Received: from acsinet40.oracle.com (acsinet40.oracle.com [141.146.126.228])
	by mail01.java.net (Postfix) with ESMTP id E1279476F4
	for <jsr356-experts@websocket-spec.java.net>; Wed, 21 May 2014 20:47:58 +0000 (UTC)
Received: from userp1040.oracle.com (unknown [156.151.31.81]) by acsinet40.oracle.com with smtp
	(TLS: TLSv1/SSLv3,256bits,AES256-SHA)
	 id 4649_01d7_e4460d3b_c61e_451a_a176_c401967297ec;
	Wed, 21 May 2014 20:45:28 +0000
Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94])
	by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s4LKlucR009074
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <jsr356-experts@websocket-spec.java.net>; Wed, 21 May 2014 20:47:56 GMT
Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231])
	by ucsinet22.oracle.com (8.14.5+Sun/8.14.5) with ESMTP id s4LKltNG004015
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <jsr356-experts@websocket-spec.java.net>; Wed, 21 May 2014 20:47:56 GMT
Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16])
	by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s4LKltCi012099
	for <jsr356-experts@websocket-spec.java.net>; Wed, 21 May 2014 20:47:55 GMT
Received: from dhcp-whq-twvpn-2-vpnpool-10-159-171-121.vpn.oracle.com (/10.159.171.121)
	by default (Oracle Beehive Gateway v4.0)
	with ESMTP ; Wed, 21 May 2014 13:47:54 -0700
Message-ID: <537D10F8.4050505@oracle.com>
Date: Wed, 21 May 2014 22:47:52 +0200
From: Pavel Bucek <pavel.bucek@oracle.com>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
MIME-Version: 1.0
To: jsr356-experts@websocket-spec.java.net
References: <537C7053.50404@oracle.com> <537CE73B.70801@oracle.com> <537CEDDC.20106@gmail.com>
In-Reply-To: <537CEDDC.20106@gmail.com>
Content-Type: multipart/alternative;
 boundary="------------080406080602030601000903"
X-Source-IP: ucsinet22.oracle.com [156.151.31.94]
Subject: [jsr356-experts] Re: JSR 356 - Maintenance Release Draft -
 WEBSOCKET_SPEC-226
Reply-To: jsr356-experts@websocket-spec.java.net
X-Loop: jsr356-experts@websocket-spec.java.net
X-Sequence: 550
Errors-to: jsr356-experts-owner@websocket-spec.java.net
Precedence: list
X-no-archive: yes
List-Id: <jsr356-experts.websocket-spec.java.net>
List-Help: <mailto:sympa@websocket-spec.java.net?subject=help>
List-Subscribe: <mailto:sympa@websocket-spec.java.net?subject=subscribe%20jsr356-experts>
List-Unsubscribe: <mailto:sympa@websocket-spec.java.net?subject=unsubscribe%20jsr356-experts>
List-Post: <mailto:jsr356-experts@websocket-spec.java.net>
List-Owner: <mailto:jsr356-experts-request@websocket-spec.java.net>

This is a multi-part message in MIME format.
--------------080406080602030601000903
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-MIME-Autoconverted: from 8bit to quoted-printable by userp1040.oracle.com id s4LKlucR009074
Content-Transfer-Encoding: quoted-printable

Hello Jean-Fran=E7ois,

breaking current commits into different ones would break lots of links=20
which are already in circulation, so I don't really want to do that. But=20
what I can do is extract the important changes and put the result here.

*API:*

diff --git a/api/client/src/main/java/javax/websocket/Endpoint.java=20
b/api/client/src/main/java/javax/websocket/Endpoint.java
index a8f018c..be599aa 100644
--- *a/api/client/src/main/java/javax/websocket/Endpoint.java*
+++ b/api/client/src/main/java/javax/websocket/Endpoint.java
@@ -76,7 +76,7 @@ package javax.websocket;
   *
   *     public void onOpen(Session session, EndpointConfig config) {
   *         final RemoteEndpoint remote =3D session.getBasicRemote();
- * session.addMessageHandler(new MessageHandler.Whole&lt;String>() {
+ * session.addMessageHandler(String.class, new=20
MessageHandler.Whole&lt;String>() {
   *             public void onMessage(String text) {
   *                 try {
   *                     remote.sendString("Got your message (" + text +=20
"). Thanks !");

diff --git a/api/client/src/main/java/javax/websocket/Session.java=20
b/api/client/src/main/java/javax/websocket/Session.java
index 6d6d4fe..0fdab21 100644
--- *a/api/client/src/main/java/javax/websocket/Session.java*
+++ b/api/client/src/main/java/javax/websocket/Session.java
@@ -86,8 +86,13 @@ public interface Session extends Closeable {
       * messages. For further details of which message handlers handle=20
which of the native websocket
       * message types please see {@link MessageHandler.Whole} and=20
{@link MessageHandler.Partial}.
       * Adding more than one of any one type will result in a runtime=20
exception.
-     *
-     * <p>See {@link Endpoint} for a usage example.
+     * <p>
+     * This method is not safe to use unless you are providing an=20
anonymous class derived directly
+     * from {@link javax.websocket.MessageHandler.Whole} or {@link=20
javax.websocket.MessageHandler.Partial}.
+     * In all other cases (Lambda Expressions, more complex inheritance=20
or generic type arrangements),
+     * one of the following methods have to be used:
+     * {@link #addMessageHandler(Class,=20
javax.websocket.MessageHandler.Whole)} or
+     * {@link #addMessageHandler(Class,=20
javax.websocket.MessageHandler.Partial)}.
       *
       * @param handler the MessageHandler to be added.
       * @throws IllegalStateException if there is already a=20
MessageHandler registered for the same native
@@ -96,6 +101,40 @@ public interface Session extends Closeable {
      void addMessageHandler(MessageHandler handler) throws=20
IllegalStateException;

      /**
+     * Register to handle to incoming messages in this conversation. A=20
maximum of one message handler per
+     * native websocket message type (text, binary, pong) may be added=20
to each Session. I.e. a maximum
+     * of one message handler to handle incoming text messages a=20
maximum of one message handler for
+     * handling incoming binary messages, and a maximum of one for=20
handling incoming pong
+     * messages. For further details of which message handlers handle=20
which of the native websocket
+     * message types please see {@link MessageHandler.Whole} and {@link=20
MessageHandler.Partial}.
+     * Adding more than one of any one type will result in a runtime=20
exception.
+     *
+     * @param clazz   type of the message processed by message handler=20
to be registered.
+     * @param handler whole message handler to be added.
+     * @throws IllegalStateException if there is already a=20
MessageHandler registered for the same native
+     *                               websocket message type as this=20
handler.
+     * @since 1.1
+     */
+    public <T> void addMessageHandler(Class<T> clazz,=20
MessageHandler.Whole<T> handler);
+
+    /**
+     * Register to handle to incoming messages in this conversation. A=20
maximum of one message handler per
+     * native websocket message type (text, binary, pong) may be added=20
to each Session. I.e. a maximum
+     * of one message handler to handle incoming text messages a=20
maximum of one message handler for
+     * handling incoming binary messages, and a maximum of one for=20
handling incoming pong
+     * messages. For further details of which message handlers handle=20
which of the native websocket
+     * message types please see {@link MessageHandler.Whole} and {@link=20
MessageHandler.Partial}.
+     * Adding more than one of any one type will result in a runtime=20
exception.
+     *
+     * @param clazz   type of the message processed by message handler=20
to be registered.
+     * @param handler partial message handler to be added.
+     * @throws IllegalStateException if there is already a=20
MessageHandler registered for the same native
+     *                               websocket message type as this=20
handler.
+     * @since 1.1
+     */
+    public <T> void addMessageHandler(Class<T> clazz,=20
MessageHandler.Partial<T> handler);
+
+    /**
       * Return an unmodifiable copy of the set of MessageHandlers for=20
this Session.
       *
       * @return the set of message handlers.

*Spec document:*

diff --git a/spec/chapters/applications.tex b/spec/chapters/applications.tex
index 765fac5..01263bc 100644
--- *a/spec/chapters/applications.tex*
+++ b/spec/chapters/applications.tex
@@ -34,6 +34,8 @@ The API limits the registration of=20
\textbf{MessageHandlers} per \textbf{Session}

  Future versions of the specification may lift this restriction.

+Method \textbf{Session.addMessageHandler(MessageHandler)} is not safe=20
for use in all circumstances, especially when using Lambda Expressions.=20
The API forces implementations to get the \textbf{MessageHandler}'s type=20
parameter in runtime, which is not always possible.  The only case where=20
you can safely use this method is when you are directly implementing=20
\textbf{MessageHandler.Whole} or \textbf{MessageHandler.Partial} as an=20
anonymous class. This approach guarantees that generic type information=20
will be present in the generated class file and the runtime will be able=20
to get it. For any other case (Lambda Expressions included), one of=20
following methods have to be used:=20
\textbf{Session.addMessageHandler(Class$<$T$>$,=20
MessageHandler.Partial$<$T$>$)} or=20
\textbf{Session.addMessageHandler(Class$<$T$>$,=20
MessageHandler.Whole$<$T$>$)}.
+
  \subsection{Sending Messages}

  The Java WebSocket API models each peer of a session with an endpoint=20
as an instance of the \textbf{RemoteEndpoint} interface. This interface=20
and its two subtypes (\textbf{RemoteEndpoint.Whole} and=20
\textbf{RemoteEndpoint.Partial}) contain a variety of methods for=20
sending websocket messages from the endpoint to its peer.
@@ -47,7 +49,8 @@ public class HelloServer extends Endpoint {
      @Override
      public void onOpen(Session session, EndpointConfig ec) {
          final RemoteEndpoint.Basic remote =3D session.getBasicRemote();
- session.addMessageHandler(new MessageHandler.Whole<String>() {
+ session.addMessageHandler(String.class,
+          new MessageHandler.Whole<String>() {
              public void onMessage(String text) {
                  try {
                      remote.sendText("Got your message (" + text + ").=20
Thanks !");


Hope it helps,
Pavel

On 21/05/14 20:18, Jeanfrancois Arcand wrote:
> Pavel,
>
> can you redo the diff that *only* include relevant change? I think it=20
> worth for all of us to just see what is really changed.
>
> Thanks
>
> -- Jeanfrancois
> On 2014-05-21, 1:49 PM, Pavel Bucek wrote:
>>
>> Please provide any feedback by COB Friday - 5/30/2014. We plan to=20
>> send this to JCP in the first week of June to start the 30 day review=20
>> period for this MR.
>>
>> Thanks,
>> Pavel
>>
>> On 21/05/14 11:22, Pavel Bucek wrote:
>>> Hi all,
>>>
>>> as you might have noticed, I filed blocker bug against=20
>>> WEBSOCKET_SPEC project - [1].
>>>
>>> The main issue is that current Session.addMessageHandler method=20
>>> cannot handle message handlers in form of lambda expressions,=20
>>> because there is no information about its generic type parameter=20
>>> available. We discussed this issue with Brian Goetz and he pointed=20
>>> out that current API is wrong not only for this case, but also for=20
>>> more complicated generics usages and is reliable only for anonymous=20
>>> classes created directly from MessageHandler.Whole and=20
>>> MessageHandler.Partial (type information is in the generated class=20
>>> file), so the issue itself is not limited only to Java SE 8.
>>>
>>> We think that this issue is important enough to fix it in a=20
>>> Maintenance Release as soon as possible, not tied to Java EE 8=20
>>> planning or anything else.
>>>
>>> Proposed solution is to add two additional Session.addMessageHandler=20
>>> methods with explicit type information, please see [2] for more=20
>>> complete description. I also attached updated version of the=20
>>> specification document. There is only one addition - last paragraph=20
>>> in chapter 2.1.3 "Receiving Messages" and the sample code in chapter=20
>>> 2.1.4 "Sending Messages" was modified to use the newly introduced=20
>>> addMessageHandler method with explicit type.
>>>
>>> Complete change diff can be seen here [3] (but it contains lots of=20
>>> noise - spec licence etc; changes.txt should be good enough for=20
>>> evaluation).
>>>
>>> Any feedback would be greatly appreciated!
>>>
>>> Thanks and regards,
>>> Pavel
>>>
>>> [1]: https://java.net/jira/browse/WEBSOCKET_SPEC-226
>>> [2]:=20
>>> https://github.com/pavelbucek/websocket-spec/blob/WEBSOCKET_SPEC-226/we=
bsocket-1.1-changes.txt
>>> [3]: https://github.com/pavelbucek/websocket-spec/pull/1/files
>>
>
>


--------------080406080602030601000903
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Jean-Fran&ccedil;ois,<br>
      <br>
      breaking current commits into different ones would break lots of
      links which are already in circulation, so I don't really want to
      do that. But what I can do is extract the important changes and
      put the result here.<br>
      <br>
      <b>API:</b><br>
      <tt><br>
      </tt><tt>diff --git
        a/api/client/src/main/java/javax/websocket/Endpoint.java
        b/api/client/src/main/java/javax/websocket/Endpoint.java</tt><tt><br>
      </tt><tt>index a8f018c..be599aa 100644</tt><tt><br>
      </tt><tt>--- <b>a/api/client/src/main/java/javax/websocket/Endpoint.java</b></tt><tt><br>
      </tt><tt>+++
        b/api/client/src/main/java/javax/websocket/Endpoint.java</tt><tt><br>
      </tt><tt>@@ -76,7 +76,7 @@ package javax.websocket;</tt><tt><br>
      </tt><tt>&nbsp; *</tt><tt><br>
      </tt><tt>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp; public void onOpen(Session session,
        EndpointConfig config) {</tt><tt><br>
      </tt><tt>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final RemoteEndpoint remote =
        session.getBasicRemote();</tt><tt><br>
      </tt><font color="#ff0000"><tt>- *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          session.addMessageHandler(new
          MessageHandler.Whole&amp;lt;String&gt;() {</tt></font><tt><br>
      </tt><font color="#009900"><tt>+ *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          session.addMessageHandler(String.class, new
          MessageHandler.Whole&amp;lt;String&gt;() {</tt></font><tt><br>
      </tt><tt>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void onMessage(String text) {</tt><tt><br>
      </tt><tt>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {</tt><tt><br>
      </tt><tt>&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remote.sendString("Got your
        message (" + text + "). Thanks !");</tt><tt><br>
        <br>
      </tt><tt>diff --git
        a/api/client/src/main/java/javax/websocket/Session.java
        b/api/client/src/main/java/javax/websocket/Session.java</tt><tt><br>
      </tt><tt>index 6d6d4fe..0fdab21 100644</tt><tt><br>
      </tt><tt>--- <b>a/api/client/src/main/java/javax/websocket/Session.java</b></tt><tt><br>
      </tt><tt>+++
        b/api/client/src/main/java/javax/websocket/Session.java</tt><tt><br>
      </tt><tt>@@ -86,8 +86,13 @@ public interface Session extends
        Closeable {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * messages. For further details of which message
        handlers handle which of the native websocket</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * message types please see {@link
        MessageHandler.Whole} and {@link MessageHandler.Partial}.</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Adding more than one of any one type will result
        in a runtime exception.</tt><tt><br>
      </tt><font color="#ff0000"><tt>-&nbsp;&nbsp;&nbsp;&nbsp; *</tt><tt><br>
        </tt><tt>-&nbsp;&nbsp;&nbsp;&nbsp; * &lt;p&gt;See {@link Endpoint} for a usage
          example.</tt></font><tt><br>
      </tt><font color="#009900"><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * &lt;p&gt;</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * This method is not safe to use unless you are
          providing an anonymous class derived directly</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * from {@link
          javax.websocket.MessageHandler.Whole} or {@link
          javax.websocket.MessageHandler.Partial}.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * In all other cases (Lambda Expressions, more
          complex inheritance or generic type arrangements),</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * one of the following methods have to be used:</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * {@link #addMessageHandler(Class,
          javax.websocket.MessageHandler.Whole)} or</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * {@link #addMessageHandler(Class,
          javax.websocket.MessageHandler.Partial)}.</tt></font><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @param handler the MessageHandler to be added.</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @throws IllegalStateException if there is already
        a MessageHandler registered for the same native</tt><tt><br>
      </tt><tt>@@ -96,6 +101,40 @@ public interface Session extends
        Closeable {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp; void addMessageHandler(MessageHandler handler)
        throws IllegalStateException;</tt><tt><br>
      </tt><tt>&nbsp;</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp; /**</tt><tt><br>
      </tt><font color="#009900"><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * Register to handle to
          incoming messages in this conversation. A maximum of one
          message handler per</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * native websocket message type (text, binary,
          pong) may be added to each Session. I.e. a maximum</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * of one message handler to handle incoming text
          messages a maximum of one message handler for</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * handling incoming binary messages, and a
          maximum of one for handling incoming pong</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * messages. For further details of which message
          handlers handle which of the native websocket</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * message types please see {@link
          MessageHandler.Whole} and {@link MessageHandler.Partial}.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * Adding more than one of any one type will
          result in a runtime exception.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; *</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @param clazz&nbsp;&nbsp; type of the message processed by
          message handler to be registered.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @param handler whole message handler to be
          added.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @throws IllegalStateException if there is
          already a MessageHandler registered for the same native</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; websocket message
          type as this handler.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @since 1.1</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; */</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp; public &lt;T&gt; void
          addMessageHandler(Class&lt;T&gt; clazz,
          MessageHandler.Whole&lt;T&gt; handler);</tt><tt><br>
        </tt><tt>+</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp; /**</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * Register to handle to incoming messages in this
          conversation. A maximum of one message handler per</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * native websocket message type (text, binary,
          pong) may be added to each Session. I.e. a maximum</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * of one message handler to handle incoming text
          messages a maximum of one message handler for</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * handling incoming binary messages, and a
          maximum of one for handling incoming pong</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * messages. For further details of which message
          handlers handle which of the native websocket</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * message types please see {@link
          MessageHandler.Whole} and {@link MessageHandler.Partial}.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * Adding more than one of any one type will
          result in a runtime exception.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; *</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @param clazz&nbsp;&nbsp; type of the message processed by
          message handler to be registered.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @param handler partial message handler to be
          added.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @throws IllegalStateException if there is
          already a MessageHandler registered for the same native</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; websocket message
          type as this handler.</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; * @since 1.1</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp; */</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp; public &lt;T&gt; void
          addMessageHandler(Class&lt;T&gt; clazz,
          MessageHandler.Partial&lt;T&gt; handler);</tt><tt><br>
        </tt><tt>+</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp; /**</tt></font><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * Return an unmodifiable copy of the set of
        MessageHandlers for this Session.</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @return the set of message handlers.</tt><tt><br>
      </tt><br>
      <b>Spec document:</b><br>
      <br>
      <tt>diff --git a/spec/chapters/applications.tex
        b/spec/chapters/applications.tex</tt><tt><br>
      </tt><tt>index 765fac5..01263bc 100644</tt><tt><br>
      </tt><tt>--- <b>a/spec/chapters/applications.tex</b></tt><tt><br>
      </tt><tt>+++ b/spec/chapters/applications.tex</tt><tt><br>
      </tt><tt>@@ -34,6 +34,8 @@ The API limits the registration of
        \textbf{MessageHandlers} per \textbf{Session}</tt><tt><br>
      </tt><tt>&nbsp;</tt><tt><br>
      </tt><tt>&nbsp;Future versions of the specification may lift this
        restriction.</tt><tt><br>
      </tt><tt>&nbsp;</tt><tt><br>
      </tt><font color="#009900"><tt>+Method
          \textbf{Session.addMessageHandler(MessageHandler)} is not safe
          for use in all circumstances, especially when using Lambda
          Expressions. The API forces implementations to get the
          \textbf{MessageHandler}'s type parameter in runtime, which is
          not always possible.&nbsp; The only case where you can safely use
          this method is when you are directly implementing
          \textbf{MessageHandler.Whole} or
          \textbf{MessageHandler.Partial} as an anonymous class. This
          approach guarantees that generic type information will be
          present in the generated class file and the runtime will be
          able to get it. For any other case (Lambda Expressions
          included), one of following methods have to be used:
          \textbf{Session.addMessageHandler(Class$&lt;$T$&gt;$,&nbsp;
          MessageHandler.Partial$&lt;$T$&gt;$)} or
          \textbf{Session.addMessageHandler(Class$&lt;$T$&gt;$,&nbsp;
          MessageHandler.Whole$&lt;$T$&gt;$)}.</tt><tt><br>
        </tt><tt>+</tt></font><tt><br>
      </tt><tt>&nbsp;\subsection{Sending Messages}</tt><tt><br>
      </tt><tt>&nbsp;</tt><tt><br>
      </tt><tt>&nbsp;The Java WebSocket API models each peer of a session
        with an endpoint as an instance of the \textbf{RemoteEndpoint}
        interface. This interface and its two subtypes
        (\textbf{RemoteEndpoint.Whole} and
        \textbf{RemoteEndpoint.Partial}) contain a variety of methods
        for sending websocket messages from the endpoint to its peer.</tt><tt><br>
      </tt><tt>@@ -47,7 +49,8 @@ public class HelloServer extends
        Endpoint {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp; @Override</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp; public void onOpen(Session session, EndpointConfig
        ec) {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final RemoteEndpoint.Basic remote =
        session.getBasicRemote();</tt><tt><br>
      </tt><font color="#ff0000"><tt>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          session.addMessageHandler(new
          MessageHandler.Whole&lt;String&gt;() {</tt></font><tt><br>
      </tt><font color="#009900"><tt>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          session.addMessageHandler(String.class,</tt><tt><br>
        </tt><tt>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new MessageHandler.Whole&lt;String&gt;() {</tt></font><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void onMessage(String text) {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {</tt><tt><br>
      </tt><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; remote.sendText("Got your message ("
        + text + "). Thanks !");</tt><tt><br>
      </tt><br>
      <br>
      Hope it helps,<br>
      Pavel<br>
      <br>
      On 21/05/14 20:18, Jeanfrancois Arcand wrote:<br>
    </div>
    <blockquote cite="mid:537CEDDC.20106@gmail.com" type="cite">Pavel,
      <br>
      <br>
      can you redo the diff that *only* include relevant change? I think
      it worth for all of us to just see what is really changed.
      <br>
      <br>
      Thanks
      <br>
      <br>
      -- Jeanfrancois
      <br>
      On 2014-05-21, 1:49 PM, Pavel Bucek wrote:
      <br>
      <blockquote type="cite">
        <br>
        Please provide any feedback by COB Friday - 5/30/2014. We plan
        to send this to JCP in the first week of June to start the 30
        day review period for this MR.
        <br>
        <br>
        Thanks,
        <br>
        Pavel
        <br>
        <br>
        On 21/05/14 11:22, Pavel Bucek wrote:
        <br>
        <blockquote type="cite">Hi all,
          <br>
          <br>
          as you might have noticed, I filed blocker bug against
          WEBSOCKET_SPEC project - [1].
          <br>
          <br>
          The main issue is that current Session.addMessageHandler
          method cannot handle message handlers in form of lambda
          expressions, because there is no information about its generic
          type parameter available. We discussed this issue with Brian
          Goetz and he pointed out that current API is wrong not only
          for this case, but also for more complicated generics usages
          and is reliable only for anonymous classes created directly
          from MessageHandler.Whole and MessageHandler.Partial (type
          information is in the generated class file), so the issue
          itself is not limited only to Java SE 8.
          <br>
          <br>
          We think that this issue is important enough to fix it in a
          Maintenance Release as soon as possible, not tied to Java EE 8
          planning or anything else.
          <br>
          <br>
          Proposed solution is to add two additional
          Session.addMessageHandler methods with explicit type
          information, please see [2] for more complete description. I
          also attached updated version of the specification document.
          There is only one addition - last paragraph in chapter 2.1.3
          "Receiving Messages" and the sample code in chapter 2.1.4
          "Sending Messages" was modified to use the newly introduced
          addMessageHandler method with explicit type.
          <br>
          <br>
          Complete change diff can be seen here [3] (but it contains
          lots of noise - spec licence etc; changes.txt should be good
          enough for evaluation).
          <br>
          <br>
          Any feedback would be greatly appreciated!
          <br>
          <br>
          Thanks and regards,
          <br>
          Pavel
          <br>
          <br>
          [1]: <a class="moz-txt-link-freetext" href="https://java.net/jira/browse/WEBSOCKET_SPEC-226">https://java.net/jira/browse/WEBSOCKET_SPEC-226</a>
          <br>
          [2]:
<a class="moz-txt-link-freetext" href="https://github.com/pavelbucek/websocket-spec/blob/WEBSOCKET_SPEC-226/websocket-1.1-changes.txt">https://github.com/pavelbucek/websocket-spec/blob/WEBSOCKET_SPEC-226/websocket-1.1-changes.txt</a><br>
          [3]: <a class="moz-txt-link-freetext" href="https://github.com/pavelbucek/websocket-spec/pull/1/files">https://github.com/pavelbucek/websocket-spec/pull/1/files</a>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
      <br>
    </blockquote>
    <br>
  </body>
</html>

--------------080406080602030601000903--