I would build a decoupled event framework, meaning that the event producer would be not bound directly to the event consumer.
This could consist of a EventManager, an EventProducer and an EventListener working together with publish/subscribe semantics.
- When the system starts up (or on the first use) a EventManager is created.
- The EventListener registers itself to receive a specific kind of events.
- The EventProducer is producing events an publishes them to the EventManager
public interface EventManager {
public void postEvent(Event event);
public void addListener(Class eventType, EventListener listener);
}
public interface EventListener {
public void handleEvent(Event event);
}
In this way when you serialize the producer then the EventManager still maintains the list of the subscribed listeners. when the object is deserialized then it can still post events to the EventManager.