Hello:
I'm developing an
EJB application that needs to read a configuration file on its deployment. I want to read several parameters from that file and instantiate an immutable object that store or hold such values. Then I want to share this instance across all the existing EJBs. I should be able to use this instance on any method of that EJBs. I want to keep this instance restricted to the scope of the EJB module because it contains information that it's private, so I can't pass it as an argument to the methods.
I'm planning to use a shared single instance because conceptually there is "one configuration" only, so it makes sense in my opinion. Correct me if I'm wrong.
In some way I want something equivalent to the concept of javax.servlet.ServletContext in the "servlet world" which, among many other things, allows to store global attributes.
Is there something similar that I can use in EJB 3.0 and 3.1? For EJB 3.1 I've read that you can inject a javax.ejb.EJBContext object into your EJBs and get/set data through the java.util.Map returned by the method context.getContextData () . Is this right? What about EJB 3.0?
By the way, to achieve the global availability of this instance in the past, I used the singleton implementation explained in the book "Design Patterns". However I've been convinced that this is not the way to go and that's why I'm changing my strategy.
Thank you.