Java Code Examples for javax.websocket.server.ServerEndpointConfig.Configurator

The following examples show how to use javax.websocket.server.ServerEndpointConfig.Configurator. These examples are extracted from open source projects. 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 Project: graphical-lsp   Source File: GLSPConfigurator.java    License: Eclipse Public License 2.0 5 votes vote down vote up
Configurator getContainerConfigurator() {
	if (containerConfigurator == null) {
		containerConfigurator = ServiceLoader.load(javax.websocket.server.ServerEndpointConfig.Configurator.class)
				.findFirst().orElse(new ContainerDefaultConfigurator());
	}
	return containerConfigurator;
}
 
Example 2
@Override
protected void registerWebSocketEndpoints(ServerContainer container) {
  try {
    final ListeningScheduledExecutorService exec = MoreExecutors.listeningDecorator(
        Executors.newScheduledThreadPool(
            config.getInt(KsqlRestConfig.KSQL_WEBSOCKETS_NUM_THREADS),
            new ThreadFactoryBuilder()
                .setDaemon(true)
                .setNameFormat("websockets-query-thread-%d")
                .build()
        )
    );
    final ObjectMapper mapper = getJsonMapper();
    final StatementParser statementParser = new StatementParser(ksqlEngine);

    container.addEndpoint(
        ServerEndpointConfig.Builder
            .create(
                WSQueryEndpoint.class,
                WSQueryEndpoint.class.getAnnotation(ServerEndpoint.class).value()
            )
            .configurator(new Configurator() {
              @Override
              @SuppressWarnings("unchecked")
              public <T> T getEndpointInstance(Class<T> endpointClass) {
                return (T) new WSQueryEndpoint(
                    mapper,
                    statementParser,
                    ksqlEngine,
                    exec
                );
              }
            })
            .build()
    );
  } catch (DeploymentException e) {
    log.error("Unable to create websockets endpoint", e);
  }
}