Can also look at org.apache.mina.filter.codec.serialization package. I haven't used it, but seems like a good fit for Object Serialization needs.
thanks ashish On Wed, Jul 28, 2010 at 1:13 PM, Emmanuel Lecharny <elecha...@gmail.com> wrote: > On 7/28/10 4:58 AM, amit shah wrote: >> >> Hello, > > Hi, > >> I understand that mina provides a framework to allow the client, >> server communicate through java objects by using the protocol codec >> factory, >> encoder& decoder. >> Since the IoBuffer provides methods to get primitive objects like int, >> string, double etc, how can we pass java collection objects like map. For >> e.g. below is my pojo class which has to be encoded& decoded. >> >> class MyClass { >> private String name; >> private Map<String, Integer> nameVsIdMap; >> private Map<String, List<Integer>> nameVsNumbers; >> >> ..... >> } >> >> Any help would be appreciated. > > You have to write yur own encoder/decoder to handle those objects.It's not > that complicated, you can follow > http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html to > get a clue about how to do that. > > Basically, the decoder will receive IoBuffer, and you will create Objects > out of that, and symetrically, the encoder will take Objects and produce an > Iobuffer. > > There are a few tricks you have to be aware of for the decoder : > - messages can be fragmented : you may not receive all the needed bytes to > generate a full object, so you have to deal with that. You can pass the > serialized object's size before the serialized object itself in orer to deal > with this issue. Note that even this size can be fragmented. Store any > temporary data into the session attributes until you have got what you need > to produce an object, then when done, call the next filter. > - you may have more than one object in the received IoBuffer, so don't > forget to iterate on the buffer until it's empty. > > Hope it helps. > > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > > -- thanks ashish Blog: http://www.ashishpaliwal.com/blog My Photo Galleries: http://www.pbase.com/ashishpaliwal