Register a HttpClientObserver which observes only requests from a HttpClient with the given Guice binding annotation.
@return the binding builder you should register with
429591
public static LinkedBindingBuilder<HttpClientObserver> bindNewObserver(final Binder binder, final Annotation annotation)
    {
        return Multibinder.newSetBinder(binder, HttpClientObserver.class, annotation).addBinding();
    }
1355677
private void setupProxyIfNeeded(HttpClientBuilder builder) {
        if (httpProxy != null) {
            builder.setProxy(new HttpHost(httpProxy.getHost(),httpProxy.getPort()));
            if (httpProxy.getUser() != null) {
                AuthScope proxyAuthScope = new AuthScope(httpProxy.getHost(),httpProxy.getPort());
                UsernamePasswordCredentials proxyCredentials = new UsernamePasswordCredentials(httpProxy.getUser(),httpProxy.getPass());
                CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
                credentialsProvider.setCredentials(proxyAuthScope,proxyCredentials);
                builder.setDefaultCredentialsProvider(credentialsProvider);
            }
        }
    }
369004
public <T> HttpClientRequest.Builder<T> options(final URI uri, final HttpClientResponseHandler<T> httpHandler)
    {
        return new HttpClientRequest.Builder<T>(httpClientFactory, HttpClientMethod.OPTIONS, uri, httpHandler);
    }
290567
public static LinkedBindingBuilder<Servlet> bindCatchallServlet(final Binder binder)
    {
        return binder.bind (Servlet.class).annotatedWith(CATCHALL_NAMED);
    }
123000
@Override
	public synchronized void registerObserver(SubjectObserver<Settings> settingsObserver)
	{
		if (settingsObserver == null)
			throw new IllegalArgumentException("settingsObserver is required");
		
		if(file != null)
		{
			if(fileMonitor == null)
				fileMonitor = new FileMonitor();				
			
			fileMonitor.monitor(file.getParent(), file.getName(), false);
			//Observer fileEventBridge = (observable,o) -> {this.reLoad();};
			//fileMonitor.addObserver(fileEventBridge);
			fileMonitor.add((observable,o) -> this.reLoad());
		}
		
		registry.register(getClass().getName(), settingsObserver);
	}
1296251
public static ILoadBalancer registerNamedLoadBalancerFromclientConfig(String name, IClientConfig clientConfig) throws ClientException {
        if (namedLBMap.get(name) != null) {
            throw new ClientException("LoadBalancer for name " + name + " already exists");
        }
    	ILoadBalancer lb = null;
        try {
            String loadBalancerClassName = clientConfig.getOrDefault(CommonClientConfigKey.NFLoadBalancerClassName);
            lb = (ILoadBalancer) ClientFactory.instantiateInstanceWithClientConfig(loadBalancerClassName, clientConfig);                                    
            namedLBMap.put(name, lb);            
            logger.info("Client: {} instantiated a LoadBalancer: {}", name, lb);
            return lb;
        } catch (Throwable e) {           
           throw new ClientException("Unable to instantiate/associate LoadBalancer with Client:" + name, e);
        }    	
    }
746831
public static TcpClient<ByteBuf, ByteBuf> newClient(ConnectionProviderFactory<ByteBuf, ByteBuf> providerFactory,
                                                        Observable<Host> hostStream) {
        return TcpClientImpl.create(providerFactory, hostStream);
    }
372488
public <T> HttpClientRequest.Builder<T> perform(final String methodName, final URI uri, final HttpClientResponseHandler<T> httpHandler) {
        final HttpClientMethod method;
        try {
            method = HttpClientMethod.valueOf(methodName.toUpperCase(Locale.ENGLISH));
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Unknown HTTP method type " + methodName, e);
        }

        return new HttpClientRequest.Builder<T>(httpClientFactory, method, uri, httpHandler);
    }
1286772
public static AnnotatedJacksonModule with(Class<? extends Annotation> clientBindingAnnotation) {
    if (clientBindingAnnotation == null) {
      throw new NullPointerException("clientBindingAnnotation:null");
    }

    BindingAnnotations.checkIsBindingAnnotation(clientBindingAnnotation);

    return new AnnotatedJacksonModule(clientBindingAnnotation);
  }
979817
public CloseableHttpClient createHttpClient(final Consumer<HttpClientBuilder> customiser)
	{
		final HttpClientBuilder builder = HttpClientBuilder.create();

		// By default set long call timeouts
		{
			RequestConfig.Builder requestBuilder = RequestConfig.custom();

			requestBuilder.setConnectTimeout((int) connectionTimeout.getMilliseconds())
			              .setSocketTimeout((int) socketTimeout.getMilliseconds());

			builder.setDefaultRequestConfig(requestBuilder.build());
		}

		// Set the default keepalive setting
		if (noKeepalive)
			builder.setConnectionReuseStrategy(new NoConnectionReuseStrategy());

		// By default share the common connection provider
		builder.setConnectionManager(connectionManager);

		// By default use the JRE default route planner for proxies
		builder.setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()));

		// Allow customisation
		if (customiser != null)
			customiser.accept(builder);

		return builder.build();
	}
427608
public function bindHttpClient()
    {
        $this->app->bind(HttpClient::class, function (Application $app) {
            $client = $app->make('ej:sdk:guzzle');
            $auth = $app->make(Authentication\Authenticator::class);

            return new HttpClient($client, $auth);
        });
    }
90392
public static Builder builder() {
    return new AutoValue_BeadledomClientConfiguration.Builder()
        .connectionPoolSize(DEFAULT_CONNECTION_POOL_SIZE)
        .maxPooledPerRouteSize(DEFAULT_MAX_POOLED_PER_ROUTE)
        .socketTimeoutMillis(DEFAULT_SOCKET_TIMEOUT_MILLIS)
        .connectionTimeoutMillis(DEFAULT_CONNECTION_TIMEOUT_MILLIS)
        .ttlMillis(DEFAULT_TTL_MILLIS);
  }
524167
@Override
  public BindingProvider createSoapClient(SoapServiceDescriptor soapServiceDescriptor)
      throws ServiceException {
    try {
      if (soapServiceDescriptor instanceof JaxWsCompatible) {
        JaxWsCompatible jaxWsCompatibleService = (JaxWsCompatible) soapServiceDescriptor;
        Object portLocator = jaxWsCompatibleService.getServiceClass()
            .getConstructor(new Class[0]).newInstance(new Object[0]);
        String interfaceClassName = soapServiceDescriptor.getInterfaceClass().getSimpleName();
        BindingProvider soapClient = (BindingProvider) portLocator.getClass()
            .getMethod("get" + interfaceClassName + "Port").invoke(portLocator);

        // Required for App Engine to avoid default 10s timeout for UrlFetch requests.
        setConnectTimeout(soapClient);

        @SuppressWarnings("rawtypes") // getHandlerChain returns a list of raw Handler.
        List<Handler> bindings = soapClient.getBinding().getHandlerChain();
        bindings.add(contextHandlerProvider.get());
        soapClient.getBinding().setHandlerChain(bindings);
        return soapClient;
      }
      throw new ServiceException(
          "Service [" + soapServiceDescriptor + "] is not compatible with JAX-WS", null);
    } catch (SecurityException e) {
      throw new ServiceException("Unexpected Exception.", e);
    } catch (NoSuchMethodException e) {
      throw new ServiceException("Unexpected Exception.", e);
    } catch (IllegalArgumentException e) {
      throw new ServiceException("Unexpected Exception.", e);
    } catch (IllegalAccessException e) {
      throw new ServiceException("Unexpected Exception.", e);
    } catch (InvocationTargetException e) {
      throw new ServiceException("Unexpected Exception.", e.getCause());
    } catch (ClassNotFoundException e) {
      throw new ServiceException("Unexpected Exception.", e);
    } catch (InstantiationException e) {
      throw new ServiceException("Unexpected Exception.", e);
    }
  }
1163047
public SofaResteasyClientBuilder registerProvider() {
        ResteasyProviderFactory providerFactory = getProviderFactory();
        // 注册内置
        Set<Class> internalProviderClasses = JAXRSProviderManager.getInternalProviderClasses();
        if (CommonUtils.isNotEmpty(internalProviderClasses)) {
            for (Class providerClass : internalProviderClasses) {
                providerFactory.register(providerClass);
            }
        }
        // 注册自定义
        Set<Object> customProviderInstances = JAXRSProviderManager.getCustomProviderInstances();
        if (CommonUtils.isNotEmpty(customProviderInstances)) {
            for (Object provider : customProviderInstances) {
                PropertyInjector propertyInjector = providerFactory.getInjectorFactory()
                    .createPropertyInjector(
                        JAXRSProviderManager.getTargetClass(provider), providerFactory);
                propertyInjector.inject(provider);
                providerFactory.registerProviderInstance(provider);
            }
        }

        return this;
    }
1155888
public JaversBuilder registerType(ClientsClassDefinition clientsClassDefinition) {
        argumentIsNotNull(clientsClassDefinition);
        clientsClassDefinitions.put(clientsClassDefinition.getBaseJavaClass(), clientsClassDefinition);
        return this;
    }
885173
public static CloseableHttpAsyncClient defaultClient() {
        RequestConfig requestConfig = RequestConfig.custom()
                .setConnectionRequestTimeout(0)
                .setConnectTimeout(10000)
                .setSocketTimeout(20000)
                .setCookieSpec(CookieSpecs.STANDARD)
                .build();
        HttpAsyncClientBuilder httpClientBuilder = HttpAsyncClients.custom();
        httpClientBuilder.setDefaultRequestConfig(requestConfig);

        CloseableHttpAsyncClient asyncHttpClient = httpClientBuilder.build();
        asyncHttpClient.start();
        return asyncHttpClient;
    }
530595
public HttpClient build() {
		HttpClient httpClient = new HttpClient();
		
		if (proxyHost != null) {
			ProxyHost h;
			if (proxyPort == -1) {
				h = new ProxyHost(proxyHost);
			} else {
				h = new ProxyHost(proxyHost, proxyPort);
			}
			httpClient.getHostConfiguration().setProxyHost(h);
		}

		if (basicAuthUsername != null) {
			httpClient.getParams().setAuthenticationPreemptive(authenticationPreemprive);
			AuthScope authscope = new AuthScope(
					basicAuthHost == null ? AuthScope.ANY_HOST : basicAuthHost,
					basicAuthPort == -1 ? AuthScope.ANY_PORT : basicAuthPort);
			Credentials credentials = new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword);
			httpClient.getState().setCredentials(authscope, credentials);
		}
		
		if (sslHostConfig != null) {
			sslHostConfigs.put(secureHost, sslHostConfig);
		}
		
		for (Entry<String, SslHostConfig> entry : sslHostConfigs.entrySet()) {
			String host = entry.getKey();
			SslHostConfig config = entry.getValue();
            AuthSSLProtocolSocketFactory factory = new AuthSSLProtocolSocketFactory(
					config.keyStoreUrl, config.keyStorePassword,
					config.trustKeyStoreUrl, config.trustKeyStorePassword);
            if (sslEnabledProtocols != null) {
                factory.setEnabledProtocols(sslEnabledProtocols);
            }
			Protocol protocol = createProtocol(factory, config);
			httpClient.getHostConfiguration().setHost(host, config.securePort, protocol);
		}

        httpClient.getParams().setSoTimeout(soTimeout);
        httpClient.getParams().setConnectionManagerTimeout(connectionManagerTimeout);
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);
		
		return httpClient;
	}