當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。