String cometdURLMapping = (String)getOption(COMETD_URL_MAPPING);
if (cometdURLMapping == null)
throw new IllegalArgumentException("Missing '" + COMETD_URL_MAPPING + "' parameter");
ServerContainer container = (ServerContainer)context.getAttribute(ServerContainer.class.getName());
if (container == null)
throw new IllegalArgumentException("Missing WebSocket ServerContainer");
// JSR 356 does not support a input buffer size option
int maxMessageSize = getOption(MAX_MESSAGE_SIZE_OPTION, container.getDefaultMaxTextMessageBufferSize());
container.setDefaultMaxTextMessageBufferSize(maxMessageSize);
long idleTimeout = getOption(IDLE_TIMEOUT_OPTION, container.getDefaultMaxSessionIdleTimeout());
container.setDefaultMaxSessionIdleTimeout(idleTimeout);
String protocol = getProtocol();
List<String> protocols = protocol == null ? null : Collections.singletonList(protocol);
for (String mapping : normalizeURLMapping(cometdURLMapping))
{
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(WebSocketScheduler.class, mapping)
.subprotocols(protocols)
.configurator(new Configurator(context))
.build();
try
{
container.addEndpoint(config);
}
catch (DeploymentException x)
{
throw new RuntimeException(x);
}