The shortest answer to your question is of course it is a good idea to make it possible for EJBs to work like Servlets and in EJB 3.1 we added a component that can do exactly that: @Singleton
An @Singleton bean can be multi-threaded like a servlet, by either:
- Using
@ConcurrencyManagement(BEAN)
- Using
@ConcurrencyManagement(CONTAINER) along with @Lock(READ) on methods where concurrency is desired and @Lock(WRITE) on methods that are not thread safe.
One other thing that Servlets have had for years that EJBs never had was <load-on-startup> which allows a Servlet to load eagerly and do work at application start.
To match the Servlet <load-on-start> we added the @Startup annotation which can be added to any @Singleton EJB and will cause it to start when the application starts. These beans will have their @PostConstruct method called when the application starts and their @PreDestroy called when the application shuts down.
Rather than use a number (<load-on-startup>1</load-on-startup>) to dictate the order in which beans annotated with @Startup start, you can annotate beans with @DependsOn and specify a list of beans that need to start before the annotated bean.
And a far less known and understood aspect we did in EJB 3.1 to align Servlets and EJBs was of course to allow EJBs to be packaged inside of .war files -- that's not the less known part -- and when we did that we quietly changed the definition of java:comp/env to match the Servlet approach.
Prior to EJB 3.1 there was no possible way to have two EJBs share a java:comp/env namespace (java:comp/env is bean-scoped in the EJB spec). Servlets, by contrast, never had any way for individual Servlets to have their own private java:comp/env namespace (java:comp/env is module-scoped in the Servlet spec). So in EJB 3.1 an EJB that is packed in a war will have the same module-scoped java:comp/env namespace as all other Servlets and EJBs in the webapp, which is a pretty big contrast to the bean-scoped java:comp/env namespace that EJBs get when packed in an EAR outside of a war. We debated on that one for weeks.
Nice little bit of beer-time trivial to quiz your friends with.