Java 类org.apache.http.osgi.services.HttpClientBuilderFactory 实例源码

项目:purecloud-iot    文件:HttpProxyConfigurationActivator.java   
/**
 * {@inheritDoc}
 */
@Override
public void start(final BundleContext context) throws Exception {
    this.context = context;

    // ensure we receive configurations for the proxy selector
    final Hashtable<String, Object> props = new Hashtable<String, Object>();
    props.put(Constants.SERVICE_PID, getName());
    props.put(Constants.SERVICE_VENDOR, context.getBundle().getHeaders(Constants.BUNDLE_VENDOR));
    props.put(Constants.SERVICE_DESCRIPTION, SERVICE_FACTORY_NAME);

    configurator = context.registerService(ManagedServiceFactory.class.getName(), this, props);
    clientFactory = context.registerService(HttpClientBuilderFactory.class.getName(),
                                            new OSGiClientBuilderFactory(context, registeredConfigurations, trackedHttpClients),
                                            props);
}
项目:modules    文件:DhisWebServiceImpl.java   
@Autowired
public DhisWebServiceImpl(@Qualifier("dhisSettingsService") SettingsService settingsService,
                          StatusMessageService statusMessageService,
                          HttpClientBuilderFactory httpClientBuilderFactory) throws InterruptedException {
    this.settingsService = settingsService;
    this.statusMessageService = statusMessageService;

    SocketConfig socketConfig = SocketConfig.custom()
            .setSoTimeout(SO_TIMEOUT)
            .build();

    poolingHttpClientConnectionManager = new PoolingHttpClientConnectionManager();
    poolingHttpClientConnectionManager.setMaxTotal(MAX_CONNECTIONS);
    poolingHttpClientConnectionManager.setDefaultMaxPerRoute(MAX_PER_ROUTE);
    poolingHttpClientConnectionManager.setDefaultSocketConfig(socketConfig);

    this.client = httpClientBuilderFactory.newBuilder()
            .setConnectionManager(poolingHttpClientConnectionManager)
            .build();

    ExecutorService executorService = Executors.newFixedThreadPool(1);
    executorService.execute(new IdleConnectionMonitorRunnable(poolingHttpClientConnectionManager));
}
项目:modules    文件:VerificationServiceImpl.java   
@Autowired
public VerificationServiceImpl(HttpClientBuilderFactory httpClientBuilderFactory) {
    this.config = RequestConfig.custom()
            .setConnectionRequestTimeout(TIMEOUT)
            .setConnectTimeout(TIMEOUT)
            .setSocketTimeout(TIMEOUT)
            .build();
    this.client = httpClientBuilderFactory.newBuilder().build();
}
项目:acs-aem-commons    文件:HttpClientFactoryImplTest.java   
@Before
public void setup() throws Exception {
    config = new HashMap<String, Object>();
    username = RandomStringUtils.randomAlphabetic(5);
    password = RandomStringUtils.randomAlphabetic(6);
    String authHeaderValue = Base64.encodeBase64String((username + ":" + password).getBytes());

    config.put("hostname", "localhost");
    config.put("port", mockServerRule.getPort().intValue());

    mockServerClient.when(
            request().withMethod("GET").withPath("/anon")
    ).respond(
            response().withStatusCode(200).withBody("OK")
    );
    mockServerClient.when(
            request().withMethod("GET").withPath("/anonJson")
    ).respond(
            response().withStatusCode(200).withBody("{ 'foo' : 'bar' }")
    );
    mockServerClient.when(
            request().withMethod("GET").withPath("/auth").
                    withHeader("Authorization", "Basic " + authHeaderValue)
    ).respond(
            response().withStatusCode(200).withBody("OK")
    );
    impl = new HttpClientFactoryImpl();
    PrivateAccessor.setField(impl, "httpClientBuilderFactory", new HttpClientBuilderFactory() {
        @Override
        public HttpClientBuilder newBuilder() {
            return HttpClients.custom();
        }
    });
}
项目:modules    文件:AbstractFormDefinitionImportService.java   
@Autowired
public AbstractFormDefinitionImportService(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) {
    this.client = httpClientBuilderFactory.newBuilder().build();
    this.tasksService = tasksService;
    this.formDefinitionService = formDefinitionService;
}
项目:modules    文件:FormDefinitionImportServiceODK.java   
@Autowired
public FormDefinitionImportServiceODK(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) {
    super(httpClientBuilderFactory, tasksService, formDefinitionService);
}
项目:modules    文件:FormDefinitionImportServiceOna.java   
@Autowired
public FormDefinitionImportServiceOna(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) {
    super(httpClientBuilderFactory, tasksService, formDefinitionService);
}
项目:modules    文件:FormDefinitionImportServiceKobo.java   
@Autowired
public FormDefinitionImportServiceKobo(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) {
    super(httpClientBuilderFactory, tasksService, formDefinitionService);
    objectMapper = new ObjectMapper();
    type = objectMapper.getTypeFactory().constructCollectionType(List.class, KoboFormInfo.class);
}
项目:modules    文件:RapidProHttpClient.java   
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
public RapidProHttpClient(HttpClientBuilderFactory httpClientBuilderFactory, SettingsService settingsService) {
    this.client = httpClientBuilderFactory.newBuilder().build();
    this.settingsService = settingsService;
}