On 3/19/07, Harold Combs <[EMAIL PROTECTED]> wrote:
> In my opinion ProtocolDecoders should be stateless and a single instance
should be used for all sessions.  This allows multiple sessions to be
handled with a single ProtocolDecoder instance.

Indeed.  The encode/decode should be pure algorithm.

I agree, but in reality, it sometimes saves a lot of time to create a
codec stateful and create a new codec per session.  I think it highly
depends on the author's preference.

> Even if the protocol must implement a complex state machine with multiple
attributes, this is best done by storing a single "state" object in the
session and using the State Pattern.

I've been working on several such protocols using a proprietary solution via
Conduits+, but I'd like to port them to MINA.  I imagine this will be a
common case--writing a State Machine for the codec, and attaching it to the
session  Does MINA (or some other OSS project) have support for this
directly (maybe defining the state machine and transitions declaratively?

I wrote a generic codec utilities based on state machine in AsyncWeb.
I implemented HTTP on top of it, so it should be able to implement
most protocols quite effectively.  If you are interested, please take
a look here:

https://svn.safehaus.org/repos/asyncweb/trunk/core/src/main/java/org/safehaus/asyncweb/codec/decoder/HttpRequestDecodingState.java

It's just a starting point, so you will have to look around other
related classes, too.

HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to