/**
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 *
 * Copyright (C)
 * <a href="http://www.inab.org">Spanish National Institute of Bioinformatics (INB)</a>
 * <a href="http://www.bsc.es">Barcelona Supercomputing Center (BSC)</a>
 * <a href="http://inb.bsc.es">Computational Node 6</a>
 */

package org.inb.biomoby.client.gui;

import java.lang.ref.SoftReference;
import java.util.Iterator;
import org.inb.biomoby.client.gui.IDynamicComponent.MobyComponentListener;
import org.inb.biomoby.shared.message.AbstractMobyObject;

/**
 * @author Dmitry Repchevsky
 */

public abstract class DynamicMobyComponent<K extends AbstractMobyObject, T extends MobyComponentListener>
        extends AbstractMobyComponent<K>
        implements IDynamicComponent<T>
{
    private MobyMessageQueue<T> queue;

    public DynamicMobyComponent()
    {
        queue = new MobyMessageQueue<T>();
    }

    @Override
    public synchronized void addListener(MobyComponentListener listener)
    {
        queue.addListener(listener);
    }

    @Override
    public synchronized void removeListener(MobyComponentListener listener)
    {
        queue.removeListener(listener);
    }

    public synchronized Iterator<SoftReference<? super T>> getListeners()
    {
        return queue.getListeners();
    }
}
