• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NetClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: disconnect

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
public void disconnect() {
    URI address = getAddress();
    if (isConnected()) {
        try {
            NetClient client = copyClient(); // Make a copy just before close
            m_client.close();
            m_client = client;
            setConnected(false);
            logger().debug("Disconnected from {}:{}",
                    address.getHost(), address.getPort());
        } catch (Exception e) {
            logger().error("Failed to disconnect from {}:{}",
                    address.getHost(), address.getPort(), e);
        }
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:18,代码来源:TcpConnection.java


示例2: newClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
private static NetClient newClient(final Builder builder) {
    NetClient client = builder.m_vertx.createNetClient();
    client.setConnectTimeout((int) builder.m_connectTimeout);
    client.setTCPKeepAlive(builder.m_keepAlive);
    client.setSSL(builder.m_sslEnabled);
    if (builder.m_reconnectAttempts > 0) {
        client.setReconnectAttempts(builder.m_reconnectAttempts);
    }
    if (builder.m_reconnectInterval > 0L) {
        client.setReconnectInterval(builder.m_reconnectInterval);
    }
    if (!Strings.isNullOrEmpty(builder.m_keystorePath)) {
        client.setKeyStorePath(builder.m_keystorePath);
    }
    if (!Strings.isNullOrEmpty(builder.m_keystorePassword)) {
        client.setKeyStorePassword(builder.m_keystorePassword);
    }
    if (!Strings.isNullOrEmpty(builder.m_truststorePath)) {
        client.setTrustStorePath(builder.m_truststorePath);
    }
    if (!Strings.isNullOrEmpty(builder.m_truststorePassword)) {
        client.setTrustStorePassword(builder.m_truststorePassword);
    }
    return client;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:26,代码来源:TcpConnection.java


示例3: connect

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
void connect(Handler<Transaction> aConnectionHandler) {
	connectionHandler = aConnectionHandler;
	NetClient client = pg.vertx.createNetClient();
	// client.setReceiveBufferSize(1024);
	client.connect(pg.port, pg.host, new AsyncResultHandler<NetSocket>() {
		@Override
		public void handle(AsyncResult<NetSocket> event) {
			if (event.succeeded()) {
				socket = event.result();
				socket.dataHandler(new Handler<Buffer>() {
					@Override
					public void handle(Buffer buffer) {
						mp.parseMessages(buffer,0,buffer.length());
					}
				});
				socket.write(new Startup(new Buffer(20)).write(pg.user, pg.db, pg.applicationName + "-" + this.hashCode()));
			} else {
				connectionHandler.handle(null);
			}
		}
	});
}
 
开发者ID:monoid-us,项目名称:vertx-postgresql,代码行数:23,代码来源:Transaction.java


示例4: createClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
/**
 * Creates a new client for the given URL and handler
 */
protected NetClient createClient(NetSocket socket, URI url, Handler<AsyncResult<NetSocket>> handler) throws MalformedURLException {
    NetClient client = vertx.createNetClient();
    int port = url.getPort();
    String host = url.getHost();
    LOG.info("Connecting " + socket.remoteAddress() + " to host " + host + " port " + port + " protocol " + protocol);
    return client.connect(port, host, handler);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:11,代码来源:TcpGatewayHandler.java


示例5: copyClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
protected NetClient copyClient() {
    return builder(getAddress(), m_vertx)
            .connectTimeout(getConnectTimeout())
            .reconnectAttempts(m_client.getReconnectAttempts())
            .reconnectInterval(m_client.getReconnectInterval())
            .keepAlive(m_client.isTCPKeepAlive())
            .sslEnabled(m_client.isSSL())
            .keystorePath(m_client.getKeyStorePath())
            .keystorePassword(m_client.getKeyStorePassword())
            .truststorePath(m_client.getTrustStorePath())
            .truststorePassword(m_client.getTrustStorePassword())
            .buildClient();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:15,代码来源:TcpConnection.java


示例6: configureNetClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
/**
 * Allows a subclass to configure the NetClient beyond what this transport might do.
 *
 * @throws IOException if an error occurs.
 */
protected void configureNetClient(NetClient client) throws IOException {
    client.setSendBufferSize(getSocketBufferSize());
    client.setReceiveBufferSize(getSocketBufferSize());
    client.setSoLinger(soLinger);
    client.setTCPKeepAlive(keepAlive);
    client.setTCPNoDelay(tcpNoDelay);
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:13,代码来源:TcpTransport.java


示例7: configureNetClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
protected void configureNetClient(NetClient client) throws IOException {
    super.configureNetClient(client);

    client.setSSL(true);
    client.setKeyStorePath(context.getKeyStoreLocation());
    client.setKeyStorePassword(context.getKeyStorePassword());
    client.setTrustStorePath(context.getTrustStoreLocation());
    client.setTrustStorePassword(context.getTrustStorePassword());
}
 
开发者ID:fusesource,项目名称:hawtjms,代码行数:11,代码来源:SslTransport.java


示例8: route

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
public void route(final SocketWrapper socket, ConnectionParameters params, final Buffer received) {
    NetClient client = null;

    if( params.protocolVirtualHost==null ) {
        params.protocolVirtualHost = defaultVirtualHost;
    }
    HashSet<String> schemes = new HashSet<String>(Arrays.asList(params.protocolSchemes));
    if(params.protocolVirtualHost!=null) {
        List<ServiceDetails> services = serviceMap.getServices(params.protocolVirtualHost);

        // Lets try again with the defaultVirtualHost
        if( services.isEmpty() && !params.protocolVirtualHost.equals(defaultVirtualHost) ) {
            params.protocolVirtualHost = defaultVirtualHost;
            services = serviceMap.getServices(params.protocolVirtualHost);
        }

        if (LOG.isDebugEnabled()) LOG.debug(String.format("%d services match the virtual host", services.size()));
        if (!services.isEmpty()) {
            ClientRequestFacade clientRequestFacade = clientRequestFacadeFactory.create(socket, params);
            ServiceDetails serviceDetails = serviceLoadBalancer.choose(services, clientRequestFacade);
            if (serviceDetails != null) {
                List<String> urlStrings = serviceDetails.getServices();
                if (LOG.isDebugEnabled()) LOG.debug("Selected service exposes the following URLS: {}", urlStrings);
                for (String urlString : urlStrings) {
                    if (StringUtils.isNotEmpty(urlString)) {
                        // lets create a client for this request...
                        try {
                            URI uri = new URI(urlString);
                            //URL url = new URL(urlString);
                            String urlProtocol = uri.getScheme();
                            if (schemes.contains(urlProtocol)) {
                                if( !socket.remoteAddress().toString().equals(clientRequestFacade.getClientRequestKey())  ) {
                                    LOG.info(String.format("Connecting client from '%s' (with key '%s') requesting virtual host '%s' to '%s:%d' using the %s protocol",
                                        socket.remoteAddress(), clientRequestFacade.getClientRequestKey(), params.protocolVirtualHost, uri.getHost(), uri.getPort(), params.protocol
                                      ));
                                } else {
                                    LOG.info(String.format("Connecting client from '%s' requesting virtual host '%s' to '%s:%d' using the %s protocol",
                                        socket.remoteAddress(), params.protocolVirtualHost, uri.getHost(), uri.getPort(), params.protocol
                                      ));
                                }

                                client = createClient(params, socket, uri, received);
                                break;
                            }
                        } catch (URISyntaxException e) {
                            LOG.warn("Failed to parse URI: " + urlString + ". " + e, e);
                        }
                    }
                }
            }
        }
    }

    if (client == null) {
        // failed to route
        handleConnectFailure(socket, String.format("No endpoint available for virtual host '%s' and protocol %s", params.protocolVirtualHost, params.protocol));
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:59,代码来源:DetectingGateway.java


示例9: getClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
public NetClient getClient() {
    return m_client;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:5,代码来源:TcpConnection.java


示例10: buildClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
public NetClient buildClient() {
    return newClient(this);
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:4,代码来源:TcpConnection.java


示例11: NetClientAdapter

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
public NetClientAdapter(final IConnection<NetClient> connection) {
    m_connection = connection;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:4,代码来源:NetClientAdapter.java


示例12: getConnection

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
public final IConnection<NetClient> getConnection() {
    return m_connection;
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:4,代码来源:NetClientAdapter.java


示例13: createNetClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
public NetClient createNetClient() {
  return null;
}
 
开发者ID:simondean,项目名称:vertx-async,代码行数:5,代码来源:FakeVertx.java


示例14: createNetClient

import org.vertx.java.core.net.NetClient; //导入依赖的package包/类
@Override
public NetClient createNetClient() {
    return null;
}
 
开发者ID:amoAHCP,项目名称:vert.x-spring-microservice-demo,代码行数:5,代码来源:ServiceInfoTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SQLSelectQueryBlock类代码示例发布时间:2022-05-23
下一篇:
Java WSDLFeaturedObject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap