扩展activiti event logger的handler
重写initializeDefaultHandlers方法
public class EsEventLogger extends EventLogger{
private static final Logger logger = LoggerFactory.getLogger(EsEventLogger.class);public static final String EVENT_FLUSHER_KEY = "eventFlusher";public EsEventLogger(Clock clock, ObjectMapper objectMapper) { super(clock, objectMapper);}@Overridepublic void onEvent(ActivitiEvent event) { EventLoggerEventHandler eventHandler = getEventHandler(event); if (eventHandler != null) { // Events are flushed when command context is closed CommandContext currentCommandContext = Context.getCommandContext(); EventFlusher eventFlusher = (EventFlusher) currentCommandContext.getAttribute(EVENT_FLUSHER_KEY); if (eventHandler != null && eventFlusher == null) { eventFlusher = createEventFlusher(); if (eventFlusher == null) { eventFlusher = new EsEventFlusher(); // change to es event logger } currentCommandContext.addAttribute(EVENT_FLUSHER_KEY, eventFlusher); currentCommandContext.addCloseListener(eventFlusher); currentCommandContext .addCloseListener(new CommandContextCloseListener() { @Override public void closing(CommandContext commandContext) { } @Override public void closed(CommandContext commandContext) { // For those who are interested: we can now broadcast the events were added if (listeners != null) { for (EventLoggerListener listener : listeners) { listener.eventsAdded(EsEventLogger.this); } } } }); } eventFlusher.addEventHandler(eventHandler); }}/ * 重写父类 * 更改事件记录的类型 * 以下是activiti默认自带的event log事件类型处理 * activiti-engine-5.20.0-sources.jar!/org/activiti/engine/impl/event/logger/handler/*EventHandler.java * @return */@Overrideprotected void initializeDefaultHandlers() { super.initializeDefaultHandlers(); addEventHandler(ActivitiEventType.ENTITY_UPDATED, TaskUpdatedEventHandler.class);}
}
关键字:activiti
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!