Search in sources :

Example 1 with RecordableEvent

use of org.xwiki.eventstream.RecordableEvent in project xwiki-platform by xwiki.

the class DefaultUntypedRecordableEventConverter method convert.

@Override
public Event convert(RecordableEvent recordableEvent, String source, Object data) throws Exception {
    Event convertedEvent = super.convert(recordableEvent, source, data);
    convertedEvent.setType(((UntypedRecordableEvent) recordableEvent).getEventType());
    return convertedEvent;
}
Also used : UntypedRecordableEvent(org.xwiki.eventstream.UntypedRecordableEvent) Event(org.xwiki.eventstream.Event) RecordableEvent(org.xwiki.eventstream.RecordableEvent)

Example 2 with RecordableEvent

use of org.xwiki.eventstream.RecordableEvent in project xwiki-platform by xwiki.

the class RecordableEventListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    if (!(event instanceof RecordableEvent) || remoteObservationManagerContext.isRemoteState()) {
        return;
    }
    // Don't handle events that are already saved by the Activity Stream implementation.
    for (Event ignoredEvent : ActivityStreamImpl.LISTENER_EVENTS) {
        if (ignoredEvent.matches(event)) {
            return;
        }
    }
    try {
        if (!this.execution.getContext().hasProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY)) {
            this.execution.getContext().setProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY, true);
            // Save the event in the event stream
            eventStream.addEvent(convertEvent(event, source, data));
            this.execution.getContext().removeProperty(AbstractEventStreamEvent.EVENT_LOOP_CONTEXT_LOCK_PROPERTY);
        }
    } catch (Exception e) {
        logger.warn("Failed to save the event [{}].", event.getClass().getCanonicalName(), e);
    }
}
Also used : AbstractEventStreamEvent(org.xwiki.eventstream.events.AbstractEventStreamEvent) AllEvent(org.xwiki.observation.event.AllEvent) Event(org.xwiki.observation.event.Event) RecordableEvent(org.xwiki.eventstream.RecordableEvent) RecordableEvent(org.xwiki.eventstream.RecordableEvent)

Aggregations

RecordableEvent (org.xwiki.eventstream.RecordableEvent)2 Event (org.xwiki.eventstream.Event)1 UntypedRecordableEvent (org.xwiki.eventstream.UntypedRecordableEvent)1 AbstractEventStreamEvent (org.xwiki.eventstream.events.AbstractEventStreamEvent)1 AllEvent (org.xwiki.observation.event.AllEvent)1 Event (org.xwiki.observation.event.Event)1