File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Stateful Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Stateful Bean" Watch "Stateful Bean" New topic

Stateful Bean

s rao

Joined: Mar 12, 2002
Posts: 15
I have 2 questions:
1. What will happen if I put some parameters inside ejbCreate() for a Stateless Bean. Will it compile/deploy.
2. Suppose if I am holding a reference of a stateless bean inside a stateful bean. what will happen during passivation. Is it right to do such a thing??
Please let me know the answers to the above.
JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
The answer to your first question:
Stateless session bean can hold state, but doesn�t hold client-specific state because a client is not guaranteed to use the same session bean instance for different method invocations. The container has the freedom to swap stateless instances back and forth between clients. It means after each method invocation, the stateless EJB clears itself out from the information of the past invocations, therefore, using a stateless EJB, it does not make sense to call the create method with a parameter because immediately after the call, the parameter will be cleared. Client-independent data can be cached in a stateless bean if:
The information being cached will never change, and
The application can tolerate a copy of the same cacher repeated in each stateless bean instance that the container creates
To answer your second question:
The container preserves remote references to other beans with the conversational state when the stateful session bean is passivated. However, I do not understand why your stateful session bean refers to a stateless session bean.
I agree. Here's the link:
subject: Stateful Bean
It's not a secret anymore!