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


Java FilterChainBuilder.add方法代码示例

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


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

示例1: doOpen

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = builder.getWorkerThreadPoolConfig(); 
    config.setPoolName(CLIENT_THREAD_POOL_NAME)
            .setQueueLimit(-1)
            .setCorePoolSize(0)
            .setMaxPoolSize(Integer.MAX_VALUE)
            .setKeepAliveTime(60L, TimeUnit.SECONDS);
    builder.setTcpNoDelay(true).setKeepAlive(true)
            .setConnectionTimeout(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:GrizzlyClient.java

示例2: start

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
public void start(int listenPort, ExecutorService threadpool) throws Exception {
  ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) threadpool;
  ThreadPoolConfig config = ThreadPoolConfig.defaultConfig().copy().setCorePoolSize(threadPoolExecutor.getCorePoolSize())
      .setMaxPoolSize(threadPoolExecutor.getMaximumPoolSize()).setPoolName("GRIZZLY-SERVER");
  ExecutorService executorService = GrizzlyExecutorService.createInstance(config);

  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyProtocolFilter());
  filterChainBuilder.add(new GrizzlyServerHandler(executorService));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  builder.setOptimizedForMultiplexing(true);
  builder.setIOStrategy(SameThreadIOStrategy.getInstance());

  transport = builder.build();

  transport.setProcessor(filterChainBuilder.build());
  transport.bind(listenPort);

  transport.start();
  LOGGER.warn("server started,listen at: " + listenPort);
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:23,代码来源:GrizzlyServer.java

示例3: start

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
public void start() throws IOException {
    // Create TCP transport
    transport = TCPNIOTransportBuilder.newInstance().build();

    // Create a FilterChain using FilterChainBuilder
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    // Add TransportFilter, which is responsible
    // for reading and writing data to the connection
    filterChainBuilder.add(new TransportFilter());
    // filterChainBuilder.add(new ClientEncodeFilter());
    filterChainBuilder.add(new TunnelRedirectServerFilter(
            TCPNIOConnectorHandler.builder(transport).build(), targetHost,
            targetPort));
    transport.setProcessor(filterChainBuilder.build());
    // transport.setReadBufferSize(512);
    // Set async write queue size limit
    // transport.getAsyncQueueIO().getWriter()
    // .setMaxPendingBytesPerConnection(10240 * 10240);
    // binding transport to start listen on certain host and port
    transport.bind(localHost, localPort);
    // start the transport
    transport.start();
    logger.info("Press any key to stop the server...");
}
 
开发者ID:chocotan,项目名称:kazeproxy,代码行数:25,代码来源:TunnelRedirectServer.java

示例4: doOpen

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
@Override
protected void doOpen() throws Throwable {
    FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
    filterChainBuilder.add(new TransportFilter());
    filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
    filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
    TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
    ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
    config.setPoolName(CLIENT_THREAD_POOL_NAME)
            .setQueueLimit(-1)
            .setCorePoolSize(0)
            .setMaxPoolSize(Integer.MAX_VALUE)
            .setKeepAliveTime(60L, TimeUnit.SECONDS);
    builder.setTcpNoDelay(true).setKeepAlive(true)
            .setConnectionTimeout(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:21,代码来源:GrizzlyClient.java

示例5: createClient

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
protected Client createClient(String targetIP, int targetPort, int connectTimeout, String key) throws Exception {
  Connection connection = null;
  GrizzlyClientHandler handler = new GrizzlyClientHandler();
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyProtocolFilter());
  filterChainBuilder.add(handler);

  final TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance();
  transportBuilder.setOptimizedForMultiplexing(true);

  transportBuilder.setIOStrategy(SameThreadIOStrategy.getInstance());

  final TCPNIOTransport transport = transportBuilder.build();
  transport.setTcpNoDelay(Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true")));

  transport.setProcessor(filterChainBuilder.build());

  transport.start();
  Future<Connection> future = transport.connect(targetIP, targetPort);
  if (connectTimeout < 1000) {
    connectTimeout = 1000;
  }
  connection = future.get(connectTimeout, TimeUnit.MILLISECONDS);
  @SuppressWarnings("unchecked")
  GrizzlyClient client = new GrizzlyClient(targetIP, targetPort, connectTimeout, connection, key);
  handler.setClient(client);
  return client;
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:31,代码来源:GrizzlyClientFactory.java

示例6: setup

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
@Override
public void setup(NetworkListener networkListener, FilterChainBuilder builder) {
    // Get the index of HttpServerFilter in the HttpServer filter chain
    final int httpServerFilterIdx = builder.indexOfType(HttpServerFilter.class);

    if (httpServerFilterIdx >= 0) {
        // Insert the WebSocketFilter right before HttpServerFilter
        builder.add(httpServerFilterIdx, new GrizzlyServerFilter(container, contextPath));
    }
}
 
开发者ID:icode,项目名称:ameba-container-grizzly,代码行数:11,代码来源:WebSocketAddOn.java

示例7: start

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的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

示例8: setup

import org.glassfish.grizzly.filterchain.FilterChainBuilder; //导入方法依赖的package包/类
@Override
public void setup(NetworkListener listener, FilterChainBuilder builder) {
	int index = builder.indexOfType(HttpServerFilter.class);
	index = index < 0 ? 0 : index;
	builder.add(index, this);
}
 
开发者ID:coderczp,项目名称:HtmlSocket,代码行数:7,代码来源:WSAddOn.java


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