where can I store information in stateless EJB ?


EJB programming & troubleshooting: where can I store information in stateless EJB ?

  1. where can I store information in stateless EJB ? (2 messages)

    I need to store information (Map) in Stateless EJB. I need this information to be kept during the session of the EJB (from the point the EJB invoked until it ends). if I were used servlets I could use the ServletContext for that, but I work with EJB. Is there any "best practice" for that ?
  2. How about using a stateful session bean, given that the map needs to be unique for each session?
  3. You should clarify your question... If you refer to information that should be kept in between calls from the same client (the same EJB proxy object), use stateful EJB. I'd suggest reading this: http://www.onjava.com/pub/a/onjava/2001/10/02/ejb.html If you want to have a data object accessible from an EJB, create a classic singleton object and use it from your stateless EJB. This requirement usually arises when you need to hold a cache somewhere. Let other mechanisms (tip: inside your persistence provider) do the caching for you. Aside from the fact that cache is overused IMHO, it is implemented in so many infrastructures that usually you don't need to implement it yourself.