The section germain to the original question is 7.11.8 (2.0 spec) "Non-reentrant instances"
The container must ensure that only one thread can be executing
an instance at any time.

As far as a stateless bean having member variables, you are correct in that it isn't prohibited so long as the member variables don't hold conversational state.

The example code is a bit contrived for simplicities sake. More typical things to keep as members might be DataSource objects (please, not Connection objects), the Home of another EJB, etc. Basically, things that carry some initialization burden but aren't dependent on any particular client.

-danch

Lucas McGregor wrote:
I thought that the spec didn't allow this either, but I couldn't find any
section saying such. Unless this is part of the conversational state as
defined by section 7.4. But the example doesn't use the variable to
communicate between method calls, nor is it static.

BUt it still doesn't seem correct to me. Would you be so kind as to point
out the parts of teh EJB spec I should review.
Thanks for time,
Lucas


-----Original Message-----
From: Rajeshwar Rao V [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 7:23 PM
To: [EMAIL PROTECTED]
Subject: RE: [JBoss-user] Stateless session beans


No. As per EJB spec..
But Yes,ur code _may_ work fine with JBoss.
Is Jboss not following EJB spec?

-----Original Message-----
From: Eric Jain [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 27, 2003 10:45 PM
To: jboss-user
Subject: [JBoss-user] Stateless session beans


Are stateless session beans threadsafe, i.e does the following code behave
as expected?

public class TestBean
implements SessionBean
{
private int tmp;

// should always return true
public boolean f()
{
tmp = 1;
boolean b = tmp == 1;
tmp = 0;
return b;
}
}


--
Eric Jain



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to