本文整理汇总了Java中javax.websocket.ClientEndpointConfig.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ClientEndpointConfig.Builder方法的具体用法?Java ClientEndpointConfig.Builder怎么用?Java ClientEndpointConfig.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.websocket.ClientEndpointConfig
的用法示例。
在下文中一共展示了ClientEndpointConfig.Builder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TyrusClient
import javax.websocket.ClientEndpointConfig; //导入方法依赖的package包/类
public TyrusClient(ExpandedConnectionParams connectionParams) throws URISyntaxException {
ClientEndpointConfig.Builder builder = ClientEndpointConfig.Builder.create();
if (connectionParams.hasSubprotocols())
builder.preferredSubprotocols(Arrays.asList(connectionParams.subprotocols.split(",")));
cec = builder.build();
ClientManager client = ClientManager
.createClient("org.glassfish.tyrus.container.jdk.client.JdkClientContainer");
client.setDefaultMaxSessionIdleTimeout(-1);
client.getProperties().put(ClientProperties.REDIRECT_ENABLED, Boolean.TRUE);
if (LOGGER.isTraceEnabled())
client.getProperties().put(ClientProperties.LOG_HTTP_UPGRADE, Boolean.TRUE);
if (connectionParams.hasCredentials())
client.getProperties().put(
ClientProperties.CREDENTIALS,
new Credentials(connectionParams.login, connectionParams.password == null ? ""
: connectionParams.password));
Settings settings = SoapUI.getSettings();
String keyStoreUrl = System.getProperty(SoapUISystemProperties.SOAPUI_SSL_KEYSTORE_LOCATION,
settings.getString(SSLSettings.KEYSTORE, null));
String pass = System.getProperty(SoapUISystemProperties.SOAPUI_SSL_KEYSTORE_PASSWORD,
settings.getString(SSLSettings.KEYSTORE_PASSWORD, ""));
if (!StringUtils.isNullOrEmpty(keyStoreUrl)) {
SslContextConfigurator sslContextConfigurator = new SslContextConfigurator(true);
sslContextConfigurator.setKeyStoreFile(keyStoreUrl);
sslContextConfigurator.setKeyStorePassword(pass);
sslContextConfigurator.setKeyStoreType("JKS");
if (sslContextConfigurator.validateConfiguration()) {
SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(sslContextConfigurator, true,
false, false);
client.getProperties().put(ClientProperties.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);
} else
LOGGER.warn("error validating keystore configuration");
}
this.client = client;
uri = new URI(connectionParams.getNormalizedServerUri());
}