@@ -0,0 +1,3343 @@
+/*%0A * Copyright (c) 2013 Red Rainbow IT Solutions GmbH, Germany%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy of%0A * this software and associated documentation files (the %22Software%22), to deal in%0A * the Software without restriction, including without limitation the rights to%0A * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of%0A * the Software, and to permit persons to whom the Software is furnished to do so,%0A * subject to the following conditions:%0A * %0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A * %0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS%0A * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR%0A * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER%0A * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN%0A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%0A */%0A%0Apackage org.jeeventstore.core.notifier;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0Aimport javax.ejb.Lock;%0Aimport javax.ejb.LockType;%0Aimport org.jeeventstore.core.ChangeSet;%0A%0A/**%0A * Base implementation implementing common functionality of commit notifiers.%0A * %0A * @author Alexander Langer%0A */%0Apublic abstract class AbstractEventStoreCommitNotifier %0A        implements EventStoreCommitNotifier %7B%0A    %0A    private List%3CEventStoreCommitListener%3E listeners = new ArrayList%3C%3E();%0A%0A    /**%0A     * @see EventStoreCommitNotifier#addListener(org.jeeventstore.core.notifier.EventStoreCommitListener) %0A     */%0A    @Override%0A    @Lock(LockType.WRITE)%0A    public void addListener(EventStoreCommitListener listener) %7B%0A        if (this.listeners.contains(listener))%0A            throw new IllegalStateException(%22Listener already listening.%22);%0A        this.listeners.add(listener);%0A    %7D%0A%0A    /**%0A     * @see EventStoreCommitNotifier#removeListener(org.jeeventstore.core.notifier.EventStoreCommitListener) %0A     */%0A    @Override%0A    @Lock(LockType.WRITE)%0A    public void removeListener(EventStoreCommitListener listener) %7B%0A        if (!this.listeners.contains(listener))%0A            throw new IllegalStateException(%22Listener not found.%22);%0A        this.listeners.remove(listener);%0A    %7D%0A%0A    /**%0A     * Perform the actual notification for a given notification.%0A     * Iterates over all registered listeners and lets them receive the given%0A     * notification.%0A     * @param notification The notification that the listeners shall receive.%0A     */%0A    protected void performNotification(EventStoreCommitNotification notification) %7B%0A        for (EventStoreCommitListener l : listeners)%0A            l.receive(notification);%0A    %7D%0A%0A    /**%0A     * Perform the actual notification for a given change set.%0A     * Iterates over all registered listeners and lets them receive a%0A     * notification for the given change set.%0A     * @param changeSet The change set that listeners shall be notified of.%0A     */%0A    protected void performNotification(ChangeSet changeSet) %7B%0A        EventStoreCommitNotification notification = new DefaultCommitNotification(changeSet);%0A        this.performNotification(notification);%0A    %7D%0A%0A%7D%0A

Add common functionality of commit notifiers.