I have confusion for the answer for the below question. Can any one please explain...
Given the following @EJB declarations:
@EJB(beanName="foo") Foo ref1;
@EJB(beanName="foo") Foo ref2;
@EJB(beanName="bar") Bar ref3;
@EJB(beanName="bar") Bar ref4;
Where
ejb "foo" is a Stateful Session bean with Local business interface Foo and ejb "bar" is a Stateless Session bean with Local business interface Bar
After injection has completed, what would be the output of the following code?
System.out.println(ref1.equals(ref2));
System.out.println(ref3.equals(ref4));
Answer : false, true
For business interfaces of EJB 3.0 Stateful Session beans, a new Stateful Session bean is created for each @EJB field/method injection. That means ref1 and ref2 refer to two different Stateful Session bean identities.
In the Stateless Session case, the two references are equivalent because they refer to the same business interface of the same bean.
Unlike the 2.x component view, the Object.equals() operation for local and remote business interface references is defined by the EJB specification.