Hi and Happy new year (for those the year starts today). Inline reply
Le 31 déc. 2012 09:02, "Ashish" <[email protected]> a écrit : > > On Mon, Dec 31, 2012 at 12:25 PM, Julien Vermillard > <[email protected]>wrote: > > > Hi, > > > > Since few year, I stopped to use the MINA ProtocolCodecFilter and > > associated stuff (CumulativeCodec..). for implementing my own codec > > independent of MINA. > > > > :) > > > > > > it's just a service consuming ByteBuffer and pushing decoded POJO in a > > callback. The point is to be independent of MINA for example, parse & save > > files using the codec, or simply implement an HTTP version of the transport > > using old style servlet. > > > > Agree. The implementation need not be tied with MINA. You can expect > ByteBuffer(s) and can decode. > I didn't quite get the statement " or simply implement an HTTP version of > the transport using old style servlet."? > For example some protocols support both plain TCP and HTTP. If you use a "ProtocolCodecFilter" which is a MINA filter for implementing the TCP transport it will be tricky to reuse it in a servlet (without MINA) for implementing an HTTP based version. > With this approach accumulation and decoding becomes one. We can also think > about accumulating as one step and decoding as another, which may be useful > for protocols which specify length or fixed headers. User provides how to > find length, Framework shall accumulate bytes and once done, can pass on > complete PDU for decoding. This might be an overhead in some cases. The > idea is to make life easy for the framework user. Or we can provide some > helper around our core Codec framework. Thoughts? > Yes, that's the idea, most UDP based protocols won't need accumulation, but most of TCP based will need it. > > > Basically a decoder looks like : https://gist.github.com/4417934 > > One is instantiated by session. > > > > Would be worth making it accumulateAndDecode() > > public interface Decoder<PDU> { > > What is PDU? It's the custom decoded POJO or an abstraction that we want to > build. > Exactly PDU : Protocol Data Unit , your protocol message type. > > > > I'm quite happy with that and I think we should not port the old > > ProtocolCodeFilter to MINA 3.0 and replace it with a independent MINA async > > decoder framework (consuming BB, accumulating if needed and producing > > pojo). > > > > Julien > > > > Not sure, but do we see scenarios where we might need reference to > IoSession, while decoding? > Nothing comes to my mind right now, but it's year end :) > You perhaps need some session attached data like security information gathered by another filter ? Ideally you should not depend on the sessionfor decoding, but some protocols are really horribles:-) . I think we should try to make it independent of the session and see if it's working for all the cases. Julien
