开发者

How to create a client notification service for a webapp or should I use an Observer Pattern?

I have a fully implemented DAO and all my beans inherit an Entity object. Now, I want to create a client notification system whereby, when a user creates/updates/delete an entity to/from a persistence storage, a notification is automatically sent to 开发者_如何学JAVAthe client via email.

I have a DAO manager that uses a Factory Pattern to return to me a manager of the DAO based on the entity type.

e.g EntityManager manager = EntityManagerFactory.createEntityManager(Product.class);

each manager has a create(), remove(), update() method....

My first idea is to have all my entity managers inherit an Observer interface and after the function calls (create, remove, update, etc.) a notification is sent.

Is that a wise idea? If not, what can I do in order to send a notification to client?

I'm running JBoss 5 or Tomcat 6 (or both for easy deployment) and Apache Struts (though I don't see the reason why I mentioned it).

Thanks in advance.


Consider using a decorator pattern to allow your entity managers to remain blissfully unaware of who needs to be notified and how to send them emails. This approach will improve maintenance of both the existing manager code and the messaging code you intend to write, and will pay off hugely if you ever need to write new entity managers what store your entities in JCR or tranmit them via web services, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜