Howdy!
I would like to know if it's advised to extend a session
EJB? What about the SessionContext, EntityManager? Will those be the same in the supreclass and in subclass or can the container inject different objects for the inherited class?
EJB 3.1 specification, 4.9.2.1 Session Bean Superclasses wrote:A session bean class is permitted to have superclasses that are themselves session bean classes. However, there are no special rules that apply to the processing of annotations or the deployment descriptor for this case. For the purposes of processing a particular session bean class, all superclass processing is identical regardless of whether the superclasses are themselves session bean classes. In this regard, the use of session bean classes as superclasses merely represents a convenient use of implementation inheritance, but does not have component inheritance semantics.
As an example, the client views exposed by a particular session bean are not inherited by a subclass that also happens to define a session bean.
Assuming Foo and Bar are local business interfaces and there is no associated deployment descriptor, session bean A exposes local business interface Foo and session bean B exposes local business interface Bar, but not Foo. Session bean B would need to explicitly include Foo in its set of exposed views for that interface to
apply. For example:
I can deal with the explicitly implementing the interface as in the example - that's not the problem.
If I understand it correctly - there will be
TWO EJB's created - one that is the superclass and the other that is the subclass (both will be accessible i.e. through their remote interfaces).
I just wonder
what about the transactions, thread-safety and EntityManager safety... Do you think such implementation reusing is allowed and advised or should rather be avoided?
Thanks in advance!
Cheers!