users@jaxb.java.net

Re: com.sun.xml.bind.util.ListImpl

From: <alanyst_at_HOTMAIL.COM>
Date: Tue, 08 Jul 2003 23:58:48 -0600

I recently encountered the limitation of not being able to change the method signature of the collectionType for a schema due to the wrapper List implementation.

In my case, I have defined a List implementation that registers listeners and notifies them when elements are added to or removed from the List. I use (and heavily subclass) the JAXB-generated classes to implement the Model portion of my MVC application, so this additional functionality of the List is essential to permit the View portion of the application to be notified of changes to the list. Unfortunately, since I cannot cast a collection property to the type defined as the collectionType, I cannot add listeners to my nifty Lists.

Would it be possible to provide a getter for the user-defined collectionType in the public interface for the wrapper List? This would of course tie me to the current JAXB implementation, but I'm already way down that road with the superClass and implClass customizations. Then I could cast the collection property to the wrapper List type, and subsequently invoke the (proposed) getter function to get the List implementation I wanted.

Thanks in advance,
Alan

On Mon, 24 Mar 2003 09:36:01 -0800, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM> wrote:

>The reason why the wrapper is used is that the RI needs to be able to intercept
>any change to a List.
>
>This handling is necessary to properly handle element/attribute default
>values. I don't particularly like the way it is, but that's the reason.
>Because this is required by the spec, it's not something we can change
>by ourselves.
>
>Basically this wrapper just looks for invocations to the mutation
>methods, and do something occasionally. But the wrapped real List
>implementation does the real work of storing values.
>
>So if you specify @collectionType, you can change the performance
>characteristic but not the method signature.
>
>regards,
>--
>Kohsuke KAWAGUCHI 408-276-7063 (x17063)
>Sun Microsystems kohsuke.kawaguchi_at_sun.com