org.eclipse.jetty.websocket.servlet.WebSocketCreator Maven / Gradle / Ivy
//
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.websocket.servlet;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.extensions.Extension;
/**
* Abstract WebSocket creator interface.
*
* Should you desire filtering of the WebSocket object creation due to criteria such as origin or sub-protocol, then you will be required to implement a custom
* WebSocketCreator implementation.
*
* This has been moved from the WebSocketServlet to a standalone class managed by the WebSocketServerFactory due to need of WebSocket {@link Extension}s that
* require the ability to create new websockets (such as the mux extension)
*/
public interface WebSocketCreator
{
/**
* Create a websocket from the incoming request.
*
* Note: if you have Servlet specific information you need to access from the UpgradeRequest, cast the {@link UpgradeRequest} to
* {@link ServletUpgradeRequest} for this extra information.
*
* Future versions of this interface will change to use the Servlet specific Upgrade Request and Response parameters.
*
* @param req
* the request details
* @param resp
* the response details
* @return a websocket object to use, or null if no websocket should be created from this request.
*/
Object createWebSocket(UpgradeRequest req, UpgradeResponse resp);
}