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


Java IoFilter类代码示例

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


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

示例1: Channel

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public Channel(final int world, final int channel) {
    this.world = world;
    this.channel = channel;
    this.mapFactory = new MapleMapFactory(MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz")), MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/String.wz")), world, channel);

    try {
        eventSM = new EventScriptManager(this, ServerConstants.EVENTS.split(" "));
        port = 7575 + this.channel - 1;
        port += (world * 100);
        ip = ServerConstants.HOST + ":" + port;
        IoBuffer.setUseDirectBuffer(false);
        IoBuffer.setAllocator(new SimpleBufferAllocator());
        acceptor = new NioSocketAcceptor();
        TimerManager.getInstance().register(new respawnMaps(), 10000);
        acceptor.setHandler(new MapleServerHandler(world, channel));
        acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30);
        acceptor.getFilterChain().addLast("codec", (IoFilter) new ProtocolCodecFilter(new MapleCodecFactory()));
        acceptor.bind(new InetSocketAddress(port));
        ((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true);

        eventSM.init();
        System.out.println("    Channel " + getId() + ": Listening on port " + port);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:27,代码来源:Channel.java

示例2: createEndpoint

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    // Using the configuration which set by the component as a default one
    // Since the configuration's properties will be set by the URI
    // we need to copy or create a new MinaConfiguration here
    // Using the configuration which set by the component as a default one
    // Since the configuration's properties will be set by the URI
    // we need to copy or create a new MinaConfiguration here
    Mina2Configuration config;
    if (configuration != null) {
        config = configuration.copy();
    } else {
        config = new Mina2Configuration();
    }

    URI u = new URI(remaining);
    config.setHost(u.getHost());
    config.setPort(u.getPort());
    config.setProtocol(u.getScheme());
    config.setFilters(resolveAndRemoveReferenceListParameter(parameters, "filters", IoFilter.class));
    setProperties(config, parameters);

    return createEndpoint(uri, config);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:Mina2Component.java

示例3: setupVmProtocol

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
protected void setupVmProtocol(String uri) {
    boolean minaLogger = configuration.isMinaLogger();
    List<IoFilter> filters = configuration.getFilters();

    address = new VmPipeAddress(configuration.getPort());
    connector = new VmPipeConnector();

    // connector config
    if (minaLogger) {
        connector.getFilterChain().addLast("logger", new LoggingFilter());
    }
    appendIoFiltersToChain(filters, connector.getFilterChain());
    if (configuration.getSslContextParameters() != null) {
        LOG.warn("Using vm protocol"
                 + ", but an SSLContextParameters instance was provided.  SSLContextParameters is only supported on the TCP protocol.");
    }
    configureCodecFactory("Mina2Producer", connector);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:Mina2Producer.java

示例4: setupVmProtocol

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
protected void setupVmProtocol(String uri, Mina2Configuration configuration) {

        boolean minaLogger = configuration.isMinaLogger();
        List<IoFilter> filters = configuration.getFilters();

        address = new VmPipeAddress(configuration.getPort());
        acceptor = new VmPipeAcceptor();

        // acceptor connectorConfig
        configureCodecFactory("Mina2Consumer", acceptor, configuration);
        if (minaLogger) {
            acceptor.getFilterChain().addLast("logger", new LoggingFilter());
        }
        appendIoFiltersToChain(filters, acceptor.getFilterChain());
        if (configuration.getSslContextParameters() != null) {
            LOG.warn("Using vm protocol"
                     + ", but an SSLContextParameters instance was provided.  SSLContextParameters is only supported on the TCP protocol.");
        }
    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:Mina2Consumer.java

示例5: startListner

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public  void startListner(IoHandler iohandler,int listenPort) throws Exception{
	acceptor = new NioSocketAcceptor();
	acceptor.setBacklog(100);
	acceptor.setReuseAddress(true);
	acceptor.setHandler(iohandler);
	
       DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
       IoFilter protocol = new ProtocolCodecFilter(new GameProtocolcodecFactory());
       chain.addLast("codec", protocol);
	threadpool = new OrderedThreadPoolExecutor(500);
	threadpool.setThreadFactory(new ServerThreadFactory("OrderedThreadPool"));
	chain.addLast("threadPool", new ExecutorFilter(threadpool));
	
	int recsize = 5120;
	int sendsize = 40480;                                                                                         
	int timeout = 10;
	SocketSessionConfig sc = acceptor.getSessionConfig();
	sc.setReuseAddress(true);// 设置每一个非主监听连接的端口可以重用
	sc.setReceiveBufferSize(recsize);// 设置输入缓冲区的大小
	sc.setSendBufferSize(sendsize);// 设置输出缓冲区的大小
	sc.setTcpNoDelay(true);// flush函数的调用 设置为非延迟发送,为true则不组装成大包发送,收到东西马上发出   
	sc.setSoLinger(0);
	sc.setIdleTime(IdleStatus.READER_IDLE, timeout);
	acceptor.bind(new InetSocketAddress(listenPort));
}
 
开发者ID:yongzhidai,项目名称:GameServer,代码行数:26,代码来源:NetManager.java

示例6: addFilterToChain

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
protected void addFilterToChain( final SocketAcceptor acceptor, final String filterName, final IoFilter filter )
{
    if ( acceptor == null )
    {
        Log.debug( "Not adding filter '{}' to acceptor that is null.", filterName );
        return;
    }

    final DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
    if ( chain.contains( COMPRESSION_FILTER_NAME ) )
    {
        Log.debug( "Adding filter '{}' as the first filter after the compression filter in acceptor {}", filterName, acceptor );
        chain.addAfter( COMPRESSION_FILTER_NAME, filterName, filter );
    }
    else if ( chain.contains( TLS_FILTER_NAME ) )
    {
        Log.debug( "Adding filter '{}' as the first filter after the TLS filter in acceptor {}", filterName, acceptor );
        chain.addAfter( TLS_FILTER_NAME, filterName, filter );
    }
    else
    {
        Log.debug( "Adding filter '{}' as the last filter in acceptor {}", filterName, acceptor );
        chain.addLast( filterName, filter );
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:26,代码来源:DebuggerPlugin.java

示例7: create

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
@Override
public IoFilter create ()
{
    if ( FilterChainBuilder.this.loggerName != null && Boolean.getBoolean ( "org.eclipse.scada.protocol.ngp.common.logger" ) )
    {
        return new LoggingFilterExtension ( this.suffix != null ? FilterChainBuilder.this.loggerName + "." + this.suffix : FilterChainBuilder.this.loggerName );
    }
    else
    {
        return null;
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:FilterChainBuilder.java

示例8: FilterChainBuilder

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public FilterChainBuilder ( final boolean clientMode )
{
    if ( !Boolean.getBoolean ( "org.eclipse.scada.protocol.ngp.common.disableStats" ) )
    {
        this.filters.add ( new Entry ( StatisticsFilter.DEFAULT_NAME, new StatisticsFilter () ) );
    }

    this.filters.add ( new Entry ( "logger.raw", new LoggerFilterFactory ( "raw" ) ) );

    this.filters.add ( new Entry ( "ssl" ) );
    this.filters.add ( new Entry ( "streamCompression" ) );

    this.filters.add ( new Entry ( "logger", new LoggerFilterFactory ( "pre" ) ) );

    this.filters.add ( new Entry ( "sync", new ExecutorFilter ( Integer.getInteger ( "org.eclipse.scada.protocol.ngp.common.coreSessionThreads", 0 ), Integer.getInteger ( "org.eclipse.scada.protocol.ngp.common.maxSessionThreads", 1 ), 1, TimeUnit.MINUTES, new NamedThreadFactory ( "org.eclipse.scada.protocol.ngp.common.FilterChainSync", false, true, THREAD_COUNTER ), IoEventType.WRITE ) ) );
    this.filters.add ( new Entry ( "frameCodec", new ProtocolCodecFilter ( new FrameEncoder (), new FrameDecoder () ) ) );

    this.filters.add ( new Entry ( "keepalive" ) );

    this.filters.add ( new Entry ( "messageChannelCodec", new MessageChannelCodecFilter () ) );
    this.filters.add ( new Entry ( "messageChannel", new IoFilterFactoryAdapter () {

        @Override
        public IoFilter create ()
        {
            // we need new instances of MessageChannelFilter
            return new MessageChannelFilter ( clientMode );
        }
    } ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:31,代码来源:FilterChainBuilder.java

示例9: buildFilterChain

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
@Override
public void buildFilterChain ( final IoFilterChain chain )
{
    for ( final Entry entry : this.filters )
    {
        final IoFilter filter = entry.getFactory ().create ();
        if ( filter != null )
        {
            chain.addLast ( entry.getName (), filter );
        }
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:14,代码来源:FilterChainBuilder.java

示例10: replaceMarker

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
/**
 * Replace an IOFilter that as pre-registered as {@link NoopFilter} with the
 * ".marker" suffix
 * 
 * @param name
 *            the name, without the ".marker" suffix
 * @param filter
 *            the filter replacement
 */
protected void replaceMarker ( final String name, final IoFilter filter )
{
    final Entry entry = this.session.getFilterChain ().getEntry ( name + ".marker" );
    if ( entry == null )
    {
        throw new IllegalStateException ( String.format ( "Filter with name '%s.marker' is missing", name ) );
    }
    entry.addAfter ( name, filter );
    entry.remove ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:ChainConfigurator.java

示例11: startGMServer

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public static void startGMServer() {

        IoBuffer.setUseDirectBuffer(false);
        IoBuffer.setAllocator(new SimpleBufferAllocator());
        acceptor = new NioSocketAcceptor();
        acceptor.setHandler(new GMServerHandler());
        acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 30);
        acceptor.getFilterChain().addLast("codec", (IoFilter) new ProtocolCodecFilter(new GMCodecFactory()));
        ((SocketSessionConfig) acceptor.getSessionConfig()).setTcpNoDelay(true);
        try {
            acceptor.bind(new InetSocketAddress(5252));
            System.out.println("\r\nGM Server online : Listening on port 5252.");
        } catch (Exception e) {
            System.out.println("Failed binding the GM Server to port : 5252");
        }

        for (World w : Server.getInstance().getWorlds()) {//For when 
            for (Channel c : w.getChannels()) {
                for (MapleCharacter chr : c.getPlayerStorage().getAllCharacters()) {
                    if (chr.isGM()) {
                        inGame.put(chr.getName(), chr.getClient().getSession());
                    }
                }
            }
        }
        started = true;
    }
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:28,代码来源:GMServer.java

示例12: appendIoFiltersToChain

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
private void appendIoFiltersToChain(List<IoFilter> filters, DefaultIoFilterChainBuilder filterChain) {
    if (filters != null && filters.size() > 0) {
        for (IoFilter ioFilter : filters) {
            filterChain.addLast(ioFilter.getClass().getCanonicalName(), ioFilter);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:Mina2Producer.java

示例13: createJndiContext

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
@Override
protected Context createJndiContext() throws Exception {
    JndiContext answer = new JndiContext();
    IoFilter myFilter = new TestFilter();
    List<IoFilter> myFilters = new ArrayList<IoFilter>();
    myFilters.add(myFilter);

    answer.bind("myFilters", myFilters);
    answer.bind("myFilter", myFilter);
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:Mina2FiltersTest.java

示例14: connect

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public boolean connect(NioSocketConnector connector, SocketAddress address) {
	if(!isSetChain){
		throw new IllegalStateException(
                "please set ConservationChain first !");
	}
    if (session != null && session.isConnected()) {
        throw new IllegalStateException(
                "Already connected. Disconnect first.");
    }

    try {

        IoFilter CODEC_FILTER = new ProtocolCodecFilter(
                new GameProtocolcodecFactory());
        
        connector.getFilterChain().addLast("codec", CODEC_FILTER);

        connector.setHandler(handler);
        ConnectFuture future1 = connector.connect(address);
        future1.awaitUninterruptibly();
        if (!future1.isConnected()) {
            return false;
        }
        session = future1.getSession();
       
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:yongzhidai,项目名称:TestClient,代码行数:31,代码来源:NetSupport.java

示例15: TCPTestClient

import org.apache.mina.core.filterchain.IoFilter; //导入依赖的package包/类
public TCPTestClient(InetSocketAddress addr) {
    this.addr = addr;
    connector.setConnectTimeoutMillis(5000);

    IoFilter tupleEncoder = new ProtocolCodecFilter(new TestTupleEncoder(),
            new TestTupleDecoder());

    connector.getFilterChain().addLast("tuples", tupleEncoder);

    connector.setHandler(new IoHandlerAdapter());
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:12,代码来源:TCPTestClient.java


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