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


Java AbstractIoSession类代码示例

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


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

示例1: sessionClosed

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@Override
public void sessionClosed(NextFilter nextFilter, IoSession session) throws Exception {
    AbstractIoSession s = (AbstractIoSession) session;
    try {
        s.getHandler().sessionClosed(session);
    } finally {
        try {
            s.getWriteRequestQueue().dispose(session);
        } finally {
            try {
                s.getAttributeMap().dispose(session);
            } finally {
                try {
                    // Remove all filters.
                    session.getFilterChain().clear();
                } finally {
                    if (s.getConfig().isUseReadOperation()) {
                        s.offerClosedReadFuture();
                    }
                }
            }
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:DefaultIoFilterChain.java

示例2: messageReceived

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@Override
public void messageReceived(NextFilter nextFilter, IoSession session, Object message) throws Exception {
    AbstractIoSession s = (AbstractIoSession) session;
    if (!(message instanceof IoBuffer)) {
        s.increaseReadMessages(System.currentTimeMillis());
    } else if (!((IoBuffer) message).hasRemaining()) {
        s.increaseReadMessages(System.currentTimeMillis());
    }

    try {
        session.getHandler().messageReceived(s, message);
    } finally {
        if (s.getConfig().isUseReadOperation()) {
            s.offerReadFuture(message);
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:DefaultIoFilterChain.java

示例3: assertThatPrepareOnlyThisForTestWorks

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@Test
@PrepareOnlyThisForTest( { NioDatagramSession.class, NioProcessor.class, AbstractIoSession.class })
public void assertThatPrepareOnlyThisForTestWorks() throws Exception {
    final String scheduleRemoveMethodName = "scheduleRemove";

    Executor executor = createMock(Executor.class);
    NioProcessor objectUnderTest = createPartialMock(NioProcessor.class, new String[] { scheduleRemoveMethodName }, executor);
    NioDatagramSession session = createMock(NioDatagramSession.class);

    expect(session.isConnected()).andReturn(false);
    expectPrivate(objectUnderTest, scheduleRemoveMethodName, session).once();

    replay(objectUnderTest, executor, session);

    assertFalse(Whitebox.<Boolean> invokeMethod(objectUnderTest, "flushNow", session, 20L));

    verify(objectUnderTest, executor, session);
}
 
开发者ID:powermock,项目名称:powermock-examples-maven,代码行数:19,代码来源:PrepareOnlyThisForTestAnnotationTest.java

示例4: notifyIdleSessions

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
private void notifyIdleSessions( long currentTime )
{
    // process idle sessions
    if ( currentTime - lastIdleCheckTime >= 1000 )
    {
        lastIdleCheckTime = currentTime;
        AbstractIoSession.notifyIdleness( getListeners().getManagedSessions().values().iterator(), currentTime );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:10,代码来源:AbstractPollingConnectionlessIoAcceptor.java

示例5: notifyIdleSessions

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
private void notifyIdleSessions(long currentTime) throws Exception {
    // process idle sessions
    if (currentTime - lastIdleCheckTime >= SELECT_TIMEOUT) {
        lastIdleCheckTime = currentTime;
        AbstractIoSession.notifyIdleness(allSessions(), currentTime);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:AbstractPollingIoProcessor.java

示例6: DefaultIoFilterChain

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
/**
 * Create a new default chain, associated with a session. It will only contain a
 * HeadFilter and a TailFilter.
 *
 * @param session The session associated with the created filter chain
 */
public DefaultIoFilterChain(AbstractIoSession session) {
    if (session == null) {
        throw new IllegalArgumentException("session");
    }

    this.session = session;
    head = new EntryImpl(null, null, "head", new HeadFilter());
    tail = new EntryImpl(head, null, "tail", new TailFilter());
    head.nextEntry = tail;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:DefaultIoFilterChain.java

示例7: filterWrite

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {

    AbstractIoSession s = (AbstractIoSession) session;

    // Maintain counters.
    if (writeRequest.getMessage() instanceof IoBuffer) {
        IoBuffer buffer = (IoBuffer) writeRequest.getMessage();
        // I/O processor implementation will call buffer.reset()
        // it after the write operation is finished, because
        // the buffer will be specified with messageSent event.
        buffer.mark();
        int remaining = buffer.remaining();

        if (remaining == 0) {
            // Zero-sized buffer means the internal message
            // delimiter.
            s.increaseScheduledWriteMessages();
        } else {
            s.increaseScheduledWriteBytes(remaining);
        }
    } else {
        s.increaseScheduledWriteMessages();
    }

    WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();

    if (!s.isWriteSuspended()) {
        if (writeRequestQueue.size() == 0) {
            // We can write directly the message
            s.getProcessor().write(s, writeRequest);
        } else {
            s.getWriteRequestQueue().offer(s, writeRequest);
            s.getProcessor().flush(s);
        }
    } else {
        s.getWriteRequestQueue().offer(s, writeRequest);
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:41,代码来源:DefaultIoFilterChain.java

示例8: exceptionCaught

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@Override
public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) throws Exception {
    AbstractIoSession s = (AbstractIoSession) session;
    try {
        s.getHandler().exceptionCaught(s, cause);
    } finally {
        if (s.getConfig().isUseReadOperation()) {
            s.offerFailedReadFuture(cause);
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:DefaultIoFilterChain.java

示例9: unwrap

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
public void unwrap(NextFilter nextFilter, IoBuffer buf) 
{    	
   	try 
   	{        		 
   		byte[] msg = new byte[buf.limit()];
   		buf.get(msg);
   		int size = msg.length-16;
   	    
   		if (size < 0)
   	    	throw new AuthException("Missing or incomplete mac block");
   	    
   	    byte[] originalMessage = new byte[size];
   	    System.arraycopy(msg, 0, originalMessage, 0, size);
   	    
   	    byte[] mac = new byte[16];
   	    System.arraycopy(msg, size, mac, 0, 16);
   	    
   	    if (isValidMAC(mac, AuthDigestMD5IoFilter.computeMACBlock(session, originalMessage, true)))
   	    {
   		    buf.position(size);
   		    buf.put(LINE_TERMINATOR);
   		    buf.flip();

   		    nextFilter.messageReceived(session, buf);
   	    }
	} 
   	catch (Exception ex) 
   	{
   		LOG.debug(ex.getMessage());
   		nextFilter.messageReceived(session, "\r\n");
	}
   	
       if ( session instanceof AbstractIoSession )
           ( ( AbstractIoSession ) session ).
           	increaseReadMessages(System.currentTimeMillis());
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:37,代码来源:DigestMD5IntegrityIoFilterCodec.java

示例10: DefaultIoFilterChain

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
/**
 * Create a new default chain, associated with a session.
 * It will only contain a HeadFilter and a TailFilter.
 *
 * @param session The session associated with the created filter chain
 */
public DefaultIoFilterChain(AbstractIoSession session) {
	if (session == null) {
		throw new IllegalArgumentException("session");
	}

	this.session = session;
}
 
开发者ID:dwing4g,项目名称:jane,代码行数:14,代码来源:DefaultIoFilterChain.java

示例11: increaseWrittenDataBytes

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
/**
    * Increase the number of bytes written on the data connection
    * @param increment The number of bytes written
    */
   public void increaseWrittenDataBytes(int increment) {
if (wrappedSession instanceof AbstractIoSession) {
    ((AbstractIoSession) wrappedSession).increaseScheduledWriteBytes(increment);
    ((AbstractIoSession) wrappedSession).increaseWrittenBytes(
	    increment, System.currentTimeMillis());
}
   }
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:12,代码来源:FtpIoSession.java

示例12: increaseReadDataBytes

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
/**
    * Increase the number of bytes read on the data connection
    * @param increment The number of bytes written
    */
   public void increaseReadDataBytes(int increment) {
if (wrappedSession instanceof AbstractIoSession) {
    ((AbstractIoSession) wrappedSession).increaseReadBytes(increment,
	    System.currentTimeMillis());
}
   }
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:11,代码来源:FtpIoSession.java

示例13: VmPipeFilterChain

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
VmPipeFilterChain(AbstractIoSession session) {
    super(session);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:4,代码来源:VmPipeFilterChain.java

示例14: filterClose

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void filterClose(NextFilter nextFilter, IoSession session) throws Exception {
    ((AbstractIoSession) session).getProcessor().remove(session);
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:6,代码来源:DefaultIoFilterChain.java

示例15: write

import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
public void write(Object message) {
  messageQueue.add(message);
  if (session instanceof AbstractIoSession) {
    ((AbstractIoSession) session).increaseReadMessages(System.currentTimeMillis());
  }
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:7,代码来源:MinaProtocolCodecFilter.java


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