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


Java IoFilterAdapter类代码示例

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


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

示例1: onPreAdd

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
@Override
public void onPreAdd(IoFilterChain parent, String name, NextFilter nextFilter) throws Exception {
    Class<? extends IoFilterAdapter> clazz = getClass();
    if (parent.contains(clazz)) {
        throw new IllegalStateException("Only one " + clazz.getName() + " is permitted.");
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:AbstractStreamWriteFilter.java

示例2: buildFilterChain

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
@Override
public void buildFilterChain ( final IoFilterChain chain )
{
    if ( this.loggerName != null && Boolean.getBoolean ( "org.eclipse.scada.protocol.sfp.common.logger.raw" ) )
    {
        chain.addFirst ( "logger.raw", new LoggingFilter ( this.loggerName ) );
    }

    if ( !Boolean.getBoolean ( "org.eclipse.scada.protocol.sfp.common.disableStats" ) )
    {
        chain.addFirst ( StatisticsFilter.DEFAULT_NAME, new StatisticsFilter () );
    }

    if ( this.loggerName != null && Boolean.getBoolean ( "org.eclipse.scada.protocol.sfp.common.logger" ) )
    {
        chain.addFirst ( "logger", new LoggingFilter ( this.loggerName ) );
    }

    chain.addLast ( "closeidle", new IoFilterAdapter () {
        @Override
        public void sessionIdle ( final NextFilter nextFilter, final IoSession session, final IdleStatus status ) throws Exception
        {
            session.close ( true );
        }
    } );
    chain.addLast ( "codec", new ProtocolCodecFilter ( new ProtocolEncoderImpl (), new ProtocolDecoderImpl () ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:28,代码来源:FilterChainBuilder.java

示例3: setUp

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
@Before
public void setUp() throws InterruptedException {
    connMsg = new ConnectMessage();
    connMsg.setProcotolVersion((byte) 0x03);

    m_minaSession = new DummySession();
    
    m_session = new MinaChannel(m_minaSession);

    m_minaSession.getFilterChain().addFirst("MessageCatcher", new IoFilterAdapter() {

        @Override
        public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session,
                                WriteRequest writeRequest) throws Exception {
            try {
                m_receivedMessage = (AbstractMessage) writeRequest.getMessage();
                if (m_receivedMessage instanceof ConnAckMessage) {
                    ConnAckMessage buf = (ConnAckMessage) m_receivedMessage;
                    m_returnCode = buf.getReturnCode();
                }
            } catch (Exception ex) {
                throw new AssertionError("Wrong return code");
            }
        }
    });

    //sleep to let the messaging batch processor to process the initEvent
    Thread.sleep(300);
    
    m_storageService = new MemoryStorageService();
    //m_storageService.initStore();

    subscriptions = new SubscriptionsStore();
    subscriptions.init(m_storageService);
    m_processor = new ProtocolProcessor();
    m_processor.init(subscriptions, m_storageService);
}
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:38,代码来源:ProtocolProcessorTest.java

示例4: testPublishOfRetainedMessage_afterNewSubscription

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
@Test
    public void testPublishOfRetainedMessage_afterNewSubscription() throws Exception {
        m_minaSession.getFilterChain().remove("MessageCatcher");
        m_minaSession.getFilterChain().addFirst("MessageCatcher", new IoFilterAdapter() {

            @Override
            public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session,
                                    WriteRequest writeRequest) throws Exception {
                try {
                    System.out.println("filterReceived class " + writeRequest.getMessage().getClass().getName());
                    if (writeRequest.getMessage() instanceof PublishMessage) {
                        m_receivedMessage = (AbstractMessage) writeRequest.getMessage();
                    }
                    
                    if (m_receivedMessage instanceof ConnAckMessage) {
                        ConnAckMessage buf = (ConnAckMessage) m_receivedMessage;
                        m_returnCode = buf.getReturnCode();
                    }
                } catch (Exception ex) {
                    throw new AssertionError("Wrong return code");
                }
            }
        });    
            
//        //simulate a connect that register a clientID to an IoSession
        final Subscription subscription = new Subscription(FAKE_CLIENT_ID, 
                FAKE_TOPIC, AbstractMessage.QOSType.MOST_ONE, true);

        //subscriptions.matches(topic) redefine the method to return true
        SubscriptionsStore subs = new SubscriptionsStore() {
            @Override
            public List<Subscription> matches(String topic) {
                if (topic.equals(FAKE_TOPIC)) {
                    return Arrays.asList(subscription);
                } else {
                    throw new IllegalArgumentException("Expected " + FAKE_TOPIC + " buf found " + topic);
                }
            }
        };
        subs.init(new MemoryStorageService());
        
        //simulate a connect that register a clientID to an IoSession
        m_processor.init(subs, m_storageService);
        ConnectMessage connectMessage = new ConnectMessage();
        connectMessage.setClientID(FAKE_CLIENT_ID);
        connectMessage.setProcotolVersion((byte)3);
        connectMessage.setCleanSession(subscription.isCleanSession());
        m_processor.processConnect(m_session, connectMessage);
        PublishEvent pubEvt = new PublishEvent(FAKE_TOPIC, AbstractMessage.QOSType.MOST_ONE, "Hello".getBytes(), true, "FakeCLI", null);
        m_processor.processPublish(pubEvt);
        
        //Exercise
        SubscribeMessage msg = new SubscribeMessage();
        msg.addSubscription(new SubscribeMessage.Couple((byte)QOSType.MOST_ONE.ordinal(), "#"));
        m_processor.processSubscribe(m_session, msg, FAKE_CLIENT_ID, false);
        
        //Verify
        assertNotNull(m_receivedMessage); 
        assertTrue(m_receivedMessage instanceof PublishMessage);
        PublishMessage pubMessage = (PublishMessage) m_receivedMessage;
        assertEquals(FAKE_TOPIC, pubMessage.getTopicName());
    }
 
开发者ID:milliondreams,项目名称:moquette-mqtt,代码行数:63,代码来源:ProtocolProcessorTest.java

示例5: setLoggingFilter

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
/**
 * <p>setLoggingFilter</p>
 *
 * @param filterLogging a {@link org.apache.mina.core.filterchain.IoFilterAdapter} object.
 */
protected final void setLoggingFilter(final IoFilterAdapter filterLogging) {
    m_filterLogging = filterLogging;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:AsyncBasicDetectorMinaImpl.java

示例6: getLoggingFilter

import org.apache.mina.core.filterchain.IoFilterAdapter; //导入依赖的package包/类
/**
 * <p>getLoggingFilter</p>
 *
 * @return a {@link org.apache.mina.core.filterchain.IoFilterAdapter} object.
 */
protected final IoFilterAdapter getLoggingFilter() {
    return m_filterLogging;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:9,代码来源:AsyncBasicDetectorMinaImpl.java


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