On Tue, Mar 31, 2009 at 10:24 AM, Emmanuel Lecharny
<[email protected]> wrote:
> Maarten Bosteels wrote:
>>
>> The codecfactory in the tutorial is stateless :
>> http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html
>>
>
> Well, if you create new instances of encoder/decoder per session, it doesn't
> matter too much that the factory is stateless or not. In fact, the factory
> being statefull or stateless is irrelevant.

I was talking about the encoder/decoder of course.
But it's the codecfactory that has to know whether the decoder is
stateless or not.

(I think encoder will almost always be stateless because all data is
already available)

It's the encoder/decoder state
> which is important. As soon as you have new instances of those guys for each
> new session, and as soon as you have a guarantee that you can't enter the
> encoder/decoder in two different threads for the same session, then you are
> safe.
>
> FWIK, if you encoder/decoder are stateless, you should never instanciate
> them for each session. If they are statefull, then again, you have to think
> about the consequences. I don't think it's a good idea to design a stateful
> codec by storing data into the encoder/decoder. I would rather store those
> data in a context object, stores within the session. This is what we do for
> the LDAP protocol. So at the end of the day, I don't think it make any sense
> to instanciate encoder/decoder at all ...

That is/was my opinion as well, but in that thread other people
expressed their preference to use stateful decoders...

>
> Thanks Marteen for the pointers !
>
You do it on purpose ! ;-)

Maarten

> --
> --
> cordialement, regards,
> Emmanuel Lécharny
> www.iktek.com
> directory.apache.org
>
>
>

Reply via email to