当前位置: 首页>>代码示例>>Java>>正文


Java SchemeRegistryFactory类代码示例

本文整理汇总了Java中org.apache.http.impl.conn.SchemeRegistryFactory的典型用法代码示例。如果您正苦于以下问题:Java SchemeRegistryFactory类的具体用法?Java SchemeRegistryFactory怎么用?Java SchemeRegistryFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchemeRegistryFactory类属于org.apache.http.impl.conn包,在下文中一共展示了SchemeRegistryFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: UpdateShardHandler

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public UpdateShardHandler(ConfigSolr cfg) {
  
  clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
  if (cfg != null ) {
    clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
    clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
  }
  
  
  ModifiableSolrParams params = new ModifiableSolrParams();
  if (cfg != null) {
    params.set(HttpClientUtil.PROP_SO_TIMEOUT,
        cfg.getDistributedSocketTimeout());
    params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
        cfg.getDistributedConnectionTimeout());
  }
  // in the update case, we want to do retries, and to use
  // the default Solr retry handler that createClient will 
  // give us
  params.set(HttpClientUtil.PROP_USE_RETRY, true);
  log.info("Creating UpdateShardHandler HTTP client with params: {}", params);
  client = HttpClientUtil.createClient(params, clientConnectionManager);
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:UpdateShardHandler.java

示例2: createProxyClient

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
 * create a proxy client
 * 
 * @return either a client or null if none is configured
 * @throws KeyManagementException
 * @throws NumberFormatException
 *           if that port could not be parsed.
 * @throws NoSuchAlgorithmException
 */
private static HttpClient createProxyClient(PlayProfile profile)
		throws KeyManagementException, NoSuchAlgorithmException {
	if (profile.getProxyAddress() == null) {
		return null;
	}

	PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
			SchemeRegistryFactory.createDefault());
	connManager.setMaxTotal(100);
	connManager.setDefaultMaxPerRoute(30);

	DefaultHttpClient client = new DefaultHttpClient(connManager);
	client.getConnectionManager().getSchemeRegistry()
			.register(Utils.getMockedScheme());
	HttpHost proxy = new HttpHost(profile.getProxyAddress(),
			profile.getProxyPort());
	client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
	if (profile.getProxyUser() != null && profile.getProxyPassword() != null) {
		client.getCredentialsProvider().setCredentials(
				new AuthScope(proxy),
				new UsernamePasswordCredentials(profile.getProxyUser(), profile
						.getProxyPassword()));
	}
	return client;
}
 
开发者ID:onyxbits,项目名称:raccoon4,代码行数:35,代码来源:PlayManager.java

示例3: ClientBuilder

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public ClientBuilder() {
  enableGZip = true;
  name = "hosebird-client-" + clientNum.getAndIncrement();
  ThreadFactory threadFactory = new ThreadFactoryBuilder()
          .setDaemon(true)
          .setNameFormat("hosebird-client-io-thread-%d")
          .build();
  executorService = Executors.newSingleThreadExecutor(threadFactory);

  ThreadFactory rateTrackerThreadFactory = new ThreadFactoryBuilder()
          .setDaemon(true)
          .setNameFormat("hosebird-client-rateTracker-thread-%d")
          .build();

  ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1, rateTrackerThreadFactory);
  rateTracker = new BasicRateTracker(30000, 100, true, scheduledExecutor);
  reconnectionManager = new BasicReconnectionManager(5);

  socketTimeoutMillis = 60000;
  connectionTimeoutMillis = 4000;

  schemeRegistry = SchemeRegistryFactory.createDefault();
}
 
开发者ID:twitter,项目名称:hbc,代码行数:24,代码来源:ClientBuilder.java

示例4: HttpStoreClientFactory

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public HttpStoreClientFactory(ClientConfig config) {
    super(config);
    ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                      config.getConnectionTimeout(TimeUnit.MILLISECONDS),
                                                                      TimeUnit.MILLISECONDS);
    mgr.setMaxTotal(config.getMaxTotalConnections());
    mgr.setDefaultMaxPerRoute(config.getMaxConnectionsPerNode());

    this.httpClient = new DefaultHttpClient(mgr);
    HttpParams clientParams = this.httpClient.getParams();

    HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
    HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);

    HttpConnectionParams.setConnectionTimeout(clientParams,
                                              config.getConnectionTimeout(TimeUnit.MILLISECONDS));
    HttpConnectionParams.setSoTimeout(clientParams,
                                      config.getSocketTimeout(TimeUnit.MILLISECONDS));
    HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

    this.httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
    HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

    this.reroute = config.getRoutingTier().equals(RoutingTier.SERVER);
    this.requestFormatFactory = new RequestFormatFactory();
}
 
开发者ID:we7,项目名称:voldemort,代码行数:27,代码来源:HttpStoreClientFactory.java

示例5: setUp

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();
    Cluster cluster = ServerTestUtils.getLocalCluster(1);
    Node node = cluster.getNodes().iterator().next();
    context = ServerTestUtils.getJettyServer(new ClusterMapper().writeCluster(cluster),
                                             VoldemortTestConstants.getSimpleStoreDefinitionsXml(),
                                             "users",
                                             RequestFormatType.VOLDEMORT_V1,
                                             node.getHttpPort());
    server = context.getServer();

    ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                                    5000,
                                                                                    TimeUnit.MILLISECONDS);
    httpClient = new DefaultHttpClient(connectionManager);
    httpStore = ServerTestUtils.getHttpStore("users",
                                             RequestFormatType.VOLDEMORT_V1,
                                             node.getHttpPort(),
                                             httpClient);
}
 
开发者ID:we7,项目名称:voldemort,代码行数:22,代码来源:HttpStoreTest.java

示例6: createClientConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
protected ClientConnectionManager createClientConnectionManager() {
    PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
            SchemeRegistryFactory.createSystemDefault());
    String s = System.getProperty("http.keepAlive");
    if ("true".equalsIgnoreCase(s)) {
        s = System.getProperty("http.maxConnections", "5");
        int max = Integer.parseInt(s);
        connmgr.setDefaultMaxPerRoute(max);
        connmgr.setMaxTotal(2 * max);
    }
    return connmgr;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SystemDefaultHttpClient.java

示例7: getPoolingClientConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public PoolingClientConnectionManager getPoolingClientConnectionManager(
    NaviHttpPoolConfig poolConfig) {
    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(
        SchemeRegistryFactory.createDefault(), poolConfig.getTimeToLive(), TimeUnit.MILLISECONDS
    );

    // timeToLive maximum time to live. May be zero if the connection does
    // not have an expiry deadline.
    connectionManager.setDefaultMaxPerRoute(poolConfig.getMaxPerRoute()); // 默认每个通道最高2个链接
    connectionManager.setMaxTotal(poolConfig.getMaxActive()); // 默认最大20,现改成MaxActive可配,默认是8
    return connectionManager;
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:13,代码来源:NaviHttpClientDriver.java

示例8: getHttpClient

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
protected HttpClient getHttpClient() {
    if (httpClient == null) {
        httpClient = new DefaultHttpClient(
            new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault(), 3000, TimeUnit.MILLISECONDS)
        );
    }
    return httpClient;
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:9,代码来源:NaviAPITestCase.java

示例9: createClientConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Override
protected ClientConnectionManager createClientConnectionManager() {
    final PoolingClientConnectionManager connmgr = new PoolingClientConnectionManager(
            SchemeRegistryFactory.createSystemDefault());
    String s = System.getProperty("http.keepAlive", "true");
    if ("true".equalsIgnoreCase(s)) {
        s = System.getProperty("http.maxConnections", "5");
        final int max = Integer.parseInt(s);
        connmgr.setDefaultMaxPerRoute(max);
        connmgr.setMaxTotal(2 * max);
    }
    return connmgr;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:SystemDefaultHttpClient.java

示例10: getConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
 * Connection manager to allow concurrent connections.
 *
 * @return {@link ClientConnectionManager} instance
 */
public static ClientConnectionManager getConnectionManager() {
	PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
			SchemeRegistryFactory.createDefault());
	connManager.setMaxTotal(100);
	connManager.setDefaultMaxPerRoute(30);
	return connManager;
}
 
开发者ID:onyxbits,项目名称:dummydroid,代码行数:13,代码来源:GooglePlayAPI.java

示例11: getConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
 * Connection manager to allow concurrent connections.
 * 
 * @return {@link ClientConnectionManager} instance
 */
public static ClientConnectionManager getConnectionManager() {
	PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
			SchemeRegistryFactory.createDefault());
	connManager.setMaxTotal(100);
	connManager.setDefaultMaxPerRoute(30);
	return connManager;
}
 
开发者ID:onyxbits,项目名称:raccoon4,代码行数:13,代码来源:GooglePlayAPI.java

示例12: getHttpClient

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
 * 
 * @param isMultiRequest
 *            是否支持多线程
 * @param connectionTimeout
 *            建立连接超时时间(毫秒)
 * @param socketTimeout
 *            等待数据超时时间(毫秒)
 * @return
 */
public static HttpClient getHttpClient(boolean isMultiRequest,
		int connectionTimeout, int socketTimeout) {
	SchemeRegistry schemeRegistry = SchemeRegistryFactory.createDefault();
	ClientConnectionManager cm = isMultiRequest ? new PoolingClientConnectionManager(
			schemeRegistry) : new BasicClientConnectionManager(
			schemeRegistry);
	HttpParams params = isMultiRequest ? new SyncBasicHttpParams()
			: new BasicHttpParams();
	HttpClientParams.setCookiePolicy(params,
			CookiePolicy.BROWSER_COMPATIBILITY);
	HttpConnectionParams.setConnectionTimeout(params, connectionTimeout);
	HttpConnectionParams.setSoTimeout(params, socketTimeout);
	return new DefaultHttpClient(cm, params);
}
 
开发者ID:holymonk,项目名称:just-for-fun,代码行数:25,代码来源:HttpClientFactory.java

示例13: getProxyClient

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
/**
 * Get a proxy client, if it is configured.
 * 
 * @return either a client or null
 * @throws IOException
 *           if reading the config file fails
 * @throws KeyManagementException
 * @throws NumberFormatException
 *           if that port could not be parsed.
 * @throws NoSuchAlgorithmException
 */
public HttpClient getProxyClient() throws IOException, KeyManagementException,
		NoSuchAlgorithmException, NumberFormatException {
	File cfgfile = new File(root, NETCFG);
	if (cfgfile.exists()) {
		Properties cfg = new Properties();
		cfg.load(new FileInputStream(cfgfile));
		String ph = cfg.getProperty(PROXYHOST, null);
		String pp = cfg.getProperty(PROXYPORT, null);
		String pu = cfg.getProperty(PROXYUSER, null);
		String pw = cfg.getProperty(PROXYPASS, null);
		if (ph == null || pp == null) {
			return null;
		}
		PoolingClientConnectionManager connManager = new PoolingClientConnectionManager(
				SchemeRegistryFactory.createDefault());
		connManager.setMaxTotal(100);
		connManager.setDefaultMaxPerRoute(30);

		DefaultHttpClient client = new DefaultHttpClient(connManager);
		client.getConnectionManager().getSchemeRegistry().register(Utils.getMockedScheme());
		HttpHost proxy = new HttpHost(ph, Integer.parseInt(pp));
		client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
		if (pu != null && pw != null) {
			client.getCredentialsProvider().setCredentials(new AuthScope(proxy),
					new UsernamePasswordCredentials(pu, pw));
		}
		return client;
	}
	return null;
}
 
开发者ID:onyxbits,项目名称:Raccoon,代码行数:42,代码来源:Archive.java

示例14: UpdateShardHandler

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
public UpdateShardHandler(ConfigSolr cfg) {
  
  clientConnectionManager = new PoolingClientConnectionManager(SchemeRegistryFactory.createSystemDefault());
  clientConnectionManager.setMaxTotal(cfg.getMaxUpdateConnections());
  clientConnectionManager.setDefaultMaxPerRoute(cfg.getMaxUpdateConnectionsPerHost());
  
  
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(HttpClientUtil.PROP_SO_TIMEOUT, cfg.getDistributedSocketTimeout());
  params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, cfg.getDistributedConnectionTimeout());
  params.set(HttpClientUtil.PROP_USE_RETRY, false);
  client = HttpClientUtil.createClient(params, clientConnectionManager);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:14,代码来源:UpdateShardHandler.java

示例15: setup

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  mockAuth = mock(Authentication.class);
  mockParams = mock(HttpParams.class);
  defaultSchemeRegistry = SchemeRegistryFactory.createDefault();
  request = new HttpGet("http://hi");
}
 
开发者ID:twitter,项目名称:hbc,代码行数:8,代码来源:RestartableHttpClientTest.java


注:本文中的org.apache.http.impl.conn.SchemeRegistryFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。