users@jaxb.java.net

Re: Lazy Init Collections in Generated Classes

From: Nick Heudecker <nheudecker_at_gmail.com>
Date: Thu, 3 Nov 2011 23:37:52 -0700

Do you think I can address this with an XJC extension?

On Thu, Nov 3, 2011 at 11:24 PM, Wolfgang Laun <wolfgang.laun_at_gmail.com>wrote:

>
>
> On 3 November 2011 22:52, Nick Heudecker <nheudecker_at_gmail.com> wrote:
>
>> I'm sure this has been asked before but my searches haven't turned up
>> anything.
>
>
> I'm quite sure this hasn't come up during the last few years.
>
>
>> I need a way to initialize collection objects lazily. My XSDs (which I
>> don't control) have the following for all objects:
>>
>> <xsd:anyAttribute namespace="##any" processContents="lax"/>
>>
>> Resulting in lots of the following:
>>
>> public class Foo {
>> private Map<QName, String> otherAttributes = new HashMap<QName,
>> String>();
>>
>> // ....
>> }
>>
>> How can I tell XJC to not create the otherAttributes map until the
>> 'getOtherAttributes()' method is called? Ordinarily this wouldn't be a
>> problem but I'm seeing a lot of needless object creation under load.
>
>
> Don't think you can. But it stands to reason to expect lazy initialization
> for this Map as well since it's being done for List objects, so you might
> raise an issue.
>
> -W
>
>>
>>
>> Thanks for your time.
>>
>
>