org.apache.tomcat.websocket.server.Constants Java Examples
The following examples show how to use
org.apache.tomcat.websocket.server.Constants.
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: TestWsWebSocketContainer.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(ServerEndpointConfig.Builder.create( ConstantTxEndpoint.class, PATH).build()); if (TestWsWebSocketContainer.timeoutOnContainer) { sc.setAsyncSendTimeout(TIMEOUT_MS); } } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #2
Source File: TestWsWebSocketContainer.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(ServerEndpointConfig.Builder.create( ConstantTxEndpoint.class, PATH).build()); if (TestWsWebSocketContainer.timeoutOnContainer) { sc.setAsyncSendTimeout(TIMEOUT_MS); } } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #3
Source File: TestWsWebSocketContainerGetOpenSessions.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(PojoEndpointA.class); sc.addEndpoint(PojoEndpointB.class); sc.addEndpoint(ServerEndpointConfig.Builder.create( ServerEndpointA.class, "/progA").build()); sc.addEndpoint(ServerEndpointConfig.Builder.create( ServerEndpointB.class, "/progB").build()); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #4
Source File: TesterEchoServer.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(Async.class); sc.addEndpoint(Basic.class); sc.addEndpoint(BasicLimitLow.class); sc.addEndpoint(BasicLimitHigh.class); sc.addEndpoint(RootEcho.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #5
Source File: TesterEchoServer.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(Async.class); sc.addEndpoint(Basic.class); sc.addEndpoint(BasicLimitLow.class); sc.addEndpoint(BasicLimitHigh.class); sc.addEndpoint(WriterError.class); sc.addEndpoint(RootEcho.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #6
Source File: TestWsWebSocketContainer.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(ServerEndpointConfig.Builder.create( ConstantTxEndpoint.class, PATH).build()); if (TestWsWebSocketContainer.timoutOnContainer) { sc.setAsyncSendTimeout(TIMEOUT_MS); } } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #7
Source File: TesterEchoServer.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(Async.class); sc.addEndpoint(Basic.class); sc.addEndpoint(BasicLimitLow.class); sc.addEndpoint(BasicLimitHigh.class); sc.addEndpoint(RootEcho.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #8
Source File: TestWsWebSocketContainer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(BlockingPojo.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #9
Source File: TesterFirehoseServer.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(Endpoint.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #10
Source File: TestWsWebSocketContainer.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { // Reset blocking state BlockingPojo.resetBlock(); sc.addEndpoint(BlockingPojo.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #11
Source File: TesterUtil.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(pojoClazz); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #12
Source File: TestWsSubprotocols.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext() .getAttribute(Constants. SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(SubProtocolsEndpoint.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #13
Source File: TesterFirehoseServer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(Endpoint.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #14
Source File: TesterUtil.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(pojoClazz); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #15
Source File: TestWsSubprotocols.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext() .getAttribute(Constants. SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { sc.addEndpoint(SubProtocolsEndpoint.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #16
Source File: TestWsWebSocketContainer.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void contextInitialized(ServletContextEvent sce) { super.contextInitialized(sce); ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute( Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE); try { // Reset blocking state BlockingPojo.resetBlock(); sc.addEndpoint(BlockingPojo.class); } catch (DeploymentException e) { throw new IllegalStateException(e); } }
Example #17
Source File: TestWsWebSocketContainer.java From Tomcat8-Source-Read with MIT License | 4 votes |
@Test public void testConnectToServerEndpointSSL() throws Exception { Tomcat tomcat = getTomcatInstance(); // No file system docBase required Context ctx = tomcat.addContext("", null); ctx.addApplicationListener(TesterEchoServer.Config.class.getName()); Tomcat.addServlet(ctx, "default", new DefaultServlet()); ctx.addServletMappingDecoded("/", "default"); TesterSupport.initSsl(tomcat); tomcat.start(); WebSocketContainer wsContainer = ContainerProvider.getWebSocketContainer(); ClientEndpointConfig clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); // Create the SSL Context // Java 7 doesn't default to TLSv1.2 but the tests do SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); // Trust store File keyStoreFile = new File(TesterSupport.CA_JKS); KeyStore ks = KeyStore.getInstance("JKS"); try (InputStream is = new FileInputStream(keyStoreFile)) { ks.load(is, org.apache.tomcat.websocket.Constants.SSL_TRUSTSTORE_PWD_DEFAULT.toCharArray()); } TrustManagerFactory tmf = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); sslContext.init(null, tmf.getTrustManagers(), null); clientEndpointConfig.getUserProperties().put( org.apache.tomcat.websocket.Constants.SSL_CONTEXT_PROPERTY, sslContext); Session wsSession = wsContainer.connectToServer( TesterProgrammaticEndpoint.class, clientEndpointConfig, new URI("wss://" + getHostName() + ":" + getPort() + TesterEchoServer.Config.PATH_ASYNC)); CountDownLatch latch = new CountDownLatch(1); BasicText handler = new BasicText(latch); wsSession.addMessageHandler(handler); wsSession.getBasicRemote().sendText(MESSAGE_STRING_1); boolean latchResult = handler.getLatch().await(10, TimeUnit.SECONDS); Assert.assertTrue(latchResult); Queue<String> messages = handler.getMessages(); Assert.assertEquals(1, messages.size()); Assert.assertEquals(MESSAGE_STRING_1, messages.peek()); }