当前位置: 首页>>代码示例>>Java>>正文


Java Configurator类代码示例

本文整理汇总了Java中javax.websocket.server.ServerEndpointConfig.Configurator的典型用法代码示例。如果您正苦于以下问题:Java Configurator类的具体用法?Java Configurator怎么用?Java Configurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configurator类属于javax.websocket.server.ServerEndpointConfig包,在下文中一共展示了Configurator类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setWebSocketEndpoints

import javax.websocket.server.ServerEndpointConfig.Configurator; //导入依赖的package包/类
/**
 *
 * @param context the context to add the web socket endpoints to
 * @param rtEventResource The instance of the websocket endpoint to return
 * @throws DeploymentException
 */
private static void setWebSocketEndpoints(ServletContextHandler context,
                                          EventsResource rtEventResource)
        throws DeploymentException, ServletException {

    ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context);

    ServerEndpointConfig serverConfig =
            ServerEndpointConfig.Builder
                                .create(EventsResource.class, EventsResource.RT_EVENT_ENDPOINT)
                                .configurator(new Configurator() {
                                    @Override
                                    public <T> T getEndpointInstance(Class<T> endpointClass)
                                            throws InstantiationException {
                                        return endpointClass.cast(rtEventResource);
                                    }
                                }).build();

    wsContainer.addEndpoint(serverConfig);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:26,代码来源:ServerMain.java

示例2: startServer

import javax.websocket.server.ServerEndpointConfig.Configurator; //导入依赖的package包/类
@Override
protected void startServer(int port, final Action<ServerWebSocket> websocketAction) throws
  Exception {
  server = new Server();
  ServerConnector connector = new ServerConnector(server);
  connector.setPort(port);
  server.addConnector(connector);
  ServletContextHandler handler = new ServletContextHandler();
  server.setHandler(handler);
  ServerContainer container = WebSocketServerContainerInitializer.configureContext(handler);
  ServerEndpointConfig config = ServerEndpointConfig.Builder.create(AsityServerEndpoint.class,
    TEST_URI)
  .configurator(new Configurator() {
    @Override
    public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
      return endpointClass.cast(new AsityServerEndpoint().onwebsocket(websocketAction));
    }
  })
  .build();
  container.addEndpoint(config);
  server.start();
}
 
开发者ID:cettia,项目名称:asity,代码行数:23,代码来源:JwaServerWebSocketTest.java

示例3: startServer

import javax.websocket.server.ServerEndpointConfig.Configurator; //导入依赖的package包/类
@Override
protected void startServer() throws Exception {
    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);
    server.addConnector(connector);
    ServletContextHandler handler = new ServletContextHandler();
    server.setHandler(handler);
    ServerContainer container = WebSocketServerContainerInitializer.configureContext(handler);
    ServerEndpointConfig config = ServerEndpointConfig.Builder.create(VibeServerEndpoint.class, "/test")
    .configurator(new Configurator() {
        @Override
        public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
            return endpointClass.cast(new VibeServerEndpoint().onwebsocket(performer.serverAction()));
        }
    })
    .build();
    container.addEndpoint(config);
    server.start();
}
 
开发者ID:vibe-project,项目名称:vibe-java-platform,代码行数:21,代码来源:JwaServerWebSocketTest.java

示例4: init

import javax.websocket.server.ServerEndpointConfig.Configurator; //导入依赖的package包/类
public static void init(final ServletContextHandler context, final MinijaxApplication application)
        throws ServletException, DeploymentException {

    final ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
    final Configurator configurator = new MinijaxWebSocketConfigurator(application);

    for (final Class<?> c : application.getWebSockets()) {
        final ServerEndpointConfig config = ServerEndpointConfig.Builder
                .create(c, c.getAnnotation(ServerEndpoint.class).value())
                .configurator(configurator)
                .build();
        container.addEndpoint(config);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:15,代码来源:MinijaxWebSocketUtils.java


注:本文中的javax.websocket.server.ServerEndpointConfig.Configurator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。