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


Java ClientConfig.property方法代码示例

本文整理汇总了Java中org.glassfish.jersey.client.ClientConfig.property方法的典型用法代码示例。如果您正苦于以下问题:Java ClientConfig.property方法的具体用法?Java ClientConfig.property怎么用?Java ClientConfig.property使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.jersey.client.ClientConfig的用法示例。


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

示例1: createConfig

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
protected ClientConfig createConfig(Set<Feature> features) {
    ClientConfig config = new ClientConfig();
    config.property(ClientProperties.FOLLOW_REDIRECTS, followRedirects);
    config.property(ClientProperties.READ_TIMEOUT, readTimeoutMs);
    config.property(ClientProperties.CONNECT_TIMEOUT, connectTimeoutMs);
    config.property(ClientProperties.ASYNC_THREADPOOL_SIZE, asyncThreadPoolSize);

    features.forEach(f -> config.register(f));

    if (compression) {
        config.register(new EncodingFeature(GZipEncoder.class));
    }

    configRequestLogging(config);

    return config;
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:18,代码来源:HttpClientFactoryFactory.java

示例2: createClientConfig

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
protected ClientConfig createClientConfig() {
	ClientConfig config = new ClientConfig();
	if ( proxy != null && proxy.getUri() != null ) {
		config.property(ClientProperties.PROXY_URI, proxy.getUriString());
		config.property(ClientProperties.PROXY_USERNAME, proxy.getUserName());
		config.property(ClientProperties.PROXY_PASSWORD, proxy.getPassword());
	}
	config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);
	config.property(ApacheClientProperties.CREDENTIALS_PROVIDER, getCredentialsProvider());
	config.property(ApacheClientProperties.SERVICE_UNAVAILABLE_RETRY_STRATEGY, getServiceUnavailableRetryStrategy());
	config.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, doPreemptiveBasicAuthentication());
	config.connectorProvider(new ApacheConnectorProvider());
	config.register(JacksonFeature.class);
	config.register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.FINE, LoggingFeature.Verbosity.PAYLOAD_ANY, 10000));
	return config;
}
 
开发者ID:fod-dev,项目名称:FoDBugTrackerUtility,代码行数:17,代码来源:RestConnection.java

示例3: build

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
public Client build(final Configuration config) {
    // setup client
    ClientConfig clientConfig = new ClientConfig();

    if (config.isVerbose()) {
        clientConfig.register(new LoggingFilter(logger("jersey"), false));
    }

    clientConfig.property(ClientProperties.CONNECT_TIMEOUT, config.getTimeout() * 1000);
    clientConfig.property(ClientProperties.READ_TIMEOUT, config.getTimeout() * 1000);

    javax.ws.rs.client.Client client;

    if (config.isVerifySSL()) {
        client = ClientBuilder.newBuilder().withConfig(clientConfig).hostnameVerifier(new HostnameVerifier() {
            @Override
            public boolean verify(String s, SSLSession sslSession) {
                return config.isVerifySSL();
            }
        }).build();
    } else {
        client = ClientBuilder.newClient(clientConfig);
    }

    return client;
}
 
开发者ID:basecrm,项目名称:basecrm-java,代码行数:27,代码来源:HttpClient.java

示例4: addProxyConfiguration

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static void addProxyConfiguration(ClientConfig config, String baseUrl) {
	String protocol = URI.create(baseUrl).getScheme().toLowerCase();

	Optional<String> proxyHost = Optional.ofNullable(System.getProperty(protocol + ".proxyHost"));
	if (!proxyHost.isPresent()) {
		return;
	}

	String host = proxyHost.get();
	String port = Optional.ofNullable(System.getProperty(protocol + ".proxyPort")).orElse("8080");
	String proxyProtocol = Optional.ofNullable(System.getProperty(protocol + ".proxyProtocol")).orElse("http");
	String url = proxyProtocol + "://" + host + ":" + port;
	config.property(ClientProperties.PROXY_URI, url);

	Optional<String> username = Optional.ofNullable(System.getProperty(protocol + ".proxyUser"));
	Optional<String> password = Optional.ofNullable(System.getProperty(protocol + ".proxyPassword"));
	if (username.isPresent() && password.isPresent()) {
		UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username.get(), password.get());
		CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
		credentialsProvider.setCredentials(AuthScope.ANY, credentials);
	}
}
 
开发者ID:saucelabs,项目名称:testobject-java-api,代码行数:23,代码来源:RestClient.java

示例5: configureProxy

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private void configureProxy(ClientConfig clientConfig, URI originalUri, String protocol) {

        List<Proxy> proxies = ProxySelector.getDefault().select(originalUri);

        for (Proxy proxy : proxies) {
            InetSocketAddress address = (InetSocketAddress) proxy.address();
            if (address != null) {
                String hostname = address.getHostName();
                int port = address.getPort();

                clientConfig.property(ClientProperties.PROXY_URI, "http://" + hostname + ":" + port);

                String httpProxyUser = System.getProperty(protocol + ".proxyUser");
                if (httpProxyUser != null) {
                    clientConfig.property(ClientProperties.PROXY_USERNAME, httpProxyUser);
                    String httpProxyPassword = System.getProperty(protocol + ".proxyPassword");
                    if (httpProxyPassword != null) {
                        clientConfig.property(ClientProperties.PROXY_PASSWORD, httpProxyPassword);
                    }
                }
            }
        }
    }
 
开发者ID:docker-java,项目名称:docker-java,代码行数:24,代码来源:JerseyDockerCmdExecFactory.java

示例6: createClient

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
public static Client createClient(String serverCert, String clientCert, String clientKey, boolean debug, Class debugClass) throws Exception {
    SSLContext sslContext = SSLContexts.custom()
        .loadTrustMaterial(KeyStoreUtil.createTrustStore(serverCert), null)
        .loadKeyMaterial(KeyStoreUtil.createKeyStore(clientCert, clientKey), "consul".toCharArray())
        .build();

    ClientConfig config = new ClientConfig();
    config.property(ClientProperties.FOLLOW_REDIRECTS, "false");
    config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT_MS);
    config.register(MultiPartFeature.class);

    ClientBuilder builder = ClientBuilder.newBuilder().withConfig(config);
    builder.sslContext(sslContext);
    builder.hostnameVerifier(CertificateTrustManager.hostnameVerifier());

    if (debug) {
        builder = builder.register(new LoggingFilter(java.util.logging.Logger.getLogger(debugClass.getName()), true));
    }

    Client client = builder.build();
    LOGGER.debug("Jax rs client has been constructed: {}, sslContext: {}", client, sslContext);
    return client;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:24,代码来源:RestClientUtil.java

示例7: buildClient

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private static void buildClient() {
	if ( USE_PROXY ) {
		ClientConfig config = new ClientConfig();
		config.connectorProvider(new ApacheConnectorProvider());
		CredentialsProvider credentials = new BasicCredentialsProvider();
		credentials.setCredentials(AuthScope.ANY, new NTCredentials(PROXY_USER, PROXY_PASS, null, PROXY_DOMAIN));
		config.property(ApacheClientProperties.CREDENTIALS_PROVIDER, credentials);
		config.property(ClientProperties.PROXY_URI, PROXY_PROTOCOL + PROXY_SERVER);

		client = ClientBuilder.newClient(config);
	}
	else
		client = ClientBuilder.newClient();
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:15,代码来源:WebHelper.java

示例8: Pandora

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
public Pandora(AnnaConfig config) {
    this.appId = config.getPandora().getAppId();
    this.userKey = config.getPandora().getUserKey();
    this.pandoraBot = config.getPandora().getBot();

    ClientConfig cfg = new ClientConfig(JacksonJsonProvider.class);
    cfg.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    client = JerseyClientBuilder.createClient(cfg);
}
 
开发者ID:wireapp,项目名称:anna-bot,代码行数:10,代码来源:Pandora.java

示例9: create

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
@Override
public WebTarget create() {
	ClientConfig configuration = new ClientConfig();
	configuration = configuration.property(ClientProperties.CONNECT_TIMEOUT, CONNECTION_TIMEOUT_MS);
	configuration = configuration.property(ClientProperties.READ_TIMEOUT, CONNECTION_TIMEOUT_MS);
	Client client = ClientBuilder.newClient(configuration).register(JacksonJsonProvider.class);
	return client.target(uri);
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:9,代码来源:WebTargetFactory.java

示例10: get

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
@Override
public WebTarget get() {
	ClientConfig configuration = new ClientConfig();
	configuration = configuration.property(ClientProperties.CONNECT_TIMEOUT, CONNECTION_TIMEOUT_MS);
	configuration = configuration.property(ClientProperties.READ_TIMEOUT, CONNECTION_TIMEOUT_MS);
	Client client = ClientBuilder.newClient(configuration).register(JacksonJsonProvider.class)
			.register(ErrorResponseFilter.class);
	return client.target("http://localhost:38081");
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:10,代码来源:WebTargetProvider.java

示例11: RESTClient

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
/**
 * Creates a new REST Client for an entity of Type T. The client interacts with a Server providing
 * CRUD functionalities
 * @param hostURL The url of the host. Common Pattern: "http://[hostname]:[port]/servicename/"
 * @param application The name of the rest application, usually {@link #DEFAULT_REST_APPLICATION} "rest" (no "/"!)
 * @param endpoint The name of the rest endpoint, typically the all lower case name of the entity in a plural form.
 * E.g., "products" for the entity "Product" (no "/"!)
 * @param entityClass Classtype of the Entitiy to send/receive. Note that the use of this Class type is
 * 			open for interpretation by the inheriting REST clients.
 */
public RESTClient(String hostURL, String application, String endpoint, final Class<T> entityClass) {
	if (!hostURL.endsWith("/")) {
		hostURL += "/";
	}
	if (!hostURL.contains("://")) {
		hostURL = "http://" + hostURL;
	}
	ClientConfig config = new ClientConfig();
	config.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT);
	config.property(ClientProperties.READ_TIMEOUT, readTimeout);
	client = ClientBuilder.newClient(config);
	service = client.target(UriBuilder.fromUri(hostURL).build());
	applicationURI = application;
	endpointURI = endpoint;
	this.entityClass = entityClass;
	
	parameterizedGenericType = new ParameterizedType() {
	        public Type[] getActualTypeArguments() {
	            return new Type[] { entityClass };
	        }

	        public Type getRawType() {
	            return List.class;
	        }

	        public Type getOwnerType() {
	            return List.class;
	        }
	    };
	    genericListType = new GenericType<List<T>>(parameterizedGenericType) { };
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:42,代码来源:RESTClient.java

示例12: getInvocationBuilder

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
protected Builder getInvocationBuilder(String url, Map<String, String> queryParameters) {
		ClientConfig clientConfig = new ClientConfig();
		if (getProxyAddress() != null) {
			clientConfig.connectorProvider(new ApacheConnectorProvider());
			clientConfig.property(ClientProperties.PROXY_URI, getProxyAddress());
		}
		Client client = ClientBuilder.newClient(clientConfig);
		client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
		WebTarget webTarget = client.target(url);

		if (queryParameters != null) {
			for (Map.Entry<String, String> queryParameter: queryParameters.entrySet())
//				webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue().replace("_", "_1").replace("%",  "_0"));
				webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue());
		}

		
		return webTarget.request(MediaType.APPLICATION_JSON).accept("application/ld+json").header("Authorization", getCloudTokenValue());
	}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:20,代码来源:OEClientReadOnly.java

示例13: configure

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
@Override
public void configure(HttpConfig config, ScriptContext context) {
    ClientConfig cc = new ClientConfig();
    // support request body for DELETE (non-standard)
    cc.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    if (!config.isFollowRedirects()) {
        cc.property(ClientProperties.FOLLOW_REDIRECTS, false);
    }
    ClientBuilder clientBuilder = ClientBuilder.newBuilder()
            .withConfig(cc)
            .register(new LoggingInterceptor(context)) // must be first
            .register(MultiPartFeature.class);
    if (config.isSslEnabled()) {
        SSLContext sslContext;
        if (config.getSslTrustStore() != null) {
            String trustStoreFile = config.getSslTrustStore();                
            String password = config.getSslTrustStorePassword();
            char[] passwordChars = password == null ? null : password.toCharArray();
            String algorithm = config.getSslAlgorithm();
            String type = config.getSslTrustStoreType();
            if (type == null) {
                type = KeyStore.getDefaultType();
            }
            try {
                KeyStore trustStore = KeyStore.getInstance(type);
                InputStream is = FileUtils.getFileStream(trustStoreFile, context);
                trustStore.load(is, passwordChars);
                context.logger.debug("trust store key count: {}", trustStore.size());
                sslContext = SslConfigurator.newInstance()
                        .securityProtocol(algorithm) // will default to TLS if null
                        .trustStore(trustStore)
                        // .keyStore(trustStore)
                        .createSSLContext();
            } catch (Exception e) {
                context.logger.error("ssl config failed: {}", e.getMessage());
                throw new RuntimeException(e);
            }                
        } else {
            sslContext = HttpUtils.getSslContext(config.getSslAlgorithm());
        }
        HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
        clientBuilder.sslContext(sslContext);
        clientBuilder.hostnameVerifier((host, session) -> true);
    }
    client = clientBuilder.build();
    client.property(ClientProperties.CONNECT_TIMEOUT, config.getConnectTimeout());
    client.property(ClientProperties.READ_TIMEOUT, config.getReadTimeout());
    if (config.getProxyUri() != null) {
        client.property(ClientProperties.PROXY_URI, config.getProxyUri());
        if (config.getProxyUsername() != null && config.getProxyPassword() != null) {
            client.property(ClientProperties.PROXY_USERNAME, config.getProxyUsername());
            client.property(ClientProperties.PROXY_PASSWORD, config.getProxyPassword());
        }
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:56,代码来源:JerseyHttpClient.java

示例14: createClient

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
private Client createClient() {
  ClientConfig config = new ClientConfig();
  config.property(ClientProperties.CONNECT_TIMEOUT, configuration.getClientConnectTimeout());
  config.property(ClientProperties.READ_TIMEOUT, configuration.getClientReadTimeout());
  config.register(new LoggingFeature());
  return ClientBuilder.newClient(config);
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:8,代码来源:ApplicationContext.java

示例15: provide

import org.glassfish.jersey.client.ClientConfig; //导入方法依赖的package包/类
@Override
public Client provide() {
  ClientConfig config = new ClientConfig();
  config.property(ClientProperties.CONNECT_TIMEOUT, 1500);
  config.property(ClientProperties.READ_TIMEOUT, 1500);
  config.register(new LoggingFeature());
  Client client = ClientBuilder.newClient(config);

  LOGGER.debug(" *** Created client: {}", client);

  return client;
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:13,代码来源:ClientFactory.java


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