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


Java DnsResolver类代码示例

本文整理汇总了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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:DefaultClientConnectionOperator.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:PoolingClientConnectionManager.java

示例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);
}
 
开发者ID:NetCrusherOrg,项目名称:netcrusher-java,代码行数:34,代码来源:HttpClientTest.java

示例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;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:13,代码来源:HttpClientConnectionOperator.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:BasicHttpClientConnectionManager.java

示例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);
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:PoolingHttpClientConnectionManager.java

示例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);
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:10,代码来源:TestWithProxiedEmbeddedServer.java

示例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
    );
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:12,代码来源:TestWithProxiedEmbeddedServer.java

示例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);
            }
        }
    };
}
 
开发者ID:bastion-dev,项目名称:Bastion,代码行数:13,代码来源:TestWithProxiedEmbeddedServer.java

示例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);
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:14,代码来源:JMeterPoolingClientConnectionManager.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:12,代码来源:PoolingClientConnectionManager.java

示例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
  );
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:BasicHttpClientConnectionManager.java

示例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
    );
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:PoolingHttpClientConnectionManager.java

示例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;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:13,代码来源:DefaultHttpClientConnectionOperator.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:TestHttpClientConnectionOperator.java


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