Java Code Examples for org.eclipse.jetty.websocket.servlet.WebSocketServletFactory#setCreator()
The following examples show how to use
org.eclipse.jetty.websocket.servlet.WebSocketServletFactory#setCreator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerRpcProvider.java From incubator-retired-wave with Apache License 2.0 | 6 votes |
@SuppressWarnings("cast") @Override public void configure(WebSocketServletFactory factory) { if (websocketMaxIdleTime == 0) { // Jetty does not allow to set infinite timeout. factory.getPolicy().setIdleTimeout(Integer.MAX_VALUE); } else { factory.getPolicy().setIdleTimeout(websocketMaxIdleTime); } factory.getPolicy().setMaxTextMessageSize(websocketMaxMessageSize * 1024 * 1024); factory.setCreator(new WebSocketCreator() { @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { ParticipantId loggedInUser = provider.sessionManager.getLoggedInUser(req.getSession()); return new WebSocketConnection(loggedInUser, provider).getWebSocketServerChannel(); } }); }
Example 2
Source File: GatewayWebsocketHandler.java From knox with Apache License 2.0 | 6 votes |
@Override public void configure(final WebSocketServletFactory factory) { factory.setCreator(this); factory.getPolicy() .setMaxTextMessageSize(config.getWebsocketMaxTextMessageSize()); factory.getPolicy() .setMaxBinaryMessageSize(config.getWebsocketMaxBinaryMessageSize()); factory.getPolicy().setMaxBinaryMessageBufferSize( config.getWebsocketMaxBinaryMessageBufferSize()); factory.getPolicy().setMaxTextMessageBufferSize( config.getWebsocketMaxTextMessageBufferSize()); factory.getPolicy() .setInputBufferSize(config.getWebsocketInputBufferSize()); factory.getPolicy() .setAsyncWriteTimeout(config.getWebsocketAsyncWriteTimeout()); factory.getPolicy().setIdleTimeout(config.getWebsocketIdleTimeout()); }
Example 3
Source File: WebSocketProducerServlet.java From pulsar with Apache License 2.0 | 5 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setMaxTextMessageSize(service.getConfig().getWebSocketMaxTextFrameSize()); if (service.getConfig().getWebSocketSessionIdleTimeoutMillis() > 0) { factory.getPolicy().setIdleTimeout(service.getConfig().getWebSocketSessionIdleTimeoutMillis()); } factory.setCreator((request, response) -> new ProducerHandler(service, request.getHttpServletRequest(), response)); }
Example 4
Source File: OpenfireWebSocketServlet.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void configure(WebSocketServletFactory factory) { if (XmppWebSocket.isCompressionEnabled()) { factory.getExtensionFactory().register("permessage-deflate", PerMessageDeflateExtension.class); } final int messageSize = JiveGlobals.getIntProperty("xmpp.parser.buffer.size", 1048576); factory.getPolicy().setMaxTextMessageBufferSize(messageSize * 5); factory.getPolicy().setMaxTextMessageSize(messageSize); factory.setCreator(new WebSocketCreator() { @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { try { for (String subprotocol : req.getSubProtocols()) { if ("xmpp".equals(subprotocol)) { resp.setAcceptedSubProtocol(subprotocol); return new XmppWebSocket(); } } } catch (Exception e) { Log.warn(MessageFormat.format("Unable to load websocket factory: {0} ({1})", e.getClass().getName(), e.getMessage())); } Log.warn("Failed to create websocket for {}:{} make a request at {}", req.getRemoteAddress(), req.getRemotePort(), req.getRequestPath() ); return null; } }); }
Example 5
Source File: WebSocketTest.java From htmlunit with Apache License 2.0 | 5 votes |
@Override public void configure(final WebSocketServletFactory factory) { factory.register(CookiesWebSocket.class); factory.setCreator(new WebSocketCreator() { @Override public Object createWebSocket(final ServletUpgradeRequest servletUpgradeRequest, final ServletUpgradeResponse servletUpgradeResponse) { return new CookiesWebSocket(); } }); }
Example 6
Source File: StreamingWebSocketServlet.java From buck with Apache License 2.0 | 5 votes |
@Override public void configure(WebSocketServletFactory factory) { // Most implementations of this method simply invoke factory.register(DispatchSocket.class); // however, that requires DispatchSocket to have a no-arg constructor. That does not work for // us because we would like all WebSockets created by this factory to have a reference to this // parent class. This is why we override the default WebSocketCreator for the factory. WebSocketCreator wrapperCreator = (req, resp) -> new MyWebSocket(); factory.setCreator(wrapperCreator); }
Example 7
Source File: IngressStreamUpdateHandler.java From warp10-platform with Apache License 2.0 | 5 votes |
@Override public void configure(final WebSocketServletFactory factory) { final IngressStreamUpdateHandler self = this; final WebSocketCreator oldcreator = factory.getCreator(); WebSocketCreator creator = new WebSocketCreator() { @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { StandaloneStreamUpdateWebSocket ws = (StandaloneStreamUpdateWebSocket) oldcreator.createWebSocket(req, resp); ws.setHandler(self); return ws; } }; factory.setCreator(creator); // // Update the maxMessageSize if need be // if (this.ingress.properties.containsKey(Configuration.INGRESS_WEBSOCKET_MAXMESSAGESIZE)) { factory.getPolicy().setMaxTextMessageSize((int) Long.parseLong(this.ingress.properties.getProperty(Configuration.INGRESS_WEBSOCKET_MAXMESSAGESIZE))); factory.getPolicy().setMaxBinaryMessageSize((int) Long.parseLong(this.ingress.properties.getProperty(Configuration.INGRESS_WEBSOCKET_MAXMESSAGESIZE))); } super.configure(factory); }
Example 8
Source File: ScriptExecutionReportingWebSocketServlet.java From gp2srv with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.setCreator(new WebSocketCreator() { public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { return new ScriptExecutionReportingWebSocket(logger); } }); }
Example 9
Source File: StandalonePlasmaHandler.java From warp10-platform with Apache License 2.0 | 5 votes |
@Override public void configure(final WebSocketServletFactory factory) { final StandalonePlasmaHandler self = this; final WebSocketCreator oldcreator = factory.getCreator(); WebSocketCreator creator = new WebSocketCreator() { @Override public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) { StandalonePlasmaWebSocket ws = (StandalonePlasmaWebSocket) oldcreator.createWebSocket(req, resp); ws.setHandler(self); return ws; } }; factory.setCreator(creator); // // Update the maxMessageSize if need be // if (this.properties.containsKey(Configuration.PLASMA_FRONTEND_WEBSOCKET_MAXMESSAGESIZE)) { factory.getPolicy().setMaxTextMessageSize((int) Long.parseLong(this.properties.getProperty(Configuration.PLASMA_FRONTEND_WEBSOCKET_MAXMESSAGESIZE))); factory.getPolicy().setMaxBinaryMessageSize((int) Long.parseLong(this.properties.getProperty(Configuration.PLASMA_FRONTEND_WEBSOCKET_MAXMESSAGESIZE))); } super.configure(factory); }
Example 10
Source File: SocketServlet.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(SOCKET_TIMEOUT_MS); factory.setCreator(new Creator()); }
Example 11
Source File: WebSocketChatServlet.java From homework_tester with MIT License | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(LOGOUT_TIME); factory.setCreator((req, resp) -> new ChatWebSocket(chatService)); }
Example 12
Source File: WebSocketReceiverServlet.java From datacollector with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory webSocketServletFactory) { webSocketServletFactory.getPolicy().setIdleTimeout(receiver.getIdleTimeout()); webSocketServletFactory.setCreator(this); }
Example 13
Source File: DmWebSocketServlet.java From roboconf-platform with Apache License 2.0 | 4 votes |
@Override public void configure( WebSocketServletFactory factory ) { factory.setCreator( new DmWebSocketCreator( this.httpClientFactory )); }
Example 14
Source File: WsServlet.java From java-11-examples with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.setCreator(new WebSocketCreatorImpl()); }
Example 15
Source File: WsServlet.java From java-11-examples with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.setCreator(new WebSocketCreatorImpl(requestRouter)); }
Example 16
Source File: SDCWebSocketServlet.java From datacollector with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(7200000); factory.setCreator(this); }
Example 17
Source File: WebSocketServerExample.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory webSocketServletFactory) { webSocketServletFactory.setCreator(this); }
Example 18
Source File: JettyWebSocketServer.java From localization_nifi with Apache License 2.0 | 4 votes |
@Override public void configure(WebSocketServletFactory webSocketServletFactory) { webSocketServletFactory.setCreator(this); }
Example 19
Source File: WebSocketGameServlet.java From tp_java_2015_02 with MIT License | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(IDLE_TIME); factory.setCreator(new GameWebSocketCreator(authService, gameMechanics, webSocketService)); }
Example 20
Source File: WebSocketChatServlet.java From stepic_java_webserver with MIT License | 4 votes |
@Override public void configure(WebSocketServletFactory factory) { factory.getPolicy().setIdleTimeout(LOGOUT_TIME); factory.setCreator((req, resp) -> new ChatWebSocket(chatService)); }