I basically would like that a service method fire events related to what was inserted, updated or deleted in the DAO layer and any other arbritrary events I might fire explicitly in my service layer. These events should somehow be available in my caller. So the code would be like
Caller:
serviceInstance.addListener(eventListener);
serviceInstance.doSomething();
if (eventListener.isEvent1Fired()) {
...
}
} finally {
serviceInstance.removeListener(eventListener);
}
ServiceInstance:
void doSomeThing() {
fireEvent1();
}
Haven't specified in full the interface. But hopefully one of you will get the idea and let me know if there is a similar thing is Spring that is available for doing this sort of thing.
Thanks,
Garry
EJB Observer Pattern
This article explains how to implement the observer pattern in a suite of integrated EJB apps. The suite has a shared repository and each EJB application has it own repository. Every application in the suite runs on a separate host. Each application needs to observe changes in the shared repository as they occur -- and within the transaction in which they occur. If a proposed change to the shared data is unacceptable to any given application then the transaction must be aborted before the change is made permanent.


Reply With Quote