org.eclipse.jetty.websocket
类 WebSocketServlet

java.lang.Object
  继承者 javax.servlet.GenericServlet
      继承者 javax.servlet.http.HttpServlet
          继承者 org.eclipse.jetty.websocket.WebSocketServlet
所有已实现的接口:
Serializable, Servlet, ServletConfig, WebSocketFactory.Acceptor

public abstract class WebSocketServlet
extends HttpServlet
implements WebSocketFactory.Acceptor

Servlet to upgrade connections to WebSocket

The request must have the correct upgrade headers, else it is handled as a normal servlet request.

The initParameter "bufferSize" can be used to set the buffer size, which is also the max frame byte size (default 8192).

The initParameter "maxIdleTime" can be used to set the time in ms that a websocket may be idle before closing.

The initParameter "maxTextMessagesSize" can be used to set the size in characters that a websocket may be accept before closing.

The initParameter "maxBinaryMessagesSize" can be used to set the size in bytes that a websocket may be accept before closing.

The initParameter "minVersion" can be used to set the minimum protocol version accepted. Default is the RFC6455 version (13)

另请参见:
序列化表格

构造方法摘要
WebSocketServlet()
           
 
方法摘要
 boolean checkOrigin(HttpServletRequest request, String origin)
          Checks the origin of an incoming WebSocket handshake request.
 void destroy()
          Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
 void init()
          A convenience method which can be overridden so that there's no need to call super.init(config).
protected  void service(HttpServletRequest request, HttpServletResponse response)
          Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class.
 
从类 javax.servlet.http.HttpServlet 继承的方法
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
从类 javax.servlet.GenericServlet 继承的方法
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 org.eclipse.jetty.websocket.WebSocketFactory.Acceptor 继承的方法
doWebSocketConnect
 

构造方法详细信息

WebSocketServlet

public WebSocketServlet()
方法详细信息

init

public void init()
          throws ServletException
从类 GenericServlet 复制的描述
A convenience method which can be overridden so that there's no need to call super.init(config).

Instead of overriding GenericServlet.init(ServletConfig), simply override this method and it will be called by GenericServlet.init(ServletConfig config). The ServletConfig object can still be retrieved via GenericServlet.getServletConfig().

覆盖:
GenericServlet 中的 init
抛出:
ServletException - if an exception occurs that interrupts the servlet's normal operation
另请参见:
GenericServlet.init()

service

protected void service(HttpServletRequest request,
                       HttpServletResponse response)
                throws ServletException,
                       IOException
从类 HttpServlet 复制的描述
Receives standard HTTP requests from the public service method and dispatches them to the doXXX methods defined in this class. This method is an HTTP-specific version of the Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) method. There's no need to override this method.

覆盖:
HttpServlet 中的 service
参数:
request - the HttpServletRequest object that contains the request the client made of the servlet
response - the HttpServletResponse object that contains the response the servlet returns to the client
抛出:
ServletException - if the HTTP request cannot be handled
IOException - if an input or output error occurs while the servlet is handling the HTTP request
另请参见:
HttpServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

checkOrigin

public boolean checkOrigin(HttpServletRequest request,
                           String origin)
从接口 WebSocketFactory.Acceptor 复制的描述

Checks the origin of an incoming WebSocket handshake request.

指定者:
接口 WebSocketFactory.Acceptor 中的 checkOrigin
参数:
request - the incoming HTTP upgrade request
origin - the origin URI
返回:
boolean to indicate that the origin is acceptable.

destroy

public void destroy()
从类 GenericServlet 复制的描述
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. See Servlet.destroy().

指定者:
接口 Servlet 中的 destroy
覆盖:
GenericServlet 中的 destroy


Copyright © 2013. All Rights Reserved.