本文整理汇总了Java中org.apache.mina.core.session.AbstractIoSession类的典型用法代码示例。如果您正苦于以下问题:Java AbstractIoSession类的具体用法?Java AbstractIoSession怎么用?Java AbstractIoSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractIoSession类属于org.apache.mina.core.session包,在下文中一共展示了AbstractIoSession类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getWriteRequestQueue
import org.apache.mina.core.session.AbstractIoSession; //导入依赖的package包/类
@Override
public WriteRequestQueue getWriteRequestQueue(IoSession session)
{
_wrqCount.getAndIncrement();
return new WriteRequestQueue()
{
private final ArrayDeque<WriteRequest> _wrq = new ArrayDeque<>();
@Override
public synchronized int size()
{
return _wrq.size();
}
@Override
public synchronized boolean isEmpty()
{
return _wrq.isEmpty();
}
@Override
public synchronized void clear()
{
_wrq.clear();
}
@Override
public WriteRequest poll()
{
WriteRequest wr;
synchronized(this)
{
wr = _wrq.pollFirst();
}
if(wr == AbstractIoSession.CLOSE_REQUEST)
{
wr = null;
session.closeNow();
dispose();
}
return wr;
}
@Override
public synchronized void offer(WriteRequest writeRequest) // message must be IoBuffer or FileRegion
{
_wrq.addLast(writeRequest);
}
@Override
public void dispose()
{
}
@Override
public synchronized String toString()
{
return _wrq.toString();
}
};
}
开发者ID:dwing4g,项目名称:jane,代码行数:62,代码来源:TestEcho.java
注:本文中的org.apache.mina.core.session.AbstractIoSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论