001/*
002 * (C) Copyright 2020 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     bdelbosc
018 */
019package org.nuxeo.ecm.core.event.stream;
020
021import java.util.List;
022
023import org.nuxeo.ecm.core.event.Event;
024import org.nuxeo.lib.stream.computation.Record;
025
026/**
027 * Collects Core Events and produces Domain Event Records.
028 *
029 * @since 11.4
030 */
031public abstract class DomainEventProducer {
032    protected final String name;
033
034    protected final String stream;
035
036    public DomainEventProducer(String name, String stream) {
037        this.name = name;
038        this.stream = stream;
039    }
040
041    /**
042     * The name of the domain event.
043     */
044    public String getName() {
045        return name;
046    }
047
048    public String getStream() {
049        return stream;
050    }
051
052    /**
053     * Receives Nuxeo Core events from the synchronous listener DomainEventProducerListener.
054     */
055    public abstract void addEvent(Event event);
056
057    /**
058     * Produces Domain Event Records from the accumulated Nuxeo Core events.
059     */
060    public abstract List<Record> getDomainEvents();
061
062}