Thanks Chuck, just one more question: do I really need synchronization at
all?
These Beans basically work like this:
getApple(int appleID) {
purgeIfTimeout(); //calls appleMap.clear() if we've timed out
if (appleMap.containsKey(String.valueOf(appleID)) {
return (Apple)appleMap.get(String.valueOf(appleID);
} else {
Apple a = FruitDB.getApple(appleID); //this is where the database
interaction takes place
if (a != null) appleMap.put(String.valueOf(appleID), a);
return a;
}
}
Is synchronization really called for here, either around the getITEM()
methods inside the beans or around the methods in BeanBag that return the
bean?
On Tue, Jan 6, 2009 at 11:14 AM, Caldarale, Charles R <
[email protected]> wrote:
> > From: Jonathan Mast [mailto:[email protected]]
> > Subject: replacement for useBean directive
>
> > wouldn't making the methods in BeanBag synchronized be
> > a better approach?
>
> Definitely. Centralize the required synchronization rather than burdening
> each caller with it.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>