Package org.glassfish.jersey.client

Examples of org.glassfish.jersey.client.ClientConfig$State


        host = environment.getProperty("bookService.host", "localhost");
        client = createHttpClient();
    }

    private Client createHttpClient() {
        ClientConfig clientConfig = new ClientConfig()
                .register(new JacksonFeature())
                .connectorProvider(new ApacheConnectorProvider());
        if (Boolean.parseBoolean(System.getProperty("proxySet"))) {
            clientConfig.property(ClientProperties.PROXY_URI, "http://" + System.getProperty("http.proxyHost") + ":" + System.getProperty("http.proxyPort"));
        }
        return ClientBuilder.newClient(clientConfig);
    }
View Full Code Here


            @Override
            public void releaseRequestingExecutor(ExecutorService es) {
            }
        };
        final ClientConfig config = new ClientConfig().
                // This is commented since, jersey has major problem (since ~2.5) - it blocks the calling thread !!!
                // When this bug will be fixed we should uncomment this line in order to enable a lot of concurrent open requsets               
                //                register(singleThreadPool, RequestExecutorProvider.class).
                property(ClientProperties.ASYNC_THREADPOOL_SIZE, 20);
        if (configuration != null)
            config.loadFrom(configuration);
        if (config.getConnectorProvider() == null)
            config.connectorProvider(new JettyConnectorProvider());
        return config;
    }
View Full Code Here

            @Override
            public void releaseRequestingExecutor(ExecutorService es) {
            }
        };
        final ClientConfig config = new ClientConfig().
                register(singleThreadPool, RequestExecutorProvider.class).
                property(ClientProperties.ASYNC_THREADPOOL_SIZE, 20);
        if (configuration != null)
            config.loadFrom(configuration);
        if (config.getConnectorProvider() == null)
            config.connectorProvider(new JettyConnectorProvider());

        return new FiberClient(ClientBuilder.newClient(config));
    }
View Full Code Here

  private String path;
  private String accessKey;
  private String secretKey;

  public ParaClient(String accessKey, String secretKey) {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.register(GenericExceptionMapper.class);
    clientConfig.register(new JacksonJsonProvider(Utils.getJsonMapper()));
    clientConfig.connectorProvider(new JettyConnectorProvider());
    this.client = ClientBuilder.newClient(clientConfig);
    this.accessKey = accessKey;
    this.secretKey = secretKey;
  }
View Full Code Here

     * @param tc                 instance of {@link TestContainer}
     * @param applicationHandler instance of {@link ApplicationHandler}
     * @return A Client instance.
     */
    protected Client getClient(TestContainer tc, ApplicationHandler applicationHandler) {
        ClientConfig cc = tc.getClientConfig();

        if (cc == null) {
            cc = new ClientConfig();
        }

        //check if logging is required
        if (isEnabled(TestProperties.LOG_TRAFFIC)) {
            cc.register(new LoggingFilter(LOGGER, isEnabled(TestProperties.DUMP_ENTITY)));
        }

        configureClient(cc);

        return ClientBuilder.newClient(cc);
View Full Code Here

            public ManagedClient get() {
                final Client client;
                if (serverConfig == null) {
                    client = ClientBuilder.newClient();
                } else {
                    ClientConfig clientConfig = new ClientConfig();
                    copyProviders(serverConfig, clientConfig);
                    client = ClientBuilder.newClient(clientConfig);
                }
                return new ManagedClient(client, "");
            }
View Full Code Here

                                final String baseUriProperty = prefix + "baseUri";
                                final Object bu = serverConfig.getProperty(baseUriProperty);
                                final String customBaseUri = (bu != null) ? bu.toString() : binding.baseUri();

                                final String configClassProperty = prefix + "configClass";
                                final ClientConfig cfg = resolveConfig(configClassProperty, binding);

                                final String inheritProvidersProperty = prefix + "inheritServerProviders";
                                if (PropertiesHelper.isProperty(serverConfig.getProperty(inheritProvidersProperty)) ||
                                        binding.inheritProviders()) {
                                    copyProviders(serverConfig, cfg);
                                }

                                final String propertyPrefix = prefix + "property.";
                                Collection<String> clientProperties =
                                        Collections2.filter(serverConfig.getPropertyNames(), new Predicate<String>() {
                                            @Override
                                            public boolean apply(String property) {
                                                return property.startsWith(propertyPrefix);
                                            }
                                        });

                                for (String property : clientProperties) {
                                    cfg.property(property.substring(propertyPrefix.length()),
                                            serverConfig.getProperty(property));
                                }

                                return new ManagedClient(ClientBuilder.newClient(cfg), customBaseUri);
                            }
View Full Code Here

            }
        }

        final Configuration cfg = Injections.getOrCreate(getLocator(), configClass);

        return (cfg instanceof ClientConfig) ? (ClientConfig) cfg : new ClientConfig().loadFrom(cfg);
    }
View Full Code Here

     *
     * @return a fully-configured {@link Client}
     */

    public Client build() {
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.property(ClientProperties.READ_TIMEOUT, configuration.getReadTimeout());
        clientConfig.property(ClientProperties.CONNECT_TIMEOUT, configuration.getConnectTimeout());
        clientConfig.property(ApacheClientProperties.DISABLE_COOKIES, true);

        PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
        poolingClientConnectionManager.setMaxTotal(configuration.getMaxTotalThread());
        poolingClientConnectionManager.setDefaultMaxPerRoute(configuration.getDefaultMaxPerRoute());

        clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, poolingClientConnectionManager);

        Client client = ClientBuilder.newBuilder()
                .register(JacksonFeature.class)
                .withConfig(clientConfig)
                .build();
View Full Code Here

    public static IConverter make(String baseUri) {
        return builder().baseUri(baseUri).build();
    }

    private static Client makeClient(long requestTimeout, int maxConnections) {
        ClientConfig clientConfig = new ClientConfig();
        int castRequestTimeout = Ints.checkedCast(requestTimeout);
        clientConfig.register(makeGZipFeature());
        clientConfig.property(ClientProperties.ASYNC_THREADPOOL_SIZE, maxConnections);
        clientConfig.property(ClientProperties.CONNECT_TIMEOUT, castRequestTimeout);
        clientConfig.property(ClientProperties.READ_TIMEOUT, castRequestTimeout);
        clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, makeConnectionManager(maxConnections));
        clientConfig.connectorProvider(new ApacheConnectorProvider());
        return ClientBuilder.newClient(clientConfig);
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.client.ClientConfig$State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.