That's too bad. A workable solution in EJB 2.1 would be to use a
stateless bean and set the pool size to 1. That will effectively give
you a singleton, though keep in mind it won't be multithreaded so code
appropriately.
-David
On Jun 14, 2009, at 5:17 PM, Sid Sidney wrote:
Thanks David, but we are stuck with Struts and EJB 2.1 at the moment.
--- On Sun, 6/14/09, David Blevins <david.blev...@visi.com> wrote:
From: David Blevins <david.blev...@visi.com>
Subject: Re: using static helper classes within servlets
To: "Tomcat Users List" <users@tomcat.apache.org>
Date: Sunday, June 14, 2009, 5:43 PM
Hey all,
If the goal is to ensure that only one instance is in the webapp,
I'd recommend the new EJB 3.1 bean type @Singleton which is
supported in OpenEJB 3.1 and 3.1.1.
http://openejb.apache.org/3.0/singleton-example.html
http://openejb.apache.org/singleton-ejb.html
Instantiation can be done at startup or lazily. All method access
synchronization is handled for you via
@ConcurrencyManagement(CONTAINER) or by you
@ConcurrencyManagement(BEAN). Regardless of that choice we will
still handle sychronization of instantiation, so double-check-
locking or other things will not be necessary.
-David
On Jun 14, 2009, at 11:19 AM, Martin Gainty wrote:
that would be the simplest solution
i *think* the OP wanted a complete EJB jar implementation (using
either annotations and or ejb-jar.xml)
which can be accomplished with OpenEJB except he would need to know
the type vis-a-vis Stateless/Stateful Local/Remote beforehand
http://openejb.apache.org/3.0/examples.html
thanks,
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de
confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig.
Diese Nachricht dient lediglich dem Austausch von Informationen und
entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten
Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den
Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes
pas le destinataire prévu, nous te demandons avec bonté que pour
satisfaire informez l'expéditeur. N'importe quelle diffusion non
autorisée ou la copie de ceci est interdite. Ce message sert à
l'information seulement et n'aura pas n'importe quel effet
légalement obligatoire. Étant donné que les email peuvent
facilement être sujets à la manipulation, nous ne pouvons accepter
aucune responsabilité pour le contenu fourni.
Date: Sun, 14 Jun 2009 13:01:31 -0400
Subject: Re: using static helper classes within servlets
From: jhmast.develo...@gmail.com
To: users@tomcat.apache.org
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 <pvcsv...@yahoo.com>
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?
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org