I have implemented an EJB state machine for monitoring business processes.. and need to send events to listeners (over RMI).
I would like to use a stateless session bean as the event dispatcher but am not sure where to persist the list of listeners in the session bean?
Normally I would use a singleton event manager, how do I do this inside the container?
I have implemented something very similiar. I used
a DB to store my event listeners. It worked just fine.
Have you evaluated JMS.
If you where to implement the dispatcher, one option you have is to presist the list of observers in the database.
We used a combination of a Mediator and an Observer to implement this. The Mediator is a singleton to which interested Observers register. The source of the events simply notifies the Mediator which in turn does a call-back on all registered Observers/Listeners.
In your case, just wrap the Mediator in a stateless session bean. The Mediator should be brought up when the application starts up - say you could have a startup servlet that creates an instance of the Mediator in the init() and maintains the reference releasing it only in the destroy().