观察者模式建议 [英] Observer pattern suggestion

查看:213
本文介绍了观察者模式建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个模块,其中用户使用应用程序插入一些数据,它基本上是一个j2ee应用程序,其中用户只创建信息有三个模块。在插入结束时,我在数据表中创建状态并发送电子邮件通知这对于所有三个模块都是通用的,这里的用户观察者模式会更好吗。如果不是更好? -

I have three modules where user inserts some data using application , it is basically a j2ee application where user just creates information there are three modules .At the end of insertion i have create a status in table of the data and send email notificaiton , this is common to all the three modules , would it be better to user observer pattern here.If not what would be better?-

推荐答案

更好地使用以下通常用于您案例的方法之一

Better use one of the below approaches generally used for your case


  1. 您可以使用数据库触发器:
    http://dev.mysql.com/doc/refman/5.0 /en/trigger-syntax.html

如果您正在使用hibernate并且不想在数据库级别实现功能
,使用hibernate拦截器:
http://www.mkyong .com / hibernate / hibernate-interceptor-example-audit-log /

If you are using hibernate and don't want to implement functionality at database level, use hibernate interceptors : http://www.mkyong.com/hibernate/hibernate-interceptor-example-audit-log/

这篇关于观察者模式建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆