RequestContext requestContext = createRequestContext(servletRequest, path, headers); TyrusUpgradeResponse upgradeResponse = new TyrusUpgradeResponse(); UpgradeInfo upgradeInfo = engine.upgrade(requestContext, upgradeResponse); success = SUCCESS.equals(upgradeInfo.getStatus()); if (success) {
@Override public UpgradeInfo upgrade(final UpgradeRequest request, final UpgradeResponse response) { DebugContext debugContext = createDebugContext(request); endpointWrapper = getEndpointWrapper(request, debugContext); } catch (HandshakeException e) { return handleHandshakeException(e, response); final ProtocolHandler protocolHandler = loadHandler(request); if (protocolHandler == null) { handleUnsupportedVersion(request, response); debugContext.appendTraceMessage(LOGGER, Level.FINE, DebugContext.Type.MESSAGE_IN, "Upgrade request contains unsupported version of Websocket protocol"); protocolHandler.handshake(endpointWrapper, request, response, extensionContext); } catch (HandshakeException e) { return handleHandshakeException(e, response); logExtensionsAndSubprotocol(protocolHandler, debugContext);
final WebSocketEngine.UpgradeInfo upgradeInfo = engine.upgrade(requestContext, tyrusUpgradeResponse); switch (upgradeInfo.getStatus()) { case HANDSHAKE_FAILED: getWsadlJaxbContext().createMarshaller().marshal(engine.getWsadlApplication(), response .getWriter()); } catch (JAXBException e) {
private final WebSocketEngine webSocketEngine = TyrusWebSocketEngine.builder(this).build();
@Override public void service(Request request, Response response) throws Exception { if (request.getMethod().equals(Method.GET) && request.getRequestURI().endsWith("application.wsadl")) { getWsadlJaxbContext().createMarshaller().marshal(engine.getWsadlApplication(), response.getWriter()); response.setStatus(200); response.setContentType(ContentType.newContentType("application/wsadl+xml")); return; } if (staticHttpHandler != null) { staticHttpHandler.service(request, response); } else { response.sendError(404); } } }
/** * Registers the specified {@link TyrusEndpointWrapper} with the <code>WebSocketEngine</code>. * * @param endpointWrapper the {@link TyrusEndpointWrapper} to register. * @throws DeploymentException when added endpoint responds to same path as some already registered endpoint. */ private void register(TyrusEndpointWrapper endpointWrapper) throws DeploymentException { checkPath(endpointWrapper); LOGGER.log(Level.FINER, "Registered endpoint: " + endpointWrapper); endpointWrappers.add(endpointWrapper); }
/** * Create new {@link org.glassfish.tyrus.core.TyrusWebSocketEngine} instance with current set of parameters. * * @return new {@link org.glassfish.tyrus.core.TyrusWebSocketEngine} instance. */ public TyrusWebSocketEngine build() { if (maxSessionsPerApp != null && maxSessionsPerApp <= 0) { LOGGER.log(Level.CONFIG, "Invalid configuration value " + MAX_SESSIONS_PER_APP + " (" + maxSessionsPerApp + "), expected value greater than 0."); maxSessionsPerApp = null; } if (maxSessionsPerRemoteAddr != null && maxSessionsPerRemoteAddr <= 0) { LOGGER.log(Level.CONFIG, "Invalid configuration value " + MAX_SESSIONS_PER_REMOTE_ADDR + " (" + maxSessionsPerRemoteAddr + "), expected value greater than 0."); maxSessionsPerRemoteAddr = null; } if (maxSessionsPerApp != null && maxSessionsPerRemoteAddr != null && maxSessionsPerApp < maxSessionsPerRemoteAddr) { LOGGER.log(Level.FINE, String.format("Invalid configuration - value %s (%d) cannot be greater then %s (%d).", MAX_SESSIONS_PER_REMOTE_ADDR, maxSessionsPerRemoteAddr, MAX_SESSIONS_PER_APP, maxSessionsPerApp)); } return new TyrusWebSocketEngine(webSocketContainer, incomingBufferSize, clusterContext, applicationEventListener, maxSessionsPerApp, maxSessionsPerRemoteAddr, tracingType, tracingThreshold, parallelBroadcastEnabled); }
@Override public void destroy() { serverContainer.stop(); engine.getApplicationEventListener().onApplicationDestroyed(); } }
@Override public UpgradeInfo upgrade(final UpgradeRequest request, final UpgradeResponse response) { DebugContext debugContext = createDebugContext(request); endpointWrapper = getEndpointWrapper(request, debugContext); } catch (HandshakeException e) { return handleHandshakeException(e, response); final ProtocolHandler protocolHandler = loadHandler(request); if (protocolHandler == null) { handleUnsupportedVersion(request, response); debugContext.appendTraceMessage(LOGGER, Level.FINE, DebugContext.Type.MESSAGE_IN, "Upgrade request contains unsupported version of Websocket protocol"); protocolHandler.handshake(endpointWrapper, request, response, extensionContext); } catch (HandshakeException e) { return handleHandshakeException(e, response); logExtensionsAndSubprotocol(protocolHandler, debugContext);
TyrusWebSocketEngine.builder(this) .applicationEventListener(applicationEventListener) .incomingBufferSize(incomingBufferSize)
/** * Registers the specified {@link TyrusEndpointWrapper} with the <code>WebSocketEngine</code>. * * @param endpointWrapper the {@link TyrusEndpointWrapper} to register. * @throws DeploymentException when added endpoint responds to same path as some already registered endpoint. */ private void register(TyrusEndpointWrapper endpointWrapper) throws DeploymentException { checkPath(endpointWrapper); LOGGER.log(Level.FINER, "Registered endpoint: " + endpointWrapper); endpointWrappers.add(endpointWrapper); }
/** * Create new {@link org.glassfish.tyrus.core.TyrusWebSocketEngine} instance with current set of parameters. * * @return new {@link org.glassfish.tyrus.core.TyrusWebSocketEngine} instance. */ public TyrusWebSocketEngine build() { if (maxSessionsPerApp != null && maxSessionsPerApp <= 0) { LOGGER.log(Level.CONFIG, "Invalid configuration value " + MAX_SESSIONS_PER_APP + " (" + maxSessionsPerApp + "), expected value greater than 0."); maxSessionsPerApp = null; } if (maxSessionsPerRemoteAddr != null && maxSessionsPerRemoteAddr <= 0) { LOGGER.log(Level.CONFIG, "Invalid configuration value " + MAX_SESSIONS_PER_REMOTE_ADDR + " (" + maxSessionsPerRemoteAddr + "), expected value greater than 0."); maxSessionsPerRemoteAddr = null; } if (maxSessionsPerApp != null && maxSessionsPerRemoteAddr != null && maxSessionsPerApp < maxSessionsPerRemoteAddr) { LOGGER.log(Level.FINE, String.format("Invalid configuration - value %s (%d) cannot be greater then %s (%d).", MAX_SESSIONS_PER_REMOTE_ADDR, maxSessionsPerRemoteAddr, MAX_SESSIONS_PER_APP, maxSessionsPerApp)); } return new TyrusWebSocketEngine(webSocketContainer, incomingBufferSize, clusterContext, applicationEventListener, maxSessionsPerApp, maxSessionsPerRemoteAddr, tracingType, tracingThreshold, parallelBroadcastEnabled); }
RequestContext requestContext = createRequestContext(servletRequest, path, headers); TyrusUpgradeResponse upgradeResponse = new TyrusUpgradeResponse(); UpgradeInfo upgradeInfo = engine.upgrade(requestContext, upgradeResponse); success = SUCCESS.equals(upgradeInfo.getStatus()); if (success) {
TyrusWebSocketEngine.builder(this) .incomingBufferSize(incomingBufferSize) .clusterContext(clusterContext)
RequestContext requestContext = createRequestContext(servletRequest, path, headers); TyrusUpgradeResponse upgradeResponse = new TyrusUpgradeResponse(); UpgradeInfo upgradeInfo = engine.upgrade(requestContext, upgradeResponse); success = SUCCESS.equals(upgradeInfo.getStatus()); if (success) {