Type: New Feature
Resolution: Won't Fix
Affects Version/s: 3.2
Fix Version/s: 3.2
The use cases for injection of Stateful session beans into container-managed component types (Stateless, Singleton, MDBs, Servlets) are extremely limited due to the fact that injection occurs when the component class is constructed. In order to get an invocation-based stateful bean, applications must either inject and use 2.x homes or do a JNDI lookup.
Provide a type-safe interface for creating stateful session beans that is decoupled from JNDI/EJBContext lookup. The interface would be similar to 2.x-style homes but without requiring the bean provider to specify an explicit home interface.
The interface looks something like this:
This interface is bound into the java:module/app/global namespace for stateful beans using this new interface.
ejb-ref definition in the DD:
1. Injection and type safety - Again, SFSB's can't be usefully injected into most container-managed component types, so you must use lookup, which requires a cast.
2. Performance - eliminates the need for a lookup on each client invocation. Also decouples SFSB creation performance from JNDI, since lookup performance is limited by/bound to the performance of naming.
3. A means for enabling use of stateless beans with OSGi service registry - Vendors are starting to experiment with EJBs in OSGi service registry, which has no mechanism for creating multiple interfaces (ServiceFactory doesn't work since it's once-per-bundle.)
Other considerations/possible additions:
1. A create method which takes a variable argument list(Object... args). It would not be type-safe, but would provide a path to support @Init.
2. A RemoteSessionFactory for business RMI that throws RemoteException.
3. A ManagedBeanFactory that provides a factory interface for @ManagedBean. Would need to find a home for that interface (!javax.annotations). Also, would require coordination with managed beans spec.