org.mailster.mina
Class CumulativeIoFilter

java.lang.Object
  extended by org.apache.mina.core.filterchain.IoFilterAdapter
      extended by org.mailster.mina.CumulativeIoFilter
All Implemented Interfaces:
org.apache.mina.core.filterchain.IoFilter
Direct Known Subclasses:
AuthDigestMD5IoFilter

public abstract class CumulativeIoFilter
extends org.apache.mina.core.filterchain.IoFilterAdapter

---
Mailster (C) 2007-2009 De Oliveira Edouard

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See  Mailster Web Site
---

CumulativeIoFilter.java - A IoFilter that cumulates data into internal buffer until there's enough data for the decoder to decode it.

Version:
$Revision: 1.6 $, $Date: 2009/01/30 01:32:30 $
Author:
Edouard De Oliveira

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
org.apache.mina.core.filterchain.IoFilter.NextFilter
 
Field Summary
private static java.lang.String BUFFER
           
protected static java.lang.String CONSUMER
           
 
Constructor Summary
CumulativeIoFilter()
           
 
Method Summary
 void cumulateAndConsume(org.apache.mina.core.filterchain.IoFilter.NextFilter nextFilter, org.apache.mina.core.session.IoSession session, org.apache.mina.core.buffer.IoBuffer in)
          Cumulates content of in into internal buffer and forwards decoding requests to DataConsumer.consume(org.apache.mina.core.filterchain.IoFilter.NextFilter, IoBuffer).
abstract  DataConsumer getDataConsumer(org.apache.mina.core.session.IoSession session)
           
private  void removeSessionBuffer(org.apache.mina.core.session.IoSession session)
           
private  void storeRemainingInSession(org.apache.mina.core.buffer.IoBuffer buf, org.apache.mina.core.session.IoSession session)
           
 
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, filterWrite, init, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BUFFER

private static final java.lang.String BUFFER

CONSUMER

protected static final java.lang.String CONSUMER
Constructor Detail

CumulativeIoFilter

public CumulativeIoFilter()
Method Detail

getDataConsumer

public abstract DataConsumer getDataConsumer(org.apache.mina.core.session.IoSession session)

cumulateAndConsume

public void cumulateAndConsume(org.apache.mina.core.filterchain.IoFilter.NextFilter nextFilter,
                               org.apache.mina.core.session.IoSession session,
                               org.apache.mina.core.buffer.IoBuffer in)
                        throws java.lang.Exception
Cumulates content of in into internal buffer and forwards decoding requests to DataConsumer.consume(org.apache.mina.core.filterchain.IoFilter.NextFilter, IoBuffer). repeatedly until it returns false. The cumulative buffer is compacted after decoding ends.

Throws:
java.lang.IllegalStateException - if your doDecode() returned true not consuming the cumulative buffer.
java.lang.Exception

removeSessionBuffer

private void removeSessionBuffer(org.apache.mina.core.session.IoSession session)

storeRemainingInSession

private void storeRemainingInSession(org.apache.mina.core.buffer.IoBuffer buf,
                                     org.apache.mina.core.session.IoSession session)