本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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);
}
}