1.注册日志的类:
@Configuration
@EnableReactor
public class ReactorConfig {
/**
*
* 〈注册审计日志 Reactor〉
*/
@Bean(name = "sysLog")
public Reactor sysLogReactor(Environment env) {
return Reactors.reactor().env(env).get();
}
}
2.声明记录日志的类和方法:
@Component
public class LogOperationHandler {
@Selector(value = "sysLog", reactor = "@sysLog")
public void handleSysLog(Event<Object> evt) {}
}
3.使用该方法:
// 系统日志
@Autowired
@Qualifier("sysLog")
private Reactor sysLog;
sysLog.notify("sysLog", Event.wrap(baseElement));//通知reactor保存到数据库中