javax.net.websocket
Class DefaultServerConfiguration

java.lang.Object
  extended by javax.net.websocket.DefaultServerConfiguration
All Implemented Interfaces:
EndpointConfiguration, ServerConfiguration

public class DefaultServerConfiguration
extends Object
implements ServerConfiguration

The DefaultServerConfiguration is a concrete class that embodies all the configuration parameters for an endpoint that is to be published as a server endpoint. Developers may subclass this class in order to override the configuration behavior.

Author:
dannycoward

Constructor Summary
protected DefaultServerConfiguration()
          For subclass implementations.
  DefaultServerConfiguration(URI uri)
          Creates a server configuration with the given URI.
 
Method Summary
 boolean checkOrigin(String originHeaderValue)
          Makes a check of the validity of the Origin header sent along with the opening handshake.
 List<Decoder> getDecoders()
          Return the Decoder implementations configured.
 List<Encoder> getEncoders()
          Return the Decoder implementations configured.
 List<Extension> getNegotiatedExtensions(List<Extension> requestedExtensions)
          Provides a simple algorithm to return the list of extensions this server will use for the web socket session: the configuration returns a list containing all of the requested extensions passed to this method that it supports, using the order in the requested extensions.
 String getNegotiatedSubprotocol(List<String> requestedSubprotocols)
          Return the subprotocol this server endpoint has chosen from the requested list supplied by a client who wishes to connect, or none if there wasn't one this server endpoint liked.
 boolean matchesURI(URI uri)
          A URI is a match if and only if it is an exact match (.equals()) the URI used to create this configuration.
 void modifyHandshake(HandshakeRequest request, HandshakeResponse response)
          The default server configuration does not make any changes to the response.
 DefaultServerConfiguration setDecoders(List<Decoder> decoders)
          Sets all the decoders that this configuration will support.
 DefaultServerConfiguration setEncoders(List<Encoder> encoders)
           
 DefaultServerConfiguration setExtensions(List<Extension> extensions)
          Sets all the extensions that this configuration will support.
 DefaultServerConfiguration setSubprotocols(List<String> subprotocols)
          Sets all the subprotocols that this configuration will support.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServerConfiguration

protected DefaultServerConfiguration()
For subclass implementations.


DefaultServerConfiguration

public DefaultServerConfiguration(URI uri)
Creates a server configuration with the given URI.

Method Detail

setEncoders

public DefaultServerConfiguration setEncoders(List<Encoder> encoders)

setDecoders

public DefaultServerConfiguration setDecoders(List<Decoder> decoders)
Sets all the decoders that this configuration will support.


setSubprotocols

public DefaultServerConfiguration setSubprotocols(List<String> subprotocols)
Sets all the subprotocols that this configuration will support.


setExtensions

public DefaultServerConfiguration setExtensions(List<Extension> extensions)
Sets all the extensions that this configuration will support.


getEncoders

public List<Encoder> getEncoders()
Return the Decoder implementations configured. These will be used by the container to decode incoming messages into the expected custom objects on MessageListener.onMessage() callbacks.

Specified by:
getEncoders in interface EndpointConfiguration

getDecoders

public List<Decoder> getDecoders()
Return the Decoder implementations configured. These will be used by the container to decode incoming messages into the expected custom objects on MessageListener.onMessage() callbacks.

Specified by:
getDecoders in interface EndpointConfiguration

getNegotiatedSubprotocol

public String getNegotiatedSubprotocol(List<String> requestedSubprotocols)
Return the subprotocol this server endpoint has chosen from the requested list supplied by a client who wishes to connect, or none if there wasn't one this server endpoint liked. See Sending the Server's Opening Handshake

Specified by:
getNegotiatedSubprotocol in interface ServerConfiguration
Parameters:
clientSubprotocolList -
Returns:

getNegotiatedExtensions

public List<Extension> getNegotiatedExtensions(List<Extension> requestedExtensions)
Provides a simple algorithm to return the list of extensions this server will use for the web socket session: the configuration returns a list containing all of the requested extensions passed to this method that it supports, using the order in the requested extensions. Subclasses may provide custom algorithms based on other factors.

Specified by:
getNegotiatedExtensions in interface ServerConfiguration
Parameters:
requestedExtensions -
Returns:

checkOrigin

public boolean checkOrigin(String originHeaderValue)
Makes a check of the validity of the Origin header sent along with the opening handshake.

Specified by:
checkOrigin in interface ServerConfiguration
Parameters:
originHeaderValue -
Returns:

matchesURI

public boolean matchesURI(URI uri)
A URI is a match if and only if it is an exact match (.equals()) the URI used to create this configuration. Subclasses may override this method to provide different matching policies.

Specified by:
matchesURI in interface ServerConfiguration
Parameters:
uri -
Returns:

modifyHandshake

public void modifyHandshake(HandshakeRequest request,
                            HandshakeResponse response)
The default server configuration does not make any changes to the response. Subclasses may override this method in order to inspect the Http request headers of the openinghandshake, for example to track cookies sent by the client. Additionally subclasses may choose to override this method to modify the outgoing handshake response. the outgoing handshake response

Specified by:
modifyHandshake in interface ServerConfiguration
Parameters:
request -
response -


Copyright © 2012. All Rights Reserved.