Hi all,
well singletons are hard to implement in EJB but what about using a Stateless Session Bean with max-cache setting to 1 ?(for container that support it). This way the container will create a single instance and serialize access to it....what do you think about it??
Francesco
-
Using SB as singletons (7 messages)
- Posted by: fmarchioni fmarchioni
- Posted on: March 25 2002 05:17 EST
Threaded Messages (7)
- Using SB as singletons by David Clarke on March 25 2002 07:44 EST
- Using SB as singletons by Nazilin Vaheed on April 01 2002 22:54 EST
- Using SB as singletons by Alex Pisarev on April 03 2002 04:02 EST
-
Using SB as singletons by David Clarke on April 04 2002 09:42 EST
-
Using SB as singletons by Alex Pisarev on April 05 2002 03:46 EST
- Using SB as singletons by Nazilin Vaheed on April 08 2002 12:18 EDT
- Using SB as singletons by David Clarke on April 09 2002 05:36 EDT
-
Using SB as singletons by Alex Pisarev on April 05 2002 03:46 EST
- Using SB as singletons by Nazilin Vaheed on April 01 2002 22:54 EST
-
Using SB as singletons[ Go to top ]
- Posted by: David Clarke
- Posted on: March 25 2002 07:44 EST
- in response to fmarchioni fmarchioni
I'm kinda confused. I thought that the whole purpose of singleton classes is that they retain their state between accesses, and obviously there is only one of them. This is quite contrary to the purpose of StateLESS session beans, where you should assume that state would be destroyed between accesses. Surely the best way would just be to have as many session beans as you like and access a normal singleton class from them. Threading might be an issue, but this can be dealt with. -
Using SB as singletons[ Go to top ]
- Posted by: Nazilin Vaheed
- Posted on: April 01 2002 22:54 EST
- in response to David Clarke
Corretc me if I am wrong:
What about keeping a normnal stateless seesion bean as an application level (scope) variable in the JSP.
nazilin
-
Using SB as singletons[ Go to top ]
- Posted by: Alex Pisarev
- Posted on: April 03 2002 04:02 EST
- in response to Nazilin Vaheed
Nazilin,
Doesn't that mean that all instances of particular jsp/servlet will have an access to one specific copy of SLSB? You cannot access the same instance of SLSB from two different places.
Alex. -
Using SB as singletons[ Go to top ]
- Posted by: David Clarke
- Posted on: April 04 2002 09:42 EST
- in response to Nazilin Vaheed
Nazillin
Yes, you can do this, but I don't think that invalidates my point. Holding Bean references is common practice. If you hold the bean reference in the JSP, you cannot make any assumptions about its state from one invocation to the next. The SLSB may have been passivated/reactivated between invocations, or as Alex says, another JSP instance may have used the Bean.
Alex, I don't think that's right. You CAN access the same instance from two places, just not at the same time. -
Using SB as singletons[ Go to top ]
- Posted by: Alex Pisarev
- Posted on: April 05 2002 03:46 EST
- in response to David Clarke
David,
Yes, that's exactly what I meant - the same time is a keyword here. But who gives you guarantee that it will not be used at the same time?
Alex. -
Using SB as singletons[ Go to top ]
- Posted by: Nazilin Vaheed
- Posted on: April 08 2002 00:18 EDT
- in response to Alex Pisarev
Yes I agree , U guys are right.
thanks,
Nazilin. -
Using SB as singletons[ Go to top ]
- Posted by: David Clarke
- Posted on: April 09 2002 05:36 EDT
- in response to Alex Pisarev
Alex,
I guess <b>single thread model</b> is the only way.
But this just proves my original point - a single SSB is NOT the way to implement a singleton function.