I've not done anything with EJBs and I'm not sure what exactly you mean by
static "properties". I have however dealt with reducing instantiations in
servlets. I simply created a BeanBag class with static methods to each one
of my beans; these are not "proper" beans, but where simply objects that
were formerly used in JSP via the jsp:useBean directive.
Here is the general pattern:
class BeanBag {
private static SomeBean someBean = null;
public static synchronized getSomeBean() {
if (someBean == null) someBean = new SomeBean();
return someBean;
}
}
I have now numerous Servlets, JSPs and POJOs that use BeanBag to obtain
singleton instances of my beans. Its worked great for me.
On Sun, Jun 14, 2009 at 8:28 AM, Sid Sidney <[email protected]> wrote:
>
>
>
> HI,
>
>
>
> In my web app, my servlets user several delegate classes that connect
> to ejbs (session beans.) I was thinking
> about putting these delegates into a helper class as static properties.
> That way my servlets can just reference the same delegates. I
> don't want to have to create a new instance of a delegate with every
> request that my servlet(s) handles.
>
>
>
> However, I'm wondering if this will cause synchronization issues with
> multiple requests being handled, as our site handles a heavy load of
> requests. Any suggestions would be appreciated?
>
>
>