org.glassfish.tyrus
Class EndpointWrapper

java.lang.Object
  extended by org.glassfish.tyrus.spi.SPIEndpoint
      extended by org.glassfish.tyrus.EndpointWrapper

public class EndpointWrapper
extends SPIEndpoint

Wraps the registered application class. There is one EndpointWrapper for each application class, which handles all the methods.

Author:
Danny Coward (danny.coward at oracle.com), Stepan Kopriva (stepan.kopriva at oracle.com), Martin Matula (martin.matula at oracle.com)

Constructor Summary
EndpointWrapper(Endpoint endpoint, EndpointConfiguration configuration, ClientContainer container, String contextPath)
           
 
Method Summary
 boolean checkHandshake(SPIHandshakeRequest hr)
          This method must be called by the provider during its check for a successful websocket handshake.
 Object decodeCompleteMessage(Object message, Class<?> type, boolean isString)
           
 List<String> getNegotiatedExtensions(List<String> clientExtensions)
          Get the negotiated extensions' names based on the extensions supported by client.
 String getNegotiatedProtocol(List<String> clientProtocols)
          Compute the sub - protocol which will be used.
 void onClose(RemoteEndpoint gs)
          Called by the provider when the web socket connection to the given remote endpoint has just closed.
 void onConnect(RemoteEndpoint gs, String subprotocol, List<String> extensions)
          Called by the provider when the web socket connection is established.
 void onMessage(RemoteEndpoint gs, ByteBuffer messageBytes)
          Called by the provider when the web socket connection has an incoming binary message from the given remote endpoint.
 void onMessage(RemoteEndpoint gs, String messageString)
          Called by the provider when the web socket connection has an incoming text message from the given remote endpoint.
 void onPartialMessage(RemoteEndpoint gs, ByteBuffer partialBytes, boolean last)
          Called by the provider when the web socket connection has an incoming partial binary message from the given remote endpoint.
 void onPartialMessage(RemoteEndpoint gs, String partialString, boolean last)
          Called by the provider when the web socket connection has an incoming partial text message from the given remote endpoint.
 void onPing(RemoteEndpoint gs, ByteBuffer bytes)
          Called by the provider when the web socket connection has an incoming ping message from the given remote endpoint.
 void onPong(RemoteEndpoint gs, ByteBuffer bytes)
          Called by the provider when the web socket connection has an incoming pong message from the given remote endpoint.
 void remove()
          Called by the provider after all connections have been closed to this endpoint, and after the endpoint has been removed from service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EndpointWrapper

public EndpointWrapper(Endpoint endpoint,
                       EndpointConfiguration configuration,
                       ClientContainer container,
                       String contextPath)
Method Detail

checkHandshake

public boolean checkHandshake(SPIHandshakeRequest hr)
Description copied from class: SPIEndpoint
This method must be called by the provider during its check for a successful websocket handshake. The provider must turn down the handshake if the method returns false. If the web socket handshake does complete, as determined by the provider, the endpoint must establish a connection and route all websocket events to this SDK provided component as appropriate.

Specified by:
checkHandshake in class SPIEndpoint
Parameters:
hr - SPIHandshakeRequest that is going to be checked.
Returns:
true if handshake is successful false otherwise.

decodeCompleteMessage

public Object decodeCompleteMessage(Object message,
                                    Class<?> type,
                                    boolean isString)

getNegotiatedExtensions

public List<String> getNegotiatedExtensions(List<String> clientExtensions)
Description copied from class: SPIEndpoint
Get the negotiated extensions' names based on the extensions supported by client.

Specified by:
getNegotiatedExtensions in class SPIEndpoint
Parameters:
clientExtensions - names of the extensions' supported by client.
Returns:
names of extensions supported by both client and class that implements this one.

getNegotiatedProtocol

public String getNegotiatedProtocol(List<String> clientProtocols)
Description copied from class: SPIEndpoint
Compute the sub - protocol which will be used.

Specified by:
getNegotiatedProtocol in class SPIEndpoint
Parameters:
clientProtocols - sub - protocols supported by client.
Returns:
negotiated sub - protocol, null if none found.

remove

public void remove()
Description copied from class: SPIEndpoint
Called by the provider after all connections have been closed to this endpoint, and after the endpoint has been removed from service.

Specified by:
remove in class SPIEndpoint

onConnect

public void onConnect(RemoteEndpoint gs,
                      String subprotocol,
                      List<String> extensions)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection is established.

Specified by:
onConnect in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who has just connected to this web socket endpoint.

onMessage

public void onMessage(RemoteEndpoint gs,
                      ByteBuffer messageBytes)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming binary message from the given remote endpoint.

Specified by:
onMessage in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
messageBytes - the message.

onMessage

public void onMessage(RemoteEndpoint gs,
                      String messageString)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming text message from the given remote endpoint.

Specified by:
onMessage in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
messageString - the String message.

onPartialMessage

public void onPartialMessage(RemoteEndpoint gs,
                             String partialString,
                             boolean last)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming partial text message from the given remote endpoint. Partial text messages are passed in sequential order, one piece at a time. If an implementation does not support streaming, it will need to reconstruct the message here and pass the whole thing along.

Specified by:
onPartialMessage in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
partialString - the String message.
last - to indicate if this is the last partial string in the sequence

onPartialMessage

public void onPartialMessage(RemoteEndpoint gs,
                             ByteBuffer partialBytes,
                             boolean last)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming partial binary message from the given remote endpoint. Partial binary messages are passed in sequential order, one piece at a time. If an implementation does not support streaming, it will need to reconstruct the message here and pass the whole thing along.

Specified by:
onPartialMessage in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
partialBytes - the piece of the binary message.
last - to indicate if this is the last partial byte buffer in the sequence

onPong

public void onPong(RemoteEndpoint gs,
                   ByteBuffer bytes)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming pong message from the given remote endpoint.

Specified by:
onPong in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
bytes - the message.

onPing

public void onPing(RemoteEndpoint gs,
                   ByteBuffer bytes)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection has an incoming ping message from the given remote endpoint.

Specified by:
onPing in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who sent the message.
bytes - the message.

onClose

public void onClose(RemoteEndpoint gs)
Description copied from class: SPIEndpoint
Called by the provider when the web socket connection to the given remote endpoint has just closed.

Specified by:
onClose in class SPIEndpoint
Parameters:
gs - SPIRemoteEndpoint who has just closed the connection.


Copyright © 2012. All Rights Reserved.