tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Mast" <jhmast.develo...@gmail.com>
Subject Re: replacement for useBean directive
Date Tue, 06 Jan 2009 17:46:48 GMT
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 <
Chuck.Caldarale@unisys.com> wrote:

> > From: Jonathan Mast [mailto:jhmast.developer@gmail.com]
> > 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message