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


Java BaseFilter类代码示例

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


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

示例1: createClient

import org.glassfish.grizzly.filterchain.BaseFilter; //导入依赖的package包/类
public static Client createClient(ClientType clientType, String url, long timeout) {
    String[] strs = url.split(":");
    if ( strs.length != 2 ) throw new RuntimeException("malform url "+url);
    if ( clientType == ClientType.Netty ) {
        ClusterClientHandler handler =  new ClusterClientHandler(timeout, EmbeddedSerializer);
        return com.sm.transport.netty.TCPClient.start(strs[0], Integer.valueOf(strs[1]), handler, (byte) 1);
    }
    else {
        BaseFilter requestCodecFilter = new RequestCodecFilter( (byte) 1);
        return com.sm.transport.grizzly.TCPClient.start(strs[0], Integer.valueOf(strs[1]), requestCodecFilter,
                new ClusterClientFilter(timeout) );
    }
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:14,代码来源:TCPClientFactory.java

示例2: start

import org.glassfish.grizzly.filterchain.BaseFilter; //导入依赖的package包/类
public static TCPServer start(int port, BaseFilter requestCodecFilter, BaseFilter serverFilter)  {
    TCPServer server = new TCPServer( port);
    // Create a FilterChain using FilterChainBuilder
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    // Add filters to the chain
    filterChainBuilder.add(new TransportFilter())
        .add(requestCodecFilter)
        .add(serverFilter);

    // Create TCP NIO transport
    server.transport = TCPNIOTransportBuilder.newInstance()
            /*.setReadBufferSize(1024 * 1024 * 16)
            .setTcpNoDelay(true)
            .setMemoryManager(new ByteBufferManager())*/
            .build();
    server.transport.setProcessor(filterChainBuilder.build());
    try {
        // Bind server socket and start transport
        server.transport.bind(port);
        server.transport.start();
        return server;
    } catch (Exception ex) {
        if ( server.transport != null) {
            server.transport.shutdown();
        }
        throw new RuntimeException( ex.getMessage(), ex);
    }
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:29,代码来源:TCPServer.java

示例3: start

import org.glassfish.grizzly.filterchain.BaseFilter; //导入依赖的package包/类
public static TCPClient start(String host, int port, BaseFilter coder, BaseFilter clientFilter) {
    TCPClient client = new TCPClient( host, port);
    client.clientFilter = clientFilter;
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    // Add TransportFilter, which is responsible
    // for reading and writing data to the connection
    filterChainBuilder.add(new TransportFilter());

    // StringFilter is responsible for Buffer <-> String conversion
    filterChainBuilder.add(coder);

    // EchoFilter is responsible for echoing received messages
    filterChainBuilder.add(clientFilter);

    // Create TCP transport
    client.transport = TCPNIOTransportBuilder.newInstance().build();

    client.transport.setProcessor(filterChainBuilder.build());

    try {
        // binding transport to start listen on certain host and port
        try {
            client.transport.start();
            // perform async. connect to the server
            Future<Connection> future = client.transport.connect(client.host, client.port);
            // wait for connect operation to complete
            client.connection = future.get(5, TimeUnit.SECONDS);
            if ( client.connection.isOpen())
                return client;
            else
                throw new ConnectionException("can not connect to "+client.toString());
            //System.in.read();
        } catch (Exception e) {
            //shutdown transport thread
            if ( client.transport != null )
                client.transport.shutdown();
            throw new RuntimeException( e.getMessage(), e);
        }

    } finally {

    }
}
 
开发者ID:viant,项目名称:CacheStore,代码行数:44,代码来源:TCPClient.java


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