@Override public JerseyClientBuilder property(String name, Object value) { this.config.property(name, value); return this; }
@Override public JerseyClientBuilder property(String name, Object value) { this.config.property(name, value); return this; }
private void addProxyConfiguration(ClientConfig clientConfig) { if (proxyHost != null) { String proxyAddress = proxyHost; if (proxyPort > 0) { proxyAddress += ':' + proxyPort; } clientConfig.property(ClientProperties.PROXY_URI, proxyAddress); if (proxyUserName != null) { if (proxyPassword == null) { throw new IllegalArgumentException("Proxy user name provided but not password"); } clientConfig.property(ClientProperties.PROXY_USERNAME, proxyUserName); clientConfig.property(ClientProperties.PROXY_PASSWORD, proxyPassword); } } }
@Override public JerseyClientBuilder property(String name, Object value) { this.config.property(name, value); return this; }
@Override public JerseyClient property(final String name, final Object value) { checkNotClosed(); config.property(name, value); return this; }
@Override public JerseyWebTarget property(String name, Object value) { checkNotClosed(); config.property(name, value); return this; }
@Override public JerseyWebTarget property(String name, Object value) { checkNotClosed(); config.property(name, value); return this; }
@Override public JerseyClient property(final String name, final Object value) { checkNotClosed(); config.property(name, value); return this; }
public RestSchemaRegistryClient(final List<String> baseUrls, final int timeoutMillis, final SSLContext sslContext, final ComponentLog logger) { this.baseUrls = new ArrayList<>(baseUrls); final ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, timeoutMillis); clientConfig.property(ClientProperties.READ_TIMEOUT, timeoutMillis); client = WebUtils.createClient(clientConfig, sslContext); this.logger = logger; }
@Override public JerseyClient property(final String name, final Object value) { checkNotClosed(); config.property(name, value); return this; }
@Override public JerseyWebTarget property(String name, Object value) { checkNotClosed(); config.property(name, value); return this; }
public EurekaJersey2ClientImpl( int connectionTimeout, int readTimeout, final int connectionIdleTimeout, ClientConfig clientConfig) { try { jerseyClientConfig = clientConfig; jerseyClientConfig.register(DiscoveryJerseyProvider.class); jerseyClientConfig.connectorProvider(new ApacheConnectorProvider()); jerseyClientConfig.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout); jerseyClientConfig.property(ClientProperties.READ_TIMEOUT, readTimeout); apacheHttpClient = ClientBuilder.newClient(jerseyClientConfig); connectionCleanerTask = new ConnectionCleanerTask(connectionIdleTimeout); eurekaConnCleaner.scheduleWithFixedDelay( connectionCleanerTask, HTTP_CONNECTION_CLEANER_INTERVAL_MS, HTTP_CONNECTION_CLEANER_INTERVAL_MS, TimeUnit.MILLISECONDS); } catch (Throwable e) { throw new RuntimeException("Cannot create Jersey2 client", e); } }
private ClientConfig _getClientConfig() { ClientConfig clientConfig = _setCredentials(_userId, _password); clientConfig = clientConfig.property( ClientProperties.CONNECT_TIMEOUT, _liferayConnectionProperties.connectTimeout.getValue() * 1000); clientConfig = clientConfig.property( ClientProperties.READ_TIMEOUT, _liferayConnectionProperties.readTimeout.getValue() * 1000); return clientConfig; }
private Client getClient(final SSLContext sslContext) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT); final Client client; if (sslContext == null) { client = WebUtils.createClient(clientConfig); } else { client = WebUtils.createClient(clientConfig, sslContext); } return client; }
private void init() { final ApacheConnectorProvider apacheConnectorProvider = new ApacheConnectorProvider(); final ClientConfig clientConfig = new ClientConfig().connectorProvider(apacheConnectorProvider); // transfer encoding should be set as jersey sets it on by default. clientConfig.property(ClientProperties.REQUEST_ENTITY_PROCESSING, enableChunkedEncoding ? RequestEntityProcessing.CHUNKED : RequestEntityProcessing.BUFFERED); client = ClientBuilder.newClient(clientConfig); target = client.target(urlString).path(PUT_PATH); if(sync) { // need to add an empty string else it is nto added as query param. target = target.queryParam("sync", "").queryParam("sync_timeout", syncTimeout); } if(responseType != ResponseType.None) { // need to add an empty string else it is nto added as query param. target = target.queryParam(responseType.value, ""); } LOG.info("target uri [{}]", target.getUri()); }
/** * Builds a {@link Resource} with a configured Jersey testing environment. * * @return a new {@link Resource} */ protected Resource buildResource() { if (bootstrapLogging) { BootstrapLogging.bootstrap(); } Consumer<ClientConfig> extendedConfigurator = config -> { clientConfigurator.accept(config); config.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); }; return new Resource(new ResourceTestJerseyConfiguration( singletons, providers, properties, mapper, validator, extendedConfigurator, testContainerFactory, registerDefaultExceptionMappers)); } }
protected Client initClient(int rt, int ct) { ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, ct); clientConfig.property(ClientProperties.READ_TIMEOUT, rt); ClientBuilder.newBuilder().register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); client.register(JacksonFeature.class); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(JacksonUtil.getMapper()); client.register(provider); return client; }
protected Client initClient(int rt, int ct) { ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, ct); clientConfig.property(ClientProperties.READ_TIMEOUT, rt); ClientBuilder.newBuilder().register(JacksonFeature.class); Client client = ClientBuilder.newClient(clientConfig); client.register(JacksonFeature.class); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(JacksonUtil.getMapper()); client.register(provider); return client; }
private Configuration buildConfig(final String name, final ExecutorService threadPool, final ObjectMapper objectMapper, final Validator validator) { final ClientConfig config = new ClientConfig(); for (Object singleton : this.singletons) { config.register(singleton); } for (Class<?> provider : this.providers) { config.register(provider); } config.register(new JacksonFeature(objectMapper)); config.register(new HibernateValidationBinder(validator)); for (Map.Entry<String, Object> property : this.properties.entrySet()) { config.property(property.getKey(), property.getValue()); } config.register(new DropwizardExecutorProvider(threadPool)); if (connectorProvider == null) { final ConfiguredCloseableHttpClient apacheHttpClient = apacheHttpClientBuilder.buildWithDefaultRequestConfiguration(name); config.connectorProvider((client, runtimeConfig) -> createDropwizardApacheConnector(apacheHttpClient)); } else { config.connectorProvider(connectorProvider); } return config; }