001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Thomas Roger
011 */
012
013package org.nuxeo.ecm.core.storage.sql.listeners;
014
015import java.util.Collections;
016import java.util.LinkedList;
017import java.util.List;
018
019import org.nuxeo.ecm.core.event.Event;
020import org.nuxeo.ecm.core.event.EventListener;
021
022public class DummyTestListener implements EventListener {
023
024    public static final List<Event> EVENTS_RECEIVED = Collections.synchronizedList(new LinkedList<Event>());
025
026    public static String threadName;
027
028    @Override
029    public void handleEvent(Event event) {
030        if (threadName != null && !Thread.currentThread().getName().equals(threadName)) {
031            return;
032        }
033        EVENTS_RECEIVED.add(event);
034    }
035
036    public static void clear() {
037        EVENTS_RECEIVED.clear();
038        threadName = null;
039    }
040
041    public static void clearForThisThread() {
042        clear();
043        threadName = Thread.currentThread().getName();
044    }
045
046}