/** * {@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); }
@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)); }
@Autowired public VerificationServiceImpl(HttpClientBuilderFactory httpClientBuilderFactory) { this.config = RequestConfig.custom() .setConnectionRequestTimeout(TIMEOUT) .setConnectTimeout(TIMEOUT) .setSocketTimeout(TIMEOUT) .build(); this.client = httpClientBuilderFactory.newBuilder().build(); }
@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(); } }); }
@Autowired public AbstractFormDefinitionImportService(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) { this.client = httpClientBuilderFactory.newBuilder().build(); this.tasksService = tasksService; this.formDefinitionService = formDefinitionService; }
@Autowired public FormDefinitionImportServiceODK(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) { super(httpClientBuilderFactory, tasksService, formDefinitionService); }
@Autowired public FormDefinitionImportServiceOna(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) { super(httpClientBuilderFactory, tasksService, formDefinitionService); }
@Autowired public FormDefinitionImportServiceKobo(HttpClientBuilderFactory httpClientBuilderFactory, TasksService tasksService, FormDefinitionService formDefinitionService) { super(httpClientBuilderFactory, tasksService, formDefinitionService); objectMapper = new ObjectMapper(); type = objectMapper.getTypeFactory().constructCollectionType(List.class, KoboFormInfo.class); }
@SuppressWarnings("SpringJavaAutowiringInspection") @Autowired public RapidProHttpClient(HttpClientBuilderFactory httpClientBuilderFactory, SettingsService settingsService) { this.client = httpClientBuilderFactory.newBuilder().build(); this.settingsService = settingsService; }