1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.websocket.servlet; 20 21 import java.io.IOException; 22 23 import javax.servlet.http.HttpServletRequest; 24 import javax.servlet.http.HttpServletResponse; 25 26 import org.eclipse.jetty.websocket.api.WebSocketPolicy; 27 import org.eclipse.jetty.websocket.api.annotations.WebSocket; 28 import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory; 29 30 /** 31 * Basic WebSocketServletFactory for working with Jetty-based WebSocketServlets 32 */ 33 public interface WebSocketServletFactory 34 { 35 public boolean acceptWebSocket(HttpServletRequest request, HttpServletResponse response) throws IOException; 36 37 public void cleanup(); 38 39 public WebSocketServletFactory createFactory(WebSocketPolicy policy); 40 41 public abstract WebSocketCreator getCreator(); 42 43 public abstract ExtensionFactory getExtensionFactory(); 44 45 /** 46 * Get the base policy in use for WebSockets. 47 * <p> 48 * Note: individual WebSocket implementations can override some of the values in here by using the {@link WebSocket @WebSocket} annotation. 49 * 50 * @return the base policy 51 */ 52 public WebSocketPolicy getPolicy(); 53 54 public void init() throws Exception; 55 56 public boolean isUpgradeRequest(HttpServletRequest request, HttpServletResponse response); 57 58 /** 59 * Register a websocket class pojo with the default {@link WebSocketCreator}. 60 * <p> 61 * Note: only required if using the default {@link WebSocketCreator} provided by this factory. 62 * 63 * @param websocketPojo 64 * the class to instantiate for each incoming websocket upgrade request. 65 */ 66 public void register(Class<?> websocketPojo); 67 68 public abstract void setCreator(WebSocketCreator creator); 69 }