本文整理汇总了Java中org.apache.http.conn.DnsResolver类的典型用法代码示例。如果您正苦于以下问题:Java DnsResolver类的具体用法?Java DnsResolver怎么用?Java DnsResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DnsResolver类属于org.apache.http.conn包,在下文中一共展示了DnsResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultClientConnectionOperator
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
/**
* Creates a new client connection operator for the given scheme registry
* and the given custom DNS lookup mechanism.
*
* @param schemes
* the scheme registry
* @param dnsResolver
* the custom DNS lookup mechanism
*/
public DefaultClientConnectionOperator(final SchemeRegistry schemes,final DnsResolver dnsResolver) {
if (schemes == null) {
throw new IllegalArgumentException(
"Scheme registry may not be null");
}
if(dnsResolver == null){
throw new IllegalArgumentException("DNS resolver may not be null");
}
this.schemeRegistry = schemes;
this.dnsResolver = dnsResolver;
}
示例2: PoolingClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
final long timeToLive, final TimeUnit tunit,
final DnsResolver dnsResolver) {
super();
if (schemeRegistry == null) {
throw new IllegalArgumentException("Scheme registry may not be null");
}
if (dnsResolver == null) {
throw new IllegalArgumentException("DNS resolver may not be null");
}
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
this.pool = new HttpConnPool(this.log, 2, 20, timeToLive, tunit);
}
示例3: setUp
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
reactor = new NioReactor();
crusher = TcpCrusherBuilder.builder()
.withReactor(reactor)
.withBindAddress("127.0.0.1", CRUSHER_PORT)
.withConnectAddress(REMOTE_HOST, REMOTE_PORT)
.buildAndOpen();
DnsResolver dnsResolver = new SystemDefaultDnsResolver() {
@Override
public InetAddress[] resolve(final String host) throws UnknownHostException {
if (host.equalsIgnoreCase(REMOTE_HOST)) {
return new InetAddress[] { InetAddress.getByAddress(new byte[] {127, 0, 0, 1}) };
} else {
return super.resolve(host);
}
}
};
HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> httpConnectionFactory =
new ManagedHttpClientConnectionFactory();
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.build();
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(
socketFactoryRegistry, httpConnectionFactory, dnsResolver);
http = HttpClients.createMinimal(connectionManager);
}
示例4: HttpClientConnectionOperator
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
HttpClientConnectionOperator(
final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver) {
super();
Args.notNull(socketFactoryRegistry, "Socket factory registry");
this.socketFactoryRegistry = socketFactoryRegistry;
this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
DefaultSchemePortResolver.INSTANCE;
this.dnsResolver = dnsResolver != null ? dnsResolver :
SystemDefaultDnsResolver.INSTANCE;
}
示例5: BasicHttpClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public BasicHttpClientConnectionManager(
final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver) {
super();
this.connectionOperator = new HttpClientConnectionOperator(
socketFactoryRegistry, schemePortResolver, dnsResolver);
this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
this.expiry = Long.MAX_VALUE;
this.socketConfig = SocketConfig.DEFAULT;
this.connConfig = ConnectionConfig.DEFAULT;
this.isShutdown = new AtomicBoolean(false);
}
示例6: PoolingHttpClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public PoolingHttpClientConnectionManager(
final Registry<ConnectionSocketFactory> socketFactoryRegistry,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
final long timeToLive, final TimeUnit tunit) {
super();
this.configData = new ConfigData();
this.pool = new CPool(
new InternalConnectionFactory(this.configData, connFactory), 2, 20, timeToLive, tunit);
this.connectionOperator = new HttpClientConnectionOperator(
socketFactoryRegistry, schemePortResolver, dnsResolver);
this.isShutDown = new AtomicBoolean(false);
}
示例7: setupProxying
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
@BeforeClass
public static void setupProxying() {
DnsResolver dnsResolver = prepareProxiedDnsResolver();
DefaultSchemePortResolver schemePortResolver = prepareSchemePortResolver();
BasicHttpClientConnectionManager connManager = prepareConnectionManager(dnsResolver, schemePortResolver);
HttpClient httpClient = prepareHttpClient(connManager);
originalHttpClient = (HttpClient) Options.getOption(Option.HTTPCLIENT);
Unirest.setHttpClient(httpClient);
}
示例8: prepareConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
private static BasicHttpClientConnectionManager prepareConnectionManager(DnsResolver dnsResolver, DefaultSchemePortResolver schemePortResolver) {
return new BasicHttpClientConnectionManager(
RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", SSLConnectionSocketFactory.getSocketFactory())
.build(),
null,
schemePortResolver,
dnsResolver
);
}
示例9: prepareProxiedDnsResolver
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
private static DnsResolver prepareProxiedDnsResolver() {
return new SystemDefaultDnsResolver() {
@Override
public InetAddress[] resolve(String host) throws UnknownHostException {
if (host.equalsIgnoreCase("sushi-shop.test")) {
return new InetAddress[]{InetAddress.getByName("127.0.0.1")};
} else {
return super.resolve(host);
}
}
};
}
示例10: JMeterPoolingClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public JMeterPoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
final long timeToLive, final TimeUnit tunit,
final DnsResolver dnsResolver,
int validateAfterInactivity) {
super();
Args.notNull(schemeRegistry, "Scheme registry");
Args.notNull(dnsResolver, "DNS resolver");
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
pool.setValidateAfterInactivity(validateAfterInactivity);
}
示例11: PoolingClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
final long timeToLive, final TimeUnit tunit,
final DnsResolver dnsResolver) {
super();
Args.notNull(schemeRegistry, "Scheme registry");
Args.notNull(dnsResolver, "DNS resolver");
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
}
示例12: BasicHttpClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public BasicHttpClientConnectionManager(
final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver) {
this(
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
connFactory
);
}
示例13: PoolingHttpClientConnectionManager
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public PoolingHttpClientConnectionManager(
final Registry<ConnectionSocketFactory> socketFactoryRegistry,
final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
final long timeToLive, final TimeUnit tunit) {
this(
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
connFactory,
timeToLive, tunit
);
}
示例14: DefaultHttpClientConnectionOperator
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
public DefaultHttpClientConnectionOperator(
final Lookup<ConnectionSocketFactory> socketFactoryRegistry,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver) {
super();
Args.notNull(socketFactoryRegistry, "Socket factory registry");
this.socketFactoryRegistry = socketFactoryRegistry;
this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
DefaultSchemePortResolver.INSTANCE;
this.dnsResolver = dnsResolver != null ? dnsResolver :
SystemDefaultDnsResolver.INSTANCE;
}
示例15: setup
import org.apache.http.conn.DnsResolver; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
conn = Mockito.mock(ManagedHttpClientConnection.class);
socket = Mockito.mock(Socket.class);
plainSocketFactory = Mockito.mock(ConnectionSocketFactory.class);
sslSocketFactory = Mockito.mock(LayeredConnectionSocketFactory.class);
socketFactoryRegistry = Mockito.mock(Lookup.class);
schemePortResolver = Mockito.mock(SchemePortResolver.class);
dnsResolver = Mockito.mock(DnsResolver.class);
connectionOperator = new DefaultHttpClientConnectionOperator(
socketFactoryRegistry, schemePortResolver, dnsResolver);
}