users@jaxb.java.net

Re: Synchronized Methods Extension

From: Franklin, Brian <brian.franklin_at_ciraden.com>
Date: Thu, 10 Jul 2003 12:48:10 -0400

If the difficulty has to do with the whole ListImpl deal, then what if the
synchronizedList call was inside the ListImpl constructor instead? Would
that help? Or is it something to do with how that line is generated in the
content class?

For example, "... = new ListImpl(Collections.synchronizedList( ...whatever
list implementation... ));"

I'm not too fond of using Vectors for this if it could be avoided (although
it's not that big of a deal).

Brian Franklin

P.S. Can't wait until the code is up on java.net. 8-}

-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Thursday, July 10, 2003 11:46 AM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Synchronized Methods Extension


Good to know that it is useful.

"Franklin, Brian" <brian.franklin_at_ciraden.com> wrote:
> Of course, while satisfied, the customer always wants more. 8-} So I
have
> another suggestion for how to enhance it. When the synchronized methods
> extension is active, could all elements that were Lists be initialized
with
> "... = Collections.synchronizedList( new ListImpl(new ArrayList()) );"
> instead of just the ListImpl?
>
> As it is, any time the contents of one of those List properties is
accessed
> (for an add/remove/etc), you have to be sure to synchronize on it. The
> Collections.synchronizedList wrapping would at least narrow that down so
> that you only have to synchronize on the List when iterating.
>
> Let me know what you think, and thanks again for the feature.

I think you could simply write:

    <globalBindings collectionType="java.util.Vector" />

Vector is synchronized, so this should work.

It would be nicer if we could somehow achive the same effect
automatically when the extension is used, but I'm afraid that would be
difficult.

regards,
--
Kohsuke Kawaguchi                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com