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


Java SchemeRegistryFactory.createDefault方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: createClient

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入方法依赖的package包/类
private static HttpClient createClient() {
    ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                                    DEFAULT_CONNECTION_MANAGER_TIMEOUT,
                                                                                    TimeUnit.MILLISECONDS);

    DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);

    HttpParams clientParams = httpClient.getParams();

    HttpConnectionParams.setSocketBufferSize(clientParams, 60000);
    HttpConnectionParams.setTcpNoDelay(clientParams, false);
    HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
    HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
    // HostConfiguration hostConfig = new HostConfiguration();
    // hostConfig.setHost("localhost");

    HttpConnectionParams.setConnectionTimeout(clientParams, DEFAULT_CONNECTION_MANAGER_TIMEOUT);
    HttpConnectionParams.setSoTimeout(clientParams, 500);
    httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
    HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

    connectionManager.setMaxTotal(DEFAULT_MAX_CONNECTIONS);
    connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_HOST_CONNECTIONS);
    HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

    return httpClient;
}
 
开发者ID:we7,项目名称:voldemort,代码行数:28,代码来源:HttpClientBench.java

示例13: PoolingClientConnectionManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入方法依赖的package包/类
public PoolingClientConnectionManager() {
    this(SchemeRegistryFactory.createDefault());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:4,代码来源:PoolingClientConnectionManager.java

示例14: ThreadSafeClientConnManager

import org.apache.http.impl.conn.SchemeRegistryFactory; //导入方法依赖的package包/类
/**
 * @since 4.1
 */
public ThreadSafeClientConnManager() {
    this(SchemeRegistryFactory.createDefault());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:ThreadSafeClientConnManager.java


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