Search in sources :

Example 1 with ThreadLocalContextManager

use of com.atlassian.sal.api.executor.ThreadLocalContextManager in project staf by simpleworks-gmbh.

the class AsynchronousHttpClientFactory method createClient.

@SuppressWarnings("static-method")
public DisposableHttpClient createClient(final URI serverUri, final AuthenticationHandler authenticationHandler) {
    final HttpClientOptions options = new HttpClientOptions();
    @SuppressWarnings({ "rawtypes", "unchecked" }) final DefaultHttpClientFactory defaultHttpClientFactory = new DefaultHttpClientFactory(new NoOpEventPublisher(), new RestClientApplicationProperties(serverUri), new ThreadLocalContextManager() {

        @Override
        public Object getThreadLocalContext() {
            return null;
        }

        @Override
        public void setThreadLocalContext(final Object context) {
        // nothing to do.
        }

        @Override
        public void clearThreadLocalContext() {
        // nothing to do.
        }
    });
    final HttpClient httpClient = defaultHttpClientFactory.create(options);
    return new AtlassianHttpClientDecorator(httpClient, authenticationHandler) {

        @Override
        public void destroy() throws Exception {
            defaultHttpClientFactory.dispose(httpClient);
        }
    };
}
Also used : DefaultHttpClientFactory(com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory) HttpClient(com.atlassian.httpclient.api.HttpClient) ThreadLocalContextManager(com.atlassian.sal.api.executor.ThreadLocalContextManager) HttpClientOptions(com.atlassian.httpclient.api.factory.HttpClientOptions)

Example 2 with ThreadLocalContextManager

use of com.atlassian.sal.api.executor.ThreadLocalContextManager in project cx-flow by checkmarx-ltd.

the class CustomAsynchronousHttpClientFactory method createClientCustom.

@SuppressWarnings("unchecked")
public DisposableHttpClient createClientCustom(final URI serverUri, final AuthenticationHandler authenticationHandler, int socketTimeoutInMs) {
    final HttpClientOptions options = new HttpClientOptions();
    options.setSocketTimeout(socketTimeoutInMs, TimeUnit.MILLISECONDS);
    options.setRequestTimeout(socketTimeoutInMs, TimeUnit.MILLISECONDS);
    final DefaultHttpClientFactory defaultHttpClientFactory = new DefaultHttpClientFactory(new NoOpEventPublisher(), new RestClientApplicationProperties(serverUri), new ThreadLocalContextManager() {

        @Override
        public Object getThreadLocalContext() {
            return null;
        }

        @Override
        public void setThreadLocalContext(Object context) {
        }

        @Override
        public void clearThreadLocalContext() {
        }
    });
    final HttpClient httpClient = defaultHttpClientFactory.create(options);
    return new AtlassianHttpClientDecorator(httpClient, authenticationHandler) {

        @Override
        public void destroy() throws Exception {
            defaultHttpClientFactory.dispose(httpClient);
        }
    };
}
Also used : DefaultHttpClientFactory(com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory) HttpClient(com.atlassian.httpclient.api.HttpClient) ThreadLocalContextManager(com.atlassian.sal.api.executor.ThreadLocalContextManager) HttpClientOptions(com.atlassian.httpclient.api.factory.HttpClientOptions)

Example 3 with ThreadLocalContextManager

use of com.atlassian.sal.api.executor.ThreadLocalContextManager in project jira-plugin by jenkinsci.

the class JiraSite method createClient.

private static DisposableHttpClient createClient(final URI serverUri, final AuthenticationHandler authenticationHandler, HttpClientOptions options) {
    final DefaultHttpClientFactory defaultHttpClientFactory = new DefaultHttpClientFactory(new NoOpEventPublisher(), new RestClientApplicationProperties(serverUri), new ThreadLocalContextManager() {

        @Override
        public Object getThreadLocalContext() {
            return null;
        }

        @Override
        public void setThreadLocalContext(Object context) {
        }

        @Override
        public void clearThreadLocalContext() {
        }
    });
    final HttpClient httpClient = defaultHttpClientFactory.create(options);
    return new AtlassianHttpClientDecorator(httpClient, authenticationHandler) {

        @Override
        public void destroy() throws Exception {
            defaultHttpClientFactory.dispose(httpClient);
        }
    };
}
Also used : DefaultHttpClientFactory(com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory) HttpClient(com.atlassian.httpclient.api.HttpClient) DisposableHttpClient(com.atlassian.jira.rest.client.internal.async.DisposableHttpClient) ThreadLocalContextManager(com.atlassian.sal.api.executor.ThreadLocalContextManager) AtlassianHttpClientDecorator(com.atlassian.jira.rest.client.internal.async.AtlassianHttpClientDecorator)

Aggregations

DefaultHttpClientFactory (com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory)3 HttpClient (com.atlassian.httpclient.api.HttpClient)3 ThreadLocalContextManager (com.atlassian.sal.api.executor.ThreadLocalContextManager)3 HttpClientOptions (com.atlassian.httpclient.api.factory.HttpClientOptions)2 AtlassianHttpClientDecorator (com.atlassian.jira.rest.client.internal.async.AtlassianHttpClientDecorator)1 DisposableHttpClient (com.atlassian.jira.rest.client.internal.async.DisposableHttpClient)1