alanyst_at_HOTMAIL.COM wrote:
> 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.
I see. Like I said, I don't like the way we use our wrapper around List,
so you gave me nice ammo for making a case against it.
I know one more case where it breaks, so I might be able to do something
about this in a long run. But this needs to go through the expert group,
so it's unlikely something will happen soon.
> 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.
Meanwhile, in a shorter time span, I think you might be able to reset
List from your subclass. That is, if the base class is like
class FooImpl
{
protected List _X = new ListImpl(new MyList());
}
You could do:
class MyFooImpl
{
MyList _trueX = new MyList();
MyFooImpl() {
_X = new ListImpl(_trueX);
}
}
This is still ugly, but I hope it lets you work around the problem.
regards,
--
Kohsuke Kawaguchi 408-276-7063 (x17063)
Sun Microsystems kohsuke.kawaguchi_at_sun.com