org.eclipse.jetty.websocket.servlet.WebSocketServlet Java Examples

The following examples show how to use org.eclipse.jetty.websocket.servlet.WebSocketServlet. 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: MVCConf.java    From codenjoy with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public ServletRegistrationBean wsControlServlet(@Value("${mvc.control-servlet-path}") String path) {
    WebSocketServlet servlet = new ControlWebSocketServlet(timer, controlPlayerTransport, secureAuthenticationService);

    return new ServletRegistrationBean<WebSocketServlet>(servlet, path){{
        setLoadOnStartup(100);
        setName("wsControlServlet");
    }};
}
 
Example #2
Source File: MVCConf.java    From codenjoy with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public ServletRegistrationBean wsScreenServlet(@Value("${mvc.screen-servlet-path}") String path) {
    ScreenWebSocketServlet servlet = new ScreenWebSocketServlet(screenPlayerTransport, defaultAuthenticationService);

    return new ServletRegistrationBean<WebSocketServlet>(servlet, path){{
        setLoadOnStartup(100);
        setName("wsScreenServlet");
    }};
}
 
Example #3
Source File: ClientProxy.java    From OmniOcular with Apache License 2.0 5 votes vote down vote up
@Override
public void startHttpServer() {
    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            Server server = new Server(23333);
            try {
                ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
                context.setContextPath("/");
                ServletHolder wsHolder = new ServletHolder("echo", new WebSocketServlet() {
                    @Override
                    public void configure(WebSocketServletFactory factory) {
                        factory.register(WebSocketHandler.class);
                    }
                });
                context.addServlet(wsHolder, "/w");

                URI uri = OmniOcular.class.getResource("/assets/omniocular/static/").toURI();
                context.setBaseResource(Resource.newResource(uri));
                context.setWelcomeFiles(new String[]{"index.html"});
                ServletHolder holderPwd = new ServletHolder("default", DefaultServlet.class);
                holderPwd.setInitParameter("cacheControl", "max-age=0,public");
                holderPwd.setInitParameter("useFileMappedBuffer", "false");
                context.addServlet(holderPwd, "/");

                server.setHandler(context);
                server.start();
                server.join();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    t.start();

}
 
Example #4
Source File: SubmarineServer.java    From submarine with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException,
    IOException {
  PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));

  final SubmarineConfiguration conf = SubmarineConfiguration.getInstance();
  LOG.info("Submarine server Host: " + conf.getServerAddress());
  if (conf.useSsl() == false) {
    LOG.info("Submarine server Port: " + conf.getServerPort());
  } else {
    LOG.info("Submarine server SSL Port: " + conf.getServerSslPort());
  }

  jettyWebServer = setupJettyServer(conf);

  // Web UI
  HandlerList handlers = new HandlerList();
  webApp = setupWebAppContext(handlers, conf);
  jettyWebServer.setHandler(handlers);

  // Add
  sharedServiceLocator = ServiceLocatorFactory.getInstance().create("shared-locator");
  ServiceLocatorUtilities.enableImmediateScope(sharedServiceLocator);
  ServiceLocatorUtilities.bind(
      sharedServiceLocator,
      new AbstractBinder() {
        @Override
        protected void configure() {
          bindAsContract(NotebookServer.class)
              .to(WebSocketServlet.class)
              .in(Singleton.class);
        }
      });

  setupRestApiContextHandler(webApp, conf);

  // Notebook server
  setupNotebookServer(webApp, conf, sharedServiceLocator);

  // Cluster Server
  setupClusterServer();

  rpcServer = SubmarineRpcServer.startRpcServer();
  startServer();
}