Tuesday, April 10, 2012

EJB Questions

Questions that have come to my mind while learning EJB's. Will post links to answers as I find them.
  • How long do session beans live ?
  • How long does an entity bean live ?
  • Can a stateless session bean ever be called from two threads at the same time ?
  • How do we test statefull session beans ?

Stateless Session Beans

Some basic notes I made while reading about stateless session beans

  • session beans contain logic for business processes
  • session beans do not represent data
  • session beans are not shared between different client sessions
  • stateless session beans do not survive jvm or machine crashes
  • session beans are non-persistent objects
  • Stateless session bean ... single request conversation
  • Do not expect a stateless session bean to retain any conversational state from call to call (the exact implementation is container specific). However, a stateless bean may contain state in the form of db connection obejcts, etc. Just be prepared to lose them and have them re-initialized at the container's whim and fancy.
  • Stateless session beans can also provide a web services interface to clients (since EJB 2.1)
  • I was having a hard time understanding the need for Local and Remote interfaces for EJB's... here is an answer http://stackoverflow.com/questions/7621907/what-is-the-purpose-of-home-remote-interfaces-ejb-3-1