Forums Register Login

doubt : stateless bean dependency injection

+Pie Number of slices to send: Send
I came across a note where it says obtaining two instances of a stateless bean via dependency injection will always be equal.

I tested it and it is true.

@EJB MySLBeanLocal mySLBean1;
@EJB MySLBeanLocal mySLBean2;

mySLBean1.equals(mySLBean2) always returns true.

But I am not sure what is the reason behind it? Isn't that while invoking stateless bean like that it is always upto the container to return which object from pool?

Any clarification will be really helpful.
+Pie Number of slices to send: Send
As per the EJB specification, the container always maintains equal instances of the Stateless Session beans in its pool. There is no state associated with Stateless session beans. Can you now make it out?
+Pie Number of slices to send: Send
Hi

In the ejb 3.0 specification on page 47 (3.4.5.2 Stateless Session Beans) you can find

The equals method always returns true when used to compare references to the same business interface type of the same session bean. Session bean references to either different business interface types or different session beans will not be equal.



I hope that this helps, in the same document - somewhere upper - is they describe the equals for statefull.

Regards
Mihai
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 876 times.
Similar Threads
Question regarding Business Delegate, Stateless Session Bean and Entity Bean in SCEA Part 2
annotations for ejb-name and transaction-type
Dependency Injection Problem !!!
EJB staless/stateful beans and JNDI
Basic Questions on EJB3
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:17:52.