EJB3 - obtaining bean via injection vs lookup - what are the differences, implications, gotchas?
问题 There are two ways I know of to obtain an EJB instance: dependency injection in servlets and EJBs via the @EJB annotation JNDI lookup via Context.lookup anywhere What are the differences, implications and gotchas in using either of these approaches? Are they the same? Is dependency injection faster than lookup? What about transaction handling and object lifecycle management? Things I'm aware of include: annotation works with servlets and and EJBs only convenient syntax container independent