对于日志和事件的记录在每个项目中都会用到,如果在每个manager层中触发时间记录的话,会比较难以扩展和维护,所以可配置的日志和事件记录在项目中会用到!
首先在spring的配置文件中加入hibernate拦截器
- <bean<wbr>id=</wbr> "sessionFactory" <wbr></wbr> class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean" > <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><property<wbr>name=</wbr></wbr></wbr></wbr></wbr> "entityInterceptor" > <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><ref<wbr>bean=</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "myInterceptor" /> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></property<span>><wbr><wbr></wbr></wbr></span> </wbr></wbr></wbr></wbr>
- </bean> <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <bean<wbr>id=</wbr> "myInterceptor" <wbr></wbr> class = "com.creawor.cbsms.util.MyInterceptor" <wbr>/><wbr><wbr></wbr></wbr></wbr>
<wbr>MyInterceptor拦截器为:</wbr>
- package <wbr>com.creawor.cbsms.util; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>java.io.Serializable; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>java.lang.reflect.InvocationTargetExceptio<wbr>n; <wbr><wbr></wbr></wbr></wbr></wbr>
- import <wbr>java.lang.reflect.Method; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>java.util.Iterator; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>javacommon.util.ApplicationContextHolder<wbr>; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>org.hibernate.CallbackException; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>org.hibernate.EntityMode; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>org.hibernate.Interceptor; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>org.hibernate.Transaction; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>org.hibernate.type.Type; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.event.EventRecord; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsChannel; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsMessage; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- public <wbr></wbr> class <wbr>MyInterceptor<wbr></wbr></wbr> implements <wbr>Interceptor{ <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr> //删除时记录时间 <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>onDelete(Object<wbr>obj,<wbr>Serializable<wbr>arg1,<wbr>Object[]<wbr>arg2,<wbr>String[]<wbr>arg3,<wbr>Type[]<wbr>arg4)<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> throws <wbr>CallbackException<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //<wbr>TODO<wbr>Auto-generated<wbr>method<wbr>stub</wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>String[]<wbr>entitys<wbr>=<wbr>EventRecord.getDeleteEntitysFireEven<wbr>t(); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> for <wbr>(String<wbr>entityName<wbr>:<wbr>entitys)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> if <wbr>(entityName.equals(obj.getClass().getSimpleName()))<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>getEventRecordMethod(entityName,<wbr>obj,EventRecord.getDeleteInfo()); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //修改时记录事件 <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> boolean <wbr>onFlushDirty(Object<wbr>obj,<wbr>Serializable<wbr>id,<wbr>Object[]<wbr>currentState,<wbr>Object[]<wbr>previousState<wbr>,<wbr>String[]<wbr>propertyNames,<wbr>Type[]<wbr>types){ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>String[]<wbr>entitys<wbr>=<wbr>EventRecord.getUpdateEntitysFireEven<wbr>t(); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> for <wbr>(String<wbr>entityName<wbr>:<wbr>entitys)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> if <wbr>(entityName.equals(obj.getClass().getSimpleName()))<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>getEventRecordMethod(entityName,<wbr>obj,<wbr>EventRecord.getUpdateInfo()); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr></wbr> false ; <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr>String<wbr>onPrepareStatement(String<wbr>arg0)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //<wbr>TODO<wbr>Auto-generated<wbr>method<wbr>stub</wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>arg0; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //保存时记录事件 <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> boolean <wbr>onSave(Object<wbr>obj,<wbr>Serializable<wbr>arg1,<wbr>Object[]<wbr>arg2,<wbr>String[]<wbr>arg3,<wbr>Type[]<wbr>arg4)<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> throws <wbr>CallbackException<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //<wbr>TODO<wbr>Auto-generated<wbr>method<wbr>stub</wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>String[]<wbr>entitys<wbr>=<wbr>EventRecord.getSaveEntitysFireEvent(); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> for <wbr>(String<wbr>entityName<wbr>:<wbr>entitys)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> if <wbr>(entityName.equals(obj.getClass().getSimpleName()))<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>getEventRecordMethod(entityName,<wbr>obj,EventRecord.getSaveInfo()); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr></wbr> false ; <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //根据反射机制执行事件记录类中相应的函数 <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>getEventRecordMethod(String<wbr>entityName,Object<wbr>obj,String<wbr>info){ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> try <wbr>{ <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Class[]<wbr>parameterTypes<wbr>=<wbr>{String.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> class ,Class.forName(EventRecord.getPrefixPackageName()+entityName)}; <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Method<wbr>method<wbr>=<wbr>EventRecord.</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> class .getMethod(EventRecord.getPrefixMethodName()+entityName,<wbr>parameterTypes); <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Object[]<wbr>objs<wbr>=<wbr>{info,<wbr>Class.forName(EventRecord.getPrefixPackageName()+entityName).cast(obj)}; <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>method.invoke((EventRecord)ApplicationContextHolder<wbr>.getBean(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "eventRecord" ),objs); <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>}<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> catch <wbr>(Exception<wbr>e)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- //<wbr>TODO<wbr>Auto-generated<wbr>catch<wbr>block</wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>e.printStackTrace(); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- }<wbr><wbr></wbr></wbr>
<wbr>事件记录类:</wbr>
- package <wbr>com.creawor.cbsms.event; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>java.sql.Timestamp; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>javacommon.util.ApplicationContextHolder<wbr>; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.dao.CbsEventDao; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsBsc; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsBscCells; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsChannel; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsEvent; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.model.CbsUserRegister; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.cbsms.service.CbsEventManager; <wbr><wbr></wbr></wbr></wbr>
- import <wbr>com.creawor.security.model.PermUser; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- public <wbr></wbr> class <wbr>EventRecord<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> //<wbr>保存时要记录事件的对象</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String[]<wbr>saveEntitysFireEvent<wbr>=<wbr>{<wbr></wbr></wbr></wbr></wbr></wbr> "CbsBscCells" , <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsChannel" ,<wbr><wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsBsc" <wbr>}; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>删除时要记录事件的对象</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String[]<wbr>deleteEntitysFireEvent<wbr>=<wbr>{<wbr></wbr></wbr></wbr></wbr></wbr> "CbsBscCells" , <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsChannel" , <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsBsc" <wbr>}; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>更新时要记录事件的对象</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String[]<wbr>updateEntitysFireEvent<wbr>=<wbr>{<wbr></wbr></wbr></wbr></wbr></wbr> "CbsBscCells" , <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsChannel" ,<wbr><wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "CbsBsc" <wbr>}; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>包的前缀,反射得到类时使用</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String<wbr>prefixPackageName<wbr>=<wbr></wbr></wbr></wbr></wbr> "com.creawor.cbsms.model." ; <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>记录该次操作的登录用户名:EventRecord为session范围</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr>String<wbr>userName; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>调用函数的前缀,反射执行函数时使用</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String<wbr>prefixMethodName<wbr>=<wbr></wbr></wbr></wbr></wbr> "recordFor" ; <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>执行save时,事件描述</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String<wbr>saveInfo<wbr>=<wbr></wbr></wbr></wbr></wbr> "创建" ; <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>执行delete时,事件描述</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String<wbr>deleteInfo<wbr>=<wbr></wbr></wbr></wbr></wbr> "删除" ; <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>执行update时,事件描述</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr></wbr> static <wbr>String<wbr>updateInfo<wbr>=<wbr></wbr></wbr></wbr></wbr> "修改" ; <wbr><wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> private <wbr>CbsEventManager<wbr>cbsEventManager; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> //<wbr>spring自动注入</wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>setCbsEventManager(CbsEventManager<wbr>cbsEventManager)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> this .cbsEventManager<wbr>=<wbr>cbsEventManager; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>recordForCbsChannel(String<wbr>desc,<wbr>CbsChannel<wbr>channel)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>StringBuffer<wbr>eventDesc<wbr>=<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> new <wbr>StringBuffer(desc); <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>eventDesc.append(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "频道" <wbr>+<wbr>channel.getChannelName()).append(</wbr></wbr> "[" ).append( <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>channel.getChannelNum()).append(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "]" ); <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>record(eventDesc.toString(),<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> null ); <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>recordForCbsBscCells(String<wbr>desc,<wbr>CbsBscCells<wbr>cell)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>StringBuffer<wbr>eventDesc<wbr>=<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> new <wbr>StringBuffer(desc); <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>eventDesc.append(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "小区" +cell.getCellName()).append( "[" ).append( <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>cell.getCellId()).append(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "]" ); <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>record(eventDesc.toString(),<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> null ); <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>record(String<wbr>eventDesc,<wbr>String<wbr>eventOrigin)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>CbsEvent<wbr>event<wbr>=<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> new <wbr>CbsEvent(); <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>event.setEventDesc(userName<wbr>+<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> "<wbr><wbr><wbr>"</wbr></wbr></wbr> <wbr>+<wbr>eventDesc); <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>event.setEventOrigin(eventOrigin); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>event.setStartTime(</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> new <wbr>Timestamp(System.currentTimeMillis())); <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>cbsEventManager.save(event); <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> void <wbr>setUserName(String<wbr>userName)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> this .userName<wbr>=<wbr>userName; <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String[]<wbr>getDeleteEntitysFireEven<wbr>t()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>deleteEntitysFireEvent; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String[]<wbr>getSaveEntitysFireEvent()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>saveEntitysFireEvent; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String[]<wbr>getUpdateEntitysFireEven<wbr>t()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>updateEntitysFireEvent; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String<wbr>getPrefixPackageName()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>prefixPackageName; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr></wbr> void <wbr>setPrefixPackageName(String<wbr>prefixPackageName)<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>EventRecord.prefixPackageName<wbr>=<wbr>prefixPackageName; <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String<wbr>getPrefixMethodName()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>prefixMethodName; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String<wbr>getDeleteInfo()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>deleteInfo; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String<wbr>getSaveInfo()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>saveInfo; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr> public <wbr></wbr> static <wbr>String<wbr>getUpdateInfo()<wbr>{ <wbr><wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> return <wbr>updateInfo; <wbr><wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr>} <wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr></wbr></wbr>
- }<wbr><wbr></wbr></wbr>
<wbr>其中EventRecord 在spring中的配置为:</wbr>
- <bean<wbr>id=</wbr> "eventRecord" <wbr></wbr> class = "com.creawor.cbsms.event.EventRecord" <wbr><wbr>scope=</wbr></wbr> "session" <wbr>autowire=</wbr> "byName" /><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
<wbr>EventRecord 为session范围可以使字段userName记录每次登录人员的姓名</wbr>
具体在每次登录后从spring容器中得到EventRecord然后set其userName即可!
最后一步要想让session范围生效还要在web.xml中添加配置:
- <web-app> <wbr><wbr></wbr></wbr>
- <wbr><wbr>... <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><listener> <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr><wbr><wbr><listener-</wbr></wbr></wbr></wbr> class >org.springframework.web.context.request.RequestContextListener</listener- class > <wbr><wbr></wbr></wbr>
- <wbr><wbr></listener> <wbr><wbr></wbr></wbr></wbr></wbr>
- <wbr><wbr>... <wbr><wbr></wbr></wbr></wbr></wbr>
- </web-app><wbr><wbr></wbr></wbr>
<wbr>这样如果想要记录一个业务bean增删改的操作只需在EventRecord中设置saveEntitysFireEvent,deleteEntitysFireEvent,updateEntitysFireEvent属性即可,同样也可使用配置文件配置,这样都可以使日志和事件的记录变得很简单!</wbr>