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


Java Transporters.connect方法代码示例

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


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

示例1: connect

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
protected Client connect(URL url) throws RemotingException {
    if (servers.containsKey(url)) {
        return null;
    }
    Client client = clients.get(url);
    if (client == null) { // TODO 有并发间隙
        client = Transporters.connect(url, dispatcher);
        clients.put(url, client);
    }
    return client;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:12,代码来源:AbstractGroup.java

示例2: connect

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:HeaderExchanger.java

示例3: main

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {

        final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler );

        Thread serverThread = new Thread( new Runnable() {

            public void run() {
                try {
                    exchangeServer = new HeaderExchangeServer(
                            Transporters.bind(
                                    clientUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 ),
                                    serverHandler ) );
                    serverStarted = true;
                } catch ( Exception e ) {
                    e.printStackTrace();
                }
            }
        } );

        serverThread.setDaemon( true );
        serverThread.start();

        while ( !serverStarted ) {
            Thread.sleep( 1000 );
        }

        HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler );
        ExchangeClient exchangeClient = new HeaderExchangeClient(
                Transporters.connect( clientUrl, clientHandler ) );

        for ( int i = 0; i < 10; i++ ) {
            Thread.sleep( 1000 );
            System.out.print( "." );
        }

        System.out.println();

        if ( clientHandler.getHeartBeatCount() > 0 ) {
            System.out.printf( "Client receives %d heartbeats",
                               clientHandler.getHeartBeatCount() );
        } else {
            throw new Exception( "Server heartbeat does not work." );
        }

        exchangeClient.close();
        exchangeServer.close();

    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:HeartbeatServer.java

示例4: main

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public static void main( String[] args ) throws Exception {
    
    final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler( handler );
    
    Thread serverThread = new Thread( new Runnable() {

        public void run() {
            try {
                exchangeServer = new HeaderExchangeServer(
                        Transporters.bind( serverUrl, serverHandler ) );
                serverStarted = true;
            } catch ( Exception e ) {
                e.printStackTrace();
            }
        }
    } );
    
    serverThread.setDaemon( true );
    serverThread.start();
    
    while ( ! serverStarted ) {
        Thread.sleep( 1000 );
    }
    
    URL url = serverUrl.addParameter( Constants.HEARTBEAT_KEY, 1000 );

    HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler( handler );
    ExchangeClient exchangeClient = new HeaderExchangeClient(
            Transporters.connect( url, clientHandler ) );
    
    for( int i = 0; i < 10; i++ ) {
        Thread.sleep( 1000 );
        System.out.print( "." );
    }

    System.out.println();

    if ( serverHandler.getHeartBeatCount() > 0 ) {
        System.out.printf( "Server receives %d heartbeats",
                           serverHandler.getHeartBeatCount() );
    } else {
        throw new Exception( "Client heartbeat does not work." );
    }

    exchangeClient.close();
    exchangeServer.close();

}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:49,代码来源:HeartbeatClient.java

示例5: main

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler);

        Thread serverThread = new Thread(new Runnable() {

            public void run() {
                try {
                    exchangeServer = new HeaderExchangeServer(
                            Transporters.bind(
                                    clientUrl.addParameter(Constants.HEARTBEAT_KEY, 1000),
                                    serverHandler));
                    serverStarted = true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        serverThread.setDaemon(true);
        serverThread.start();

        while (!serverStarted) {
            Thread.sleep(1000);
        }

        HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler);
        ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(clientUrl, clientHandler),true);

        for (int i = 0; i < 10; i++) {
            Thread.sleep(1000);
            System.out.print(".");
        }

        System.out.println();

        if (clientHandler.getHeartBeatCount() > 0) {
            System.out.printf("Client receives %d heartbeats",
                    clientHandler.getHeartBeatCount());
        } else {
            throw new Exception("Server heartbeat does not work.");
        }

        exchangeClient.close();
        exchangeServer.close();

    }
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:48,代码来源:HeartbeatServer.java

示例6: main

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        final HeartBeatExchangeHandler serverHandler = new HeartBeatExchangeHandler(handler);

        Thread serverThread = new Thread(new Runnable() {

            public void run() {
                try {
                    exchangeServer = new HeaderExchangeServer(
                            Transporters.bind(serverUrl, serverHandler));
                    serverStarted = true;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        serverThread.setDaemon(true);
        serverThread.start();

        while (!serverStarted) {
            Thread.sleep(1000);
        }

        URL url = serverUrl.addParameter(Constants.HEARTBEAT_KEY, 1000);

        HeartBeatExchangeHandler clientHandler = new HeartBeatExchangeHandler(handler);
        ExchangeClient exchangeClient = new HeaderExchangeClient(Transporters.connect(url, clientHandler),true);

        for (int i = 0; i < 10; i++) {
            Thread.sleep(1000);
            System.out.print(".");
        }

        System.out.println();

        if (serverHandler.getHeartBeatCount() > 0) {
            System.out.printf("Server receives %d heartbeats",
                    serverHandler.getHeartBeatCount());
        } else {
            throw new Exception("Client heartbeat does not work.");
        }

        exchangeClient.close();
        exchangeServer.close();

    }
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:48,代码来源:HeartbeatClient.java

示例7: connect

import com.alibaba.dubbo.remoting.Transporters; //导入方法依赖的package包/类
public ExchangeClient connect(URL url, ExchangeHandler handler) throws RemotingException {
    return new HeaderExchangeClient(Transporters.connect(url, new DecodeHandler(new HeaderExchangeHandler(handler))), true);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:4,代码来源:HeaderExchanger.java


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