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


Java Configurator类代码示例

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


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

示例1: WebsocketClient

import javax.websocket.ClientEndpointConfig.Configurator; //导入依赖的package包/类
public WebsocketClient(String uri, final String sessionID, MessageHandler.Whole<String> messageHandler)
    throws IOException {

// add session ID so the request gets through LAMS security
Builder configBuilder = ClientEndpointConfig.Builder.create();
configBuilder.configurator(new Configurator() {
    @Override
    public void beforeRequest(Map<String, List<String>> headers) {
	headers.put("Cookie", Arrays.asList("JSESSIONID=" + sessionID));
    }
});
ClientEndpointConfig clientConfig = configBuilder.build();
this.websocketEndpoint = new WebsocketEndpoint(messageHandler);
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
try {
    container.connectToServer(websocketEndpoint, clientConfig, new URI(uri));
} catch (DeploymentException | URISyntaxException e) {
    throw new IOException("Error while connecting to websocket server", e);
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WebsocketClient.java

示例2: connect

import javax.websocket.ClientEndpointConfig.Configurator; //导入依赖的package包/类
private void connect() throws Exception {
	while (sessionServer != null && !sessionServer.isOpen()) {
		break;
	}
	SSLContext context = createSSLContext();
	SecureSocketClient endpoint = new SecureSocketClient();

	Configurator configurator = new Configurator() {

		@Override
		public void beforeRequest(Map<String, List<String>> headers) {
			headers.put(SEC_WEB_SOCKET_PROTOCOL_STRING, singletonList("configured-proto"));
		}

	};
	ClientEndpointConfig clientEndpointConfig = create().configurator(configurator)
			.preferredSubprotocols(asList(new String[] { "foo", "bar", "configured-proto" })).build();
	clientEndpointConfig.getUserProperties().put(SSL_CONTEXT, context);

	final WebSocketContainer serverContainer = getWebSocketContainer();
	URI uri = new URI("wss://127.0.0.1:8443/secure-test/session");
	serverContainer.connectToServer(endpoint, clientEndpointConfig, uri);
	awake();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:25,代码来源:SessionSecureTestCase.java

示例3: setConfigurator

import javax.websocket.ClientEndpointConfig.Configurator; //导入依赖的package包/类
public void setConfigurator(Configurator configurator) {
	this.configBuilder.configurator(configurator);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:EndpointConnectionManager.java


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