• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultApacheHttpClient4Config类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config的典型用法代码示例。如果您正苦于以下问题:Java DefaultApacheHttpClient4Config类的具体用法?Java DefaultApacheHttpClient4Config怎么用?Java DefaultApacheHttpClient4Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultApacheHttpClient4Config类属于com.sun.jersey.client.apache4.config包,在下文中一共展示了DefaultApacheHttpClient4Config类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initWithNiwsConfig

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    super.initWithNiwsConfig(clientConfig);
    this.ncc = clientConfig;
    this.restClientName = ncc.getClientName();
    this.isSecure = getBooleanFromConfig(ncc, CommonClientConfigKey.IsSecure, this.isSecure);
    this.isHostnameValidationRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsHostnameValidationRequired, this.isHostnameValidationRequired);
    this.isClientAuthRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsClientAuthRequired, this.isClientAuthRequired);
    this.bFollowRedirects = getBooleanFromConfig(ncc, CommonClientConfigKey.FollowRedirects, true);
    this.ignoreUserToken = getBooleanFromConfig(ncc, CommonClientConfigKey.IgnoreUserTokenInConnectionPoolForSecureClient, this.ignoreUserToken);

    this.config = new DefaultApacheHttpClient4Config();
    this.config.getProperties().put(
            ApacheHttpClient4Config.PROPERTY_CONNECT_TIMEOUT,
            Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ConnectTimeout))));
    this.config.getProperties().put(
            ApacheHttpClient4Config.PROPERTY_READ_TIMEOUT,
            Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ReadTimeout))));

    this.restClient = apacheHttpClientSpecificInitialization();
    this.setRetryHandler(new HttpClientLoadBalancerErrorHandler(ncc));
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:23,代码来源:RestClient.java


示例2: createClient

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
@Before
public void createClient() throws Exception {
  testProperties = new TestProperties();

  String applicationContextPath = getApplicationContextPath();
  APP_BASE_PATH = testProperties.getApplicationPath("/" + applicationContextPath);
  LOGGER.info("Connecting to application "+APP_BASE_PATH);

  ClientConfig clientConfig = new DefaultApacheHttpClient4Config();
  clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
  client = ApacheHttpClient4.create(clientConfig);

  defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient();
  HttpParams params = defaultHttpClient.getParams();
  HttpConnectionParams.setConnectionTimeout(params, 3 * 60 * 1000);
  HttpConnectionParams.setSoTimeout(params, 10 * 60 * 1000);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:18,代码来源:AbstractWebappIntegrationTest.java


示例3: createDefaultJerseyClient

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:BlobStoreClientFactory.java


示例4: createDefaultJerseyClient

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:UserAccessControlClientFactory.java


示例5: createDefaultJerseyClient

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) {
    HttpClient httpClient = new HttpClientBuilder().using(configuration).build();
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    // For shading reasons we can't add a Jackson JSON message body provider.  However, our client implementation will
    // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter.
    return new ApacheHttpClient4(handler, config);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:9,代码来源:BlobStoreClientFactory.java


示例6: createDefaultJerseyClient

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) {
    HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName);
    ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true);
    ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator()));
    return new ApacheHttpClient4(handler, config);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:QueueClientFactory.java


示例7: TestUtil

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
public TestUtil(TestProperties testProperties) {

    this.testProperties = testProperties;

    // create admin user:
    ClientConfig clientConfig = new DefaultApacheHttpClient4Config();
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = ApacheHttpClient4.create(clientConfig);

    defaultHttpClient = (DefaultHttpClient) client.getClientHandler().getHttpClient();
  }
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:12,代码来源:TestUtil.java


示例8: buildClientConfig

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
private ApacheHttpClient4Config buildClientConfig() {
    ApacheHttpClient4Config clientConfig = new DefaultApacheHttpClient4Config();
    ObjectMapper objectMapper = buildObjectMapper();
    clientConfig.getSingletons().add(new JacksonJaxbJsonProvider(objectMapper, null));
    return clientConfig;
}
 
开发者ID:BrettDuclos,项目名称:Dials,代码行数:7,代码来源:DialsClientBuilder.java


示例9: main

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    
    //get the command line arguments
    if(args.length < 5) {
        printUseage();
        System.exit(1);
        return;
    }
    final String server = args[0];
    final int port = Integer.parseInt(args[1]);
    
    final String query = args[2];
    final File queryFile;
    if(query.charAt(0) == '@') {
       queryFile = new File(query.substring(1));
       if(!queryFile.exists()) {
           System.err.println("Query file '" + queryFile.getAbsolutePath() + "' does not exist!");
           System.exit(2);
        } 
    } else {
        queryFile = null;
    }
    
    final String path = args[3];
    final String username = args[4];
    final String password;
    if(args.length == 6) {
        password = args[5];
    } else {
        password = "";
    }
    
    //setup authentication
    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
    final DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getProperties().put(ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider);
    
    //setup the Resource for the REST Server API Call
    final Client client = ApacheHttpClient4.create(config);
    final String uri = "http://" + server + ":" + port + "/exist/rest" + path;
    final WebResource resource;
    final ClientResponse response;
    
    logger.info("Starting Query of {}...", uri);
    
    if(queryFile == null) {
        resource = client.resource(uri + "?_query=" + URLEncoder.encode(query, "UTF-8"));
        logger.info("Using HTTP GET to perform the Query...");
        
        //GET the Resource
        response = resource.get(ClientResponse.class);
    } else {
        resource = client.resource(uri);
        logger.info("Using HTTP POST to perform the Query...");
        
        //POST the Resource
        response = resource.type(MediaType.APPLICATION_XML_TYPE).post(ClientResponse.class, createQueryDocument(queryFile));
    }
    
    
    final Status responseStatus = response.getClientResponseStatus();
    if(responseStatus == Status.OK) {
        ConsoleWriter.writeResponseBody(response, "Finished Query OK.");
    } else {
        logger.error("Received HTTP Response: {} {}", responseStatus.getStatusCode(), responseStatus.toString());
        System.exit(3);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:70,代码来源:QueryApp.java


示例10: main

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    
    //get the command line arguments
    if(args.length < 4) {
        printUseage();
        System.exit(1);
        return;
    }
    final String server = args[0];
    final int port = Integer.parseInt(args[1]);
    final String path = args[2];
    final String username = args[3];
    final String password;
    if(args.length == 5) {
        password = args[4];
    } else {
        password = "";
    }
    
    //setup authentication
    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
    final DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getProperties().put(ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider);
    
    //setup the Resource for the REST Server API Call
    final Client client = ApacheHttpClient4.create(config);
    final String uri = "http://" + server + ":" + port + "/exist/rest" + path;
    final WebResource resource = client.resource(uri);
    
    logger.info("About to remove {}...", uri);
    
    //DELETE the Resource
    final ClientResponse response = resource.delete(ClientResponse.class);
    final Status responseStatus = response.getClientResponseStatus();
    if(responseStatus == Status.OK) {
        ConsoleWriter.writeResponseBody(response, "Removed OK.");
    } else {
        logger.error("Received HTTP Response: {} {}", responseStatus.getStatusCode(), responseStatus.toString());
        System.exit(3);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:43,代码来源:RemoveApp.java


示例11: main

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    
    //get the command line arguments
    if(args.length < 5) {
        printUseage();
        System.exit(1);
        return;
    }
    final String server = args[0];
    final int port = Integer.parseInt(args[1]);
    final File file = new File(args[2]);
    if(!file.exists()) {
       System.err.println("File '" + file.getAbsolutePath() + "' does not exist!");
       System.exit(2);
    }
    final String collection = args[3];
    final String username = args[4];
    final String password;
    if(args.length == 6) {
        password = args[5];
    } else {
        password = "";
    }
    
    //setup authentication
    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
    final DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getProperties().put(ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider);
    
    //setup the Resource for the REST Server API Call
    final Client client = ApacheHttpClient4.create(config);
    final String uri = "http://" + server + ":" + port + "/exist/rest" + collection + "/" + file.getName();
    final WebResource resource = client.resource(uri);
    
    logger.info("Starting upload of {} to {}...", file.getAbsolutePath(), uri);
    
    //PUT the Resource
    final ClientResponse response = resource.put(ClientResponse.class, file);
    final Status responseStatus = response.getClientResponseStatus();
    if(responseStatus == Status.CREATED) {
        ConsoleWriter.writeResponseBody(response, "Finished upload OK.");
    } else {
        logger.error("Received HTTP Response: {} {}", responseStatus.getStatusCode(), responseStatus.toString());
        System.exit(3);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:48,代码来源:StoreApp.java


示例12: main

import com.sun.jersey.client.apache4.config.DefaultApacheHttpClient4Config; //导入依赖的package包/类
public static void main(final String[] args) {
    
    //get the command line arguments
    if(args.length < 4) {
        printUseage();
        System.exit(1);
        return;
    }
    final String server = args[0];
    final int port = Integer.parseInt(args[1]);
    final String path = args[2];
    final String username = args[3];
    final String password;
    if(args.length == 5) {
        password = args[4];
    } else {
        password = "";
    }
    
    //setup authentication
    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
    final DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config();
    config.getProperties().put(ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider);
    
    //setup the Resource for the REST Server API Call
    final Client client = Client.create();
    final String uri = "http://" + server + ":" + port + "/exist/rest" + path;
    final WebResource resource = client.resource(uri);
    
    logger.info("Starting download of {}...", uri);
    
    //GET the Resource
    final ClientResponse response = resource.get(ClientResponse.class);
    final Status responseStatus = response.getClientResponseStatus();
    if(responseStatus == Status.OK) {
        logger.info("Received: {}", response.getType().toString());
        
        //download the Resource and print the content out on the console
        ConsoleWriter.writeResponseBody(response, "Finished download OK.");
    } else {
        logger.error("Received HTTP Response: {} {}", responseStatus.getStatusCode(), responseStatus.toString());
        System.exit(2);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:46,代码来源:RetrieveApp.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FeatureTypeConstraint类代码示例发布时间:2022-05-22
下一篇:
Java OWLEditorKit类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap