Is it allowed (and good practice) to hold some shared informations in our application by using a Singleton Session Bean inside a Stateless Session Bean?
The SSB will be injected into the SLSB.
@Stateless
public class MySLSB {
@Inject
MySSB mySSB;
-
@Singleton
@Lock(READ)
public class MySSB implements Serializable {
private static final long serialVersionUID = 1L;
It is more than allowed. Using Singleton injections in your stateless or statefull EJBs would allow you to call business methods on your SSB in your SLSB. One of the trivial advantages is using SSB concurrent capabilities. In your example all of your method calls toward you SSB would be locked on Read and that means all your threads would be accessing your SSB methods on Read mode unless a thread is holding a lock on Write.