commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: [Betwixt] is betwixt thread safe ?
Date Tue, 16 Aug 2011 08:45:06 GMT
Hi Patrick,
indeed, when ingesting XML documents you have to make sure the
Digester instance is not used in other running threads; sometimes
creating new BeanReader instances could require time, that's why I
suggested you using a Pool of BeanReader.
Sure, paste your code on pastie.org or similar (it makes more readable
than in the email) and I'll more than glad to help you!
Have a nice day, all the best!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/



On Mon, Aug 15, 2011 at 9:02 PM, patrick daures
<patrick.daures@gmail.com> wrote:
> Hi again,
> From what I found on the web, it's not safe to reuse the same instance of a
> Digester between different threads.
> But what I'm currently doing is creating a new instance of BeanReader (which
> extends the Digester class) for every call, which means that I shouldn't
> have any multithreading issue with the Digester lib.
> I will find more information about the lib's version and maybe send some
> code so you can tell me what is the problem.
>
> Thanks
>
> Patrick
>
> 2011/8/15 Simone Tripodi <simonetripodi@apache.org>
>
>> Hi Patrick,
>> sorry for the misunderstanding I made, for deserializer I meant the
>> BeanReader :P
>> Sorry again, have a nice day!
>> Simo
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>>
>>
>> On Mon, Aug 15, 2011 at 9:57 AM, patrick daures
>> <patrick.daures@gmail.com> wrote:
>> > Hi,
>> > I have another question to ask you, you said "get/release a deserializer
>> for
>> > each request".
>> > For the moment, I don't use any deserializer, I only use BeanReader and
>> > BeanWriter objects.
>> > What I do is create a new instance of one of this object every time I
>> need
>> > to serialize / unserialize data.
>> > Could you please give me an example of code using this "deserializer" to
>> > help me to write the code needed ?
>> >
>> > Thank you
>> >
>> > Patrick
>> >
>> > 2011/8/14 Simone Tripodi <simonetripodi@apache.org>
>> >
>> >> Hi Patrick!
>> >> you're welcome, let us know about your results!
>> >> Have  nice day,
>> >> Simo
>> >>
>> >> http://people.apache.org/~simonetripodi/
>> >> http://www.99soft.org/
>> >>
>> >>
>> >>
>> >> On Sun, Aug 14, 2011 at 8:54 PM, Patrick Daures
>> >> <patrick.daures@gmail.com> wrote:
>> >> > Ok, thank you very much for your advice.
>> >> > I will take the 3rd solution
>> >> >
>> >> > Patrick
>> >> >
>> >> > Le 14 août 2011 à 20:24, Simone Tripodi a écrit :
>> >> >
>> >> >> Hi Patrick!!!
>> >> >> for the XML -> Object mapping, Betwixt relies on Digester, which
is
>> >> >> NOT thread safe.
>> >> >> You have 3 options:
>> >> >>
>> >> >> - synchronize the blocks as you did - anyway it's not the best
way
>> IMHO;
>> >> >> - re-create the deserializer for each request;
>> >> >> - use Betwixt in combination with commons-pool, get/release a
>> >> >> deserializer for each request (same pattern you would do with JDBC
>> >> >> Connection in a DataSource).
>> >> >>
>> >> >> My preferred is the #3, but it's just a matter of tastes ;)
>> >> >> Have a nice day, all the best!!!
>> >> >> Simo
>> >> >>
>> >> >> http://people.apache.org/~simonetripodi/
>> >> >> http://www.99soft.org/
>> >> >>
>> >> >>
>> >> >>
>> >> >> On Sat, Aug 13, 2011 at 8:31 PM, patrick daures
>> >> >> <patrick.daures@gmail.com> wrote:
>> >> >>> Hi, i'm currently using betwixt in produit to serialize and
>> unserialize
>> >> >>> objects in XML. Each thread is using a new instance of beanreader
to
>> >> >>> unserialize XML. I had a problem with my application, i added
a
>> >> synchronized
>> >> >>> around the call to the betwixt lib and everything went fine.
Maybe
>> the
>> >> >>> problem comes from my app, but i wanted to be sure the lib
is thread
>> >> safe.
>> >> >>> Thanks.
>> >> >>>
>> >> >>
>> >> >> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> >> For additional commands, e-mail: user-help@commons.apache.org
>> >> >>
>> >> >
>> >> >
>> >> > ---------------------------------------------------------------------
>> >> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> > For additional commands, e-mail: user-help@commons.apache.org
>> >> >
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> >> For additional commands, e-mail: user-help@commons.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message