Package org.glassfish.jersey.client

Examples of org.glassfish.jersey.client.ClientConfig.register()


  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


  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

            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

    }

    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());
View Full Code Here

    final ClientConfig clientConfig = createClientConfig(config,
        jacksonJsonProvider, httpParams, clientConnectionManager);
    final Connector connector = new ApacheConnector(clientConfig);
    clientConfig.connector(connector);
    clientConfig.register(new CsrfProtectionFilter(
        "DiscoveryDNS Reseller API Client"));
    final ClientBuilder clientBuilder = ClientBuilder.newBuilder();
    clientBuilder.withConfig(clientConfig);

    return clientBuilder.build();
View Full Code Here

  private ClientConfig createClientConfig(final DNSAPIClientConfig config,
      final JacksonJsonProvider jacksonJsonProvider,
      final HttpParams httpParams,
      final PoolingClientConnectionManager clientConnectionManager) {
    final ClientConfig clientConfig = new ClientConfig();
    clientConfig.register(jacksonJsonProvider);
    clientConfig.property(
        ClientProperties.BUFFER_RESPONSE_ENTITY_ON_EXCEPTION, true);
    clientConfig.property(ClientProperties.CONNECT_TIMEOUT,
        config.getTimeout());
    clientConfig.property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE,
View Full Code Here

        _test("Disabled", false, true);
    }

    private void _test(final String response, final Boolean globalDisable, final Boolean clientDisable) throws Exception {
        final ClientConfig config = new ClientConfig();
        config.register(Filter.class);

        if (globalDisable != null) {
            config.property(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, globalDisable);
        }
        if (clientDisable != null) {
View Full Code Here

    @Test
    public void testPostChunked() {
        ClientConfig config = new ClientConfig();
        config.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024);
        config.connectorProvider(new JettyConnectorProvider());
        config.register(new LoggingFilter(LOGGER, true));

        Client client = ClientBuilder.newClient(config);
        WebTarget r = client.target(getBaseUri());

        byte[] content = new byte[1024 * 1024];
 
View Full Code Here

    }

    @Test
    public void testCustomExecutorsAsync() throws ExecutionException, InterruptedException {
        ClientConfig jerseyConfig = new ClientConfig();
        jerseyConfig.register(CustomExecutorProvider.class).register(ThreadInterceptor.class);
        Client client = ClientBuilder.newClient(jerseyConfig);
        runCustomExecutorTestAsync(client);
    }

    @Test
View Full Code Here

    }

    @Test
    public void testCustomExecutorsInstanceAsync() throws ExecutionException, InterruptedException {
        ClientConfig jerseyConfig = new ClientConfig();
        jerseyConfig.register(new CustomExecutorProvider()).register(ThreadInterceptor.class);
        Client client = ClientBuilder.newClient(jerseyConfig);
        runCustomExecutorTestAsync(client);
    }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.