users@jaxb.java.net

Re: Is Marshall thread safe?

From: Felipe Gaucho <fgaucho_at_gmail.com>
Date: Wed, 26 Aug 2009 16:21:05 +0200

You can also use "stax" to stream your objects instead of load them in
memory...

On 26.08.2009, at 16:06, jyoti chhabra <jyoti.chhabra_at_gmail.com> wrote:

> Hey,
>
> I am using Jaxb in my application. Currently it's cpu intensive.
> This is how i use it :
> JAXBContext jaxbContext =
> JAXBContext.newInstance(packageName);
> StringWriter xmlStringWriter = new StringWriter();
> Marshaller marshaller = jaxbContext.createMarshaller();
> marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
> new Boolean(true));
> marshaller.marshal(enqueueObj, xmlStringWriter);
>
> enqueueObj is input to function and if of type JAXBElement<T>
>
> I profile my code and found that creation of jaxbContext is costly
> compared to other methods.
> What i was wondering is that could i make jaxbContext as a static
> variable, assuming there is only 1 kind of packageName.
> Is the creation of marshaller thread safe? Is there any limit to how
> many marshaller could i create? Would it spawn a new thread for it?
> What would be a better way to improve performance. Currently size of
> my object is from couple of Kbs to Mb. But i do expect it to grow to
> couple of Mbs.
>
> Appreciate any pointers.
>
> Regards,
> Jyoti
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>