directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daune...@daune-consult.com
Subject Re: [mina] sample with XML
Date Sat, 07 Jan 2006 09:29:45 GMT
Maarten Bosteels <m.bosteels@pandora.be> a écrit :

> Hi,
>
> We use mina for transport and xmlbeans (http://xmlbeans.apache.org) 
> to parse and generate xml documents.
> Our ProtocolDecoder just reads an array of bytes
> and the ProtocolHandler passes these bytes on to the xmlparser.
>
> The protocol (EPP) is pretty simple:
> * 4 bytes indicating the total length of the message
> * (length - 4) bytes of xml data
>
> Academic question:  If your protocol doesn't have a length header and 
> you don't know the
> byte encoding used by the incoming xml, how can you know when a 
> message is complete ?

Maarten,

I use Mina (in Belgium too, for info) for a binary protocol, and we add 
4 bytes
too. This makes our protocol more robust, and decoding easier.

J-F

> Maarten
>
> Chris Allen wrote:
>
>> Hi,
>>
>> I ended up using Jdom for paring the XML in my proxy server for Jabber
>> using MINA.  It worked very well.  Basically you can create a
>> ProtocolCodecFactory that uses a custom ProtocolDecoder.  The decoder
>> will have to overwrite the decode() method where it will convert the
>> ByteBuffer that it receives into an org.jdom.Document instance.  You
>> can either do the parsing of the XML there or do it in your
>> IoHandlerAdapter's messageReceived() method.
>>
>> There is a good example of using a ProtocolCodecFactory for converting
>> the messages to Strings on the MINA website; it's basically the same
>> thing, except you convert it into either a Jdom Document like I'm
>> doing or one of the others that Vinod suggested.  Take a look at the
>> package org.apache.mina.filter.codec.textline for an example:
>> http://directory.apache.org/subprojects/network/xref/org/apache/mina/filter/codec/textline/package-summary.html
>>
>> I hope that helps.
>>
>> -Chris
>>
>> On 1/6/06, Vinod Panicker <vinod.p@gmail.com> wrote:
>>
>>> On 1/6/06, sylvain.eche@bnpparibas.com <sylvain.eche@bnpparibas.com> wrote:
>>>
>>>> Hi all
>>>>
>>>> Is there any source code that implement XML parsing for Mina ?
>>>> my Aim is to implement an XML parsing (as a decoder) that transform XML in
>>>> object and send this objects to the handler.
>>>> Has anyone see some sample about that ?
>>>>
>>> Might sound silly, but have you considered using SAX / DOM / XPath for
>>> your XML parsing?  That will give you ready made objects that you can
>>> pass to your handler.
>>>
>>> Regards,
>>> Vinod.
>>>
>>>
>>
>>
>>
>
>




Mime
View raw message