Search code examples
javadependency-injectionejbstatic-methodsstateless-session-bean

What are the advantages to using a Stateless Bean and DI instead of a POJO and Static Methods


Why would it be beneficial to use stateless beans and dependancy injection over just a simple pojo with static methods? In other words, are the advantages to an EJB purely because of the underlying container benefits like threading, transactions, etc..?


Solution

  • A POJO with a bunch of static methods can't be easily mocked out for testing code that depends on it whereas a stateless singleton can.