All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.proofpoint.http.client.balancing.BalancingHttpClientBindingBuilder Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2015 Proofpoint, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.proofpoint.http.client.balancing;

import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.binder.LinkedBindingBuilder;
import com.proofpoint.http.client.HttpClient;
import com.proofpoint.http.client.HttpClientBinder.HttpClientBindingBuilder;
import com.proofpoint.http.client.HttpRequestFilter;

import java.lang.annotation.Annotation;
import java.util.Collection;

public class BalancingHttpClientBindingBuilder
{
    private final Binder binder;
    private final Key key;
    private final HttpClientBindingBuilder delegateBindingBuilder;

    public BalancingHttpClientBindingBuilder(Binder binder, Class annotationType, HttpClientBindingBuilder delegateBindingBuilder)
    {
        this(binder, Key.get(HttpClient.class, annotationType), delegateBindingBuilder);
    }

    public BalancingHttpClientBindingBuilder(Binder binder, Annotation annotation, HttpClientBindingBuilder delegateBindingBuilder)
    {
        this(binder, Key.get(HttpClient.class, annotation), delegateBindingBuilder);
    }

    private BalancingHttpClientBindingBuilder(Binder binder, Key key, HttpClientBindingBuilder delegateBindingBuilder)
    {
        this.binder = binder;
        this.key = key;
        this.delegateBindingBuilder = delegateBindingBuilder;
    }

    public BalancingHttpClientBindingBuilder withAlias(Class alias)
    {
        binder.bind(HttpClient.class).annotatedWith(alias).to(key);
        return this;
    }

    public BalancingHttpClientBindingBuilder withAlias(Annotation alias)
    {
        binder.bind(HttpClient.class).annotatedWith(alias).to(key);
        return this;
    }

    public BalancingHttpClientBindingBuilder withAliases(Collection> aliases)
    {
        for (Class alias : aliases) {
            binder.bind(HttpClient.class).annotatedWith(alias).to(key);
        }
        return this;
    }

    public LinkedBindingBuilder addFilterBinding()
    {
        return delegateBindingBuilder.addFilterBinding();
    }

    public BalancingHttpClientBindingBuilder withFilter(Class filterClass)
    {
        delegateBindingBuilder.withFilter(filterClass);
        return this;
    }

    /**
     * @deprecated No longer necessary.
     */
    @Deprecated
    @SuppressWarnings("deprecation")
    public BalancingHttpClientBindingBuilder withTracing()
    {
        delegateBindingBuilder.withTracing();
        return this;
    }

    public BalancingHttpClientBindingBuilder withoutTracing()
    {
        delegateBindingBuilder.withoutTracing();
        return this;
    }

    /**
     * @deprecated No longer necessary.
     */
    @Deprecated
    public BalancingHttpClientBindingBuilder withPrivateIoThreadPool()
    {
        return this;
    }

    public BalancingHttpClientBindingBuilder withoutCertificateVerification() {
        delegateBindingBuilder.withoutCertificateVerification();
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy