javax.websocket.server.ServerEndpointConfig.Configurator Java Examples

The following examples show how to use javax.websocket.server.ServerEndpointConfig.Configurator. 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: GLSPConfigurator.java    From graphical-lsp with 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
Source File: KsqlRestApplication.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 5 votes vote down vote up
@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);
  }
}