0) I still don't know where one goes to get an official clarification of the
spec.  Does anyone know the answer to that?  Is the answer send to ejb-interest
and wait for clarification from a sun representative?

Still unanswered are:

1) What sections of the spec  apply only to stateful session beans?
2)  How does one know that 6.5.6 applies only to stateful session beans and not stateless session beans?
 

dan benanav wrote:

Where can I ge definitive answers and clarifications of the ejb spec?

More specifically I have the following question and would like an "official" answer to it.

1) The spec states:
a) All session objects of the same stateless session bean within the same home have the same object identity, which is assigned by the container.

and also

b) Clients are not allowed to make concurrent calls to a session object. If a client-invoked business method is in progress on an instance when another client-invoked call, from the same or different client, arrives at the same instance, the container must throw the java.rmi.RemoteException to the second client.

If the sense of identity in a) and b) are the same, then the two statements taken together would mean that only one client can invoke a method on a stateless session bean at a time.  For example the following code could generate an error.

myStatelessHome = (MyStatelessHome)narrow(initialContext.lookup(...), MyStatelessHome.class);
stateless1 = myStatelessHome.create();
stateless2 = myStatelessHome.create()
(new MyThread(stateless1)).start();
(new MyThread(stateless2)).start();

public class MyThread extends Thread
{
    private MyStateless myStateless;
    public MyThread(MyStateless x)
   {
      this.myStateless = x;
   }
    public void run()
   {
        //call methods on myStateless.
   }
}

But that goes against much of what the spec states about using multiple instances of stateless session beans.  If the above reasoning where true than multiple instances would never be required since concurrent calls would only generate an exception.

So what is the meaning of b).

1) It doesn't apply to stateless session beans at all.  It is legal for concurrently invoke methods on stateless session beans.  If so does the container need to serialize the calls?

2) It applies but the sense of identity is the normal sense and not that described in a).

For example the code above would be OK but the following would not.

myStatelessHome = (MyStatelessHome)narrow(initialContext.lookup(...), MyStatelessHome.class);
stateless = myStatelessHome.create();
(new MyThread(stateless)).start();
(new MyThread(stateless)).start();
 

Reply via email to