As you pointed out XJC must be informed which methods (except the
methods in java.util.List) which mutates the List. This can be done
though configuration i.e. you have to configure which of your methods
which mutate the list. XJC would use the list of method names (I think
signatures would not be necessary) and override them with intercepting
code, all mutating methods in java.util.List would be overridden
automatically.
An example of how this could be done is:
collectionType="java.util.ArrayList" - standard list, automatically
overridden
collectionType="MyList(mySuperMutationMethod)" - uses a list with a
custom mutator
It should also be noted that all mutators which end up in calling e.g.
"add" would be automatically handled (because of polymorphism) so there
is no need to explicitly declare it as a mutator.
In my opinion, the solution above is very general; it both allows
plugging in a standard list class without modification, the solution
also allows for programs to exploit custom list implementations.
Regarding your suggestion:
The solution you suggested, i.e. not wrapping the list if there are no
default attributes works fine, at least for me. I do not use default
values often.
Erik
-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: den 3 november 2003 16:29
To: users_at_jaxb.dev.java.net
Subject: Re: The com.sun.xml.bind.util.ListImpl story
I think the easiest thing we can do is to use the wrapper only when the
default value is indeed specified.
> Another solution which would have the desired properties described
> above is to let JAXB auto generate a subclass (during schema
> compilation) of the desired list implementation class.
Your idea is interesting, but I have a question. How do XJC know which
are mutation methods on your custom class?
Like if I do:
class MyList extends ArrayList {
void mySuperMutationMethod() {
...
}
}
How does XJC know that mySuperMutationMethod needs interception?
I understand your frustration, though. Like I wrote, I don't like the
behavior either.
regards,
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net