Synchronization of Stateless Session bean instances. Is there anyway by which we can update/modify (not on server start up but at actual application run time) value of instance variables of ll stateless session bean instances present in the pool??
Additional NoteThis is a little messy because you don't always know how many instances the EJB Container has deployed in memory. Furthermore, you need to broadcast this message to each and every instance. Session bean were not designed to be called individually because the Container dynamically assigns an instance to handle the method invocation before each invocation.
This is something related to snchronizing all the instances. If a user modify a variable in Stateless Session Bean can it be reflected to all other instances in the pool? so that if next/other user access the variable he/she will get the updated value.
Because of this, I would suggest you move the data contained in your instance variables outside the session bean. It could be placed into a database table which is accessed by a read-only entity bean.
The session bean can read the values before every request. Plus, since these are read-only entity beans, the values are cached in memory (provided you have a big enough cache) and the database is only accessed once or after a configurable amount of time.
This solution also works in a clustered environment and is portable across other app servers.
If you don't like entity beans, you can always use static objects to store the data of the instance variables. These would be stored in a static object in memory thereby accessible and shareable by any and all instances of the session bean. This is a more complex solution and you need to understand how classloaders work. Plus, it may not work in a cluster nor be portable.