本文整理匯總了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());
}