本文整理汇总了Java中javax.websocket.server.ServerEndpointConfig.Configurator方法的典型用法代码示例。如果您正苦于以下问题:Java ServerEndpointConfig.Configurator方法的具体用法?Java ServerEndpointConfig.Configurator怎么用?Java ServerEndpointConfig.Configurator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.websocket.server.ServerEndpointConfig
的用法示例。
在下文中一共展示了ServerEndpointConfig.Configurator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerRooms
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private Set<ServerEndpointConfig> registerRooms(Collection<Room> rooms) {
Set<ServerEndpointConfig> endpoints = new HashSet<ServerEndpointConfig>();
for (Room room : rooms) {
RoomRegistrationHandler roomRegistration = new RoomRegistrationHandler(room, systemId, registrationSecret);
try{
roomRegistration.performRegistration();
}catch(Exception e){
Log.log(Level.SEVERE, this, "Room Registration FAILED", e);
//we keep running, maybe we were registered ok before...
}
//now regardless of our registration, open our websocket.
SessionRoomResponseProcessor srrp = new SessionRoomResponseProcessor();
ServerEndpointConfig.Configurator config = new RoomWSConfig(room, srrp, roomRegistration.getToken());
endpoints.add(ServerEndpointConfig.Builder.create(RoomWS.class, "/ws/" + room.getRoomId())
.configurator(config).build());
}
return endpoints;
}
示例2: initWebsocketRpcRuntime
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private void initWebsocketRpcRuntime(final ServletContext ctx, final RpcSpringContext rpcCtx) {
LOGGER.info("Starting Websocket RPC runtime");
ServerEndpointConfig.Configurator cfg = new WebsocketEndpointConfigurator(ctx, rpcCtx);
ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(WebsocketEndpoint.class, RpcConfig.getInstance().getPath() + "/wskt").configurator(cfg).build();
try {
rpcCtx.getWebsocketContainer().addEndpoint(sec);
} catch (DeploymentException ex) {
throw new RuntimeException(ex);
}
}
示例3: getConfigurator
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
@Override
public Configurator getConfigurator() {
for (ServerEndpointConfig.Configurator impl : ServiceLoader.load(javax.websocket.server.ServerEndpointConfig.Configurator.class)) {
return impl;
}
throw new IllegalStateException("Cannot load platform configurator");
}
示例4: configuratorFor
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private ServerEndpointConfig.Configurator configuratorFor(final String prefix, final boolean isRaw) {
return new ServerEndpointConfig.Configurator() {
@Override
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
try {
return endpointClass.getConstructor(SockJsServer.class, String.class, String.class)
.newInstance(sockJsServer, context.getContextPath(), prefix);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
HandshakeResponse response) {
if (isRaw) {
// We have no reliable key (like session id) to save
// headers with for raw websocket requests
return;
}
String path = request.getRequestURI().getPath();
Matcher matcher = SESSION_PATTERN.matcher(path);
if (matcher.matches()) {
String sessionId = matcher.group(1);
saveHeaders(sessionId, request.getHeaders());
}
}
};
}
示例5: configuratorFor
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
private ServerEndpointConfig.Configurator configuratorFor(final String prefix, final boolean isRaw) {
return new ServerEndpointConfig.Configurator() {
@Override
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException {
try {
return endpointClass.getConstructor(SockJsServer.class, String.class, String.class)
.newInstance(sockJsServer, getServletContext().getContextPath(), prefix);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request,
HandshakeResponse response) {
if (isRaw) {
// We have no reliable key (like session id) to save
// headers with for raw websocket requests
return;
}
String path = request.getRequestURI().getPath();
Matcher matcher = SESSION_PATTERN.matcher(path);
if (matcher.matches()) {
String sessionId = matcher.group(1);
saveHeaders(sessionId, request.getHeaders());
}
}
};
}
示例6: test_store_request_headers_in_the_user_properties_map_during_handshake
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
@Test
public void test_store_request_headers_in_the_user_properties_map_during_handshake() {
ServerEndpointConfig.Configurator configurator = new DaggerEndpointConfigurator(null);
HandshakeRequest handshakeRequest = createHandshakeRequest();
ServerEndpointConfig endpointConfig = createServerEndpointConfig();
configurator.modifyHandshake(endpointConfig, handshakeRequest, null);
assertSame(handshakeRequest.getHeaders(), endpointConfig.getUserProperties().get(DaggerEndpointConfigurator.REQUEST_HEADERS_KEY));
}
示例7: DelegatingConfigurator
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
public DelegatingConfigurator(final ServerEndpointConfig.Configurator delegate) {
this.delegate = delegate;
}
示例8: WebsocketBundle
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
public WebsocketBundle(ServerEndpointConfig.Configurator defaultConfigurator, Class<?>... endpoints) {
this(defaultConfigurator, Arrays.asList(endpoints), new ArrayList<>());
}
示例9: DefaultServerEndpointConfig
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
* <p>Constructor for DefaultServerEndpointConfig.</p>
*
* @param manager a manager
* @param endpointClass a {@link java.lang.Class} endpoint class.
* @param webSocketConf a {@link ameba.websocket.WebSocket} object.
*/
public DefaultServerEndpointConfig(final InjectionManager manager,
Class endpointClass,
final WebSocket webSocketConf) {
path = webSocketConf.path();
subprotocols = Arrays.asList(webSocketConf.subprotocols());
encoders = Lists.newArrayList(webSocketConf.encoders());
decoders = Lists.newArrayList(webSocketConf.decoders());
for (Class<? extends Extension> extensionClass : webSocketConf.extensions()) {
extensions.add(Injections.getOrCreate(manager, extensionClass));
}
final WebSocketEndpointProvider provider = manager.getInstance(WebSocketEndpointProvider.class);
final EndpointMeta endpointMeta = provider.parseMeta(endpointClass, webSocketConf);
final ServerEndpointConfig.Configurator cfgr =
Injections.getOrCreate(manager, webSocketConf.configurator());
serverEndpointConfigurator = new ServerEndpointConfig.Configurator() {
@Override
public String getNegotiatedSubprotocol(List<String> supported, List<String> requested) {
return cfgr.getNegotiatedSubprotocol(supported, requested);
}
@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
return cfgr.getNegotiatedExtensions(installed, requested);
}
@Override
public boolean checkOrigin(String originHeaderValue) {
return cfgr.checkOrigin(originHeaderValue);
}
@Override
public void modifyHandshake(ServerEndpointConfig sec,
HandshakeRequest request, HandshakeResponse response) {
cfgr.modifyHandshake(sec, request, response);
}
@Override
public <T> T getEndpointInstance(Class<T> eClass) throws InstantiationException {
if (EndpointDelegate.class.equals(eClass)) {
return eClass.cast(new EndpointDelegate(endpointMeta));
}
return cfgr.getEndpointInstance(eClass);
}
};
}
示例10: getConfigurator
import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public ServerEndpointConfig.Configurator getConfigurator() {
return serverEndpointConfigurator;
}