directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Vermillard <jvermill...@archean.fr>
Subject Re: Using Mina ByteBuffers
Date Fri, 22 Apr 2005 12:17:09 GMT
Le jeudi 21 avril 2005 à 20:42 +0900, Trustin Lee a écrit :
> Hi,
> 
> 2005/4/21, daune.jf@daune-consult.com <daune.jf@daune-consult.com>:
> > Hi,
> > 
> > I wonder what I have to do to use Mina ByteBuffer implementation in my
> > application (in ProtocolDecoder, in order to copy incoming bytes until a
> > complete message is received)
> 
> You could just use CumulativeProtocolDecoder that does what you want.
> 
> > I especially wonder if I must acquire the buffer after calling
> > ByteBuffer.allocate (and then release it when work is done), or if
> > acquire/release is not needed.
> > 
> > There is some javadoc about it:
> > 
> > "Please note that you never need to release the allocated buffer because MINA
> > will release it automatically.
> > But, if you didn't pass it to MINA or called {@link #acquire()} by yourself, you
> > will have to release it manually"
> > 
> > But I don't understand what is meant by "pass to MINA".
> 
> I updated documentation of Acquire/Release section.  Please svn up and
> then you'll see more clear explanation.  I'll copy and paste it here:
> 
> Please note that you never need to release the allocated buffer
> because MINA will release it automatically when:
> 
>  * You pass the buffer by calling {@link IoSession#write(ByteBuffer,
> Object)}.</li>
>  * You pass the buffer by calling {@link
> ProtocolEncoderOutput#write(ByteBuffer)}.
> 
> And, you don't need to release any {@link ByteBuffer} which is passed
> as a parameter of {@link IoHandler#dataRead(IoSession, ByteBuffer)}
> method.  They are released automatically when the method returns.
> 
> You have to release buffers manually by calling {@link #release()} when:
> 
>  * You allocated a buffer, but didn't pass the buffer to any of two
> methods above.</li>
>  * You called {@link #acquire()} to prevent the buffer from being released.</li>
> 
> Is the documentation clearer now?
> 
> Thanks,
> Trustin


Damned, I never seen this so usefull CumulativeProtocolDecoder class
before !
That probably could help everybody migrating from Netty2.

Julien


Mime
View raw message