First of all, I am newbie in J2EE. I have a doubt about EJB. I don't know how to share objects (if possible) within EJB. I want to know if I can use any kind of ?shared memory? to store some objects to be shared and access from any EJB instance running on the same server.
I have some information stored in a database, and I want to avoid accessing the database every time an EJB need some information store on it (that information doesn?t change very often). I have some beans managing the database and some other beans that depend on some of the data stored in the database. I want the managing bean to store some data in a "shared memory", and leave it there without any modification until the data in the database will be changed (the managing beans are fully responsible for the database, so if there is any modification in the database they can modify the stored data in the "shared memory"). Then I want some other beans to have access to that "shared memory" so they don?t have to access the database directly...
I am using JBoss AS 4.0.5 (with EJB 3.0 specification), session beans, message-driven beans and entity beans for persistence (MySQL server 5). I have looked the specification and some books that I have, and I couldn?t find anything like the javax.servlet.ServletContext object that exist in the web tier. In this object I can bind an object to a given attribute name in this servlet context, and any other servlet from the same context can get access to it by using the attribute name. For example;
//Storing the object in the context
//Getting the stored object from the context
I hope that I have made myself clear, I am Spanish and it?s a little difficult for me to explain myself in English? as I told you I am a beginner in J2EE so I am a little confuse right now, and I might be quite wrong on anything that I have said in this post.
Thanks in advanced