Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.websockets

public Class WebSocketEngine

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .HashMap, .List, java.util.logging.Level, .Logger, org.glassfish.grizzly.CloseType, .Closeable, .Connection, .GenericCloseListener, org.glassfish.grizzly.filterchain.FilterChainContext, org.glassfish.grizzly.http.HttpContent, .HttpRequestPacket, .HttpResponsePacket, org.glassfish.grizzly.http.server.util.Mapper, org.glassfish.grizzly.http.util.HttpStatus, .MimeHeaders

WebSockets engine implementation (singleton), which handles WebSocketApplications registration, responsible for client and server handshake validation.
Author
Alexey Stashok
See Also
WebSocket, WebSocketApplication

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final HashMap<WebSocketApplication, String>
private final List<WebSocketApplication>
private final HashMap<String, List<WebSocketApplication>>
public static final int
public static final Version
private static final String[]
private static final WebSocketEngine
private final HashMap<String, WebSocketApplication>
pack-priv static final Logger
private Mapper
private final HttpResponsePacket.Builder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public WebSocketApplication
private WebSocketEngine.WebSocketApplicationReg
getApplication(final HttpRequestPacket request, final Mapper glassfishMapper)

private static String
public static WebSocketEngine
private void
public static ProtocolHandler
public synchronized void
register(final String
the context path (per servlet rules)
contextPath
,
final String
url pattern (per servlet rules)
urlPattern
,
final WebSocketApplication
the WebSocket application.
app
)

Register a WebSocketApplication to a specific context path and url pattern.

public synchronized void
public synchronized void
public synchronized void
unregisterAll()

Un-registers all WebSocketApplication instances with the WebSocketEngine.

public boolean
upgrade(FilterChainContext ctx, HttpContent requestContent)

public boolean
upgrade(FilterChainContext ctx, HttpContent requestContent, Mapper mapper)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationMapback to summary
private final HashMap<WebSocketApplication, String> applicationMap
applicationsback to summary
private final List<WebSocketApplication> applications
contextApplicationsback to summary
private final HashMap<String, List<WebSocketApplication>> contextApplications
DEFAULT_TIMEOUTback to summary
public static final int DEFAULT_TIMEOUT
DEFAULT_VERSIONback to summary
public static final Version DEFAULT_VERSION
EMPTY_STRING_ARRAYback to summary
private static final String[] EMPTY_STRING_ARRAY
engineback to summary
private static final WebSocketEngine engine
fullPathToApplicationback to summary
private final HashMap<String, WebSocketApplication> fullPathToApplication
loggerback to summary
pack-priv static final Logger logger
mapperback to summary
private Mapper mapper
unsupportedVersionsResponseBuilderback to summary
private final HttpResponsePacket.Builder unsupportedVersionsResponseBuilder

Constructor Detail

WebSocketEngineback to summary
private WebSocketEngine()

Method Detail

getApplicationback to summary
public WebSocketApplication getApplication(HttpRequestPacket request)
getApplicationback to summary
private WebSocketEngine.WebSocketApplicationReg getApplication(final HttpRequestPacket request, final Mapper glassfishMapper)
getContextPathback to summary
private static String getContextPath(String mapping)
getEngineback to summary
public static WebSocketEngine getEngine()
handleUnsupportedVersionback to summary
private void handleUnsupportedVersion(final FilterChainContext ctx, final HttpRequestPacket request) throws IOException
loadHandlerback to summary
public static ProtocolHandler loadHandler(MimeHeaders headers)
registerback to summary
public synchronized void register(final String contextPath, final String urlPattern, final WebSocketApplication app)

Register a WebSocketApplication to a specific context path and url pattern. If you wish to associate this application with the root context, use an empty string for the contextPath argument.

Examples:
// WS application will be invoked:
// ws://localhost:8080/echo
// WS application will not be invoked:
// ws://localhost:8080/foo/echo
// ws://localhost:8080/echo/some/path
register("", "/echo", webSocketApplication);

// WS application will be invoked:
// ws://localhost:8080/echo
// ws://localhost:8080/echo/some/path
// WS application will not be invoked:
// ws://localhost:8080/foo/echo
register("", "/echo/*", webSocketApplication);

// WS application will be invoked:
// ws://localhost:8080/context/echo

// WS application will not be invoked:
// ws://localhost:8080/echo
// ws://localhost:8080/context/some/path
register("/context", "/echo", webSocketApplication);
Parameters
contextPath:String

the context path (per servlet rules)

urlPattern:String

url pattern (per servlet rules)

app:WebSocketApplication

the WebSocket application.

registerback to summary
public synchronized void register(WebSocketApplication app)
Annotations
@Deprecated
unregisterback to summary
public synchronized void unregister(WebSocketApplication app)
unregisterAllback to summary
public synchronized void unregisterAll()

Un-registers all WebSocketApplication instances with the WebSocketEngine.

upgradeback to summary
public boolean upgrade(FilterChainContext ctx, HttpContent requestContent) throws IOException
upgradeback to summary
public boolean upgrade(FilterChainContext ctx, HttpContent requestContent, Mapper mapper) throws IOException
org.glassfish.grizzly.websockets back to summary

private Class WebSocketEngine.WebSocketApplicationReg

extends Object
Class Inheritance
  • java.lang.Object
  • org.glassfish.grizzly.websockets.WebSocketEngine.WebSocketApplicationReg

Field Summary

Modifier and TypeField and Description
private final WebSocketApplication
private final WebSocketMappingData

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

appback to summary
private final WebSocketApplication app
mappingDataback to summary
private final WebSocketMappingData mappingData

Constructor Detail

WebSocketApplicationRegback to summary
public WebSocketApplicationReg(final WebSocketApplication app, final WebSocketMappingData mappingData)