本文整理汇总了Java中org.apache.http.conn.scheme.SchemeSocketFactory类的典型用法代码示例。如果您正苦于以下问题:Java SchemeSocketFactory类的具体用法?Java SchemeSocketFactory怎么用?Java SchemeSocketFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SchemeSocketFactory类属于org.apache.http.conn.scheme包,在下文中一共展示了SchemeSocketFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getKeyStore
import org.apache.http.conn.scheme.SchemeSocketFactory; //导入依赖的package包/类
public KeyStore getKeyStore(){
SchemeRegistry registry = httpClient4.getConnectionManager().getSchemeRegistry();
if(! registry.getSchemeNames().contains("https")){
throw new IllegalStateException("Registry does not include an 'https' entry.");
}
SchemeSocketFactory awareSocketFactory = httpClient4.getConnectionManager().getSchemeRegistry().getScheme("https").getSchemeSocketFactory();
if(awareSocketFactory instanceof KeyStoreAwareSocketFactory){
return ((KeyStoreAwareSocketFactory) awareSocketFactory).getKeyStore();
}else{
throw new IllegalStateException("Cannot extract keystore from scheme socket factory of type: " + awareSocketFactory.getClass().getName());
}
}
示例2: DxHttpClient
import org.apache.http.conn.scheme.SchemeSocketFactory; //导入依赖的package包/类
/**
* Creates the http client using a thread safe {@code PoolingClientConnectionManager}
*
* See http://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/connmgmt.html#d5e581
*
* @authors Paolo Di Tommaso <[email protected]>
*
* @return
*/
protected DxHttpClient() {
log.debug("Creating DxHttpClient object");
try {
DxEnv env = DxEnv.getInstance();
securityContext = env.getSecurityContext();
apiserver = env.getApiserverPath();
final String PROT = env.getApiserverProtocol();
final String HOST = env.getApiserverHost();
final int PORT = env.getApiserverPort();
SchemeRegistry schemeRegistry = new SchemeRegistry();
SchemeSocketFactory factory = "https".equals(PROT) ? SSLSocketFactory.getSocketFactory() : PlainSocketFactory.getSocketFactory();
schemeRegistry.register(new Scheme(PROT, PORT, factory));
PoolingClientConnectionManager manager = new PoolingClientConnectionManager(schemeRegistry);
manager.setMaxTotal(100);
manager.setDefaultMaxPerRoute(10);
manager.setMaxPerRoute(new HttpRoute(new HttpHost(HOST, PORT)), 50);
httpclient = new DefaultHttpClient(manager);
}
catch( IOException e ) {
throw new IllegalStateException(e);
}
}