001/*
002 *  jDTAUS Core SPI
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.monitor.spi;
022
023import org.jdtaus.core.monitor.Task;
024import org.jdtaus.core.monitor.TaskEventSource;
025
026/**
027 * Monitors tasks.
028 * <p>jDTAUS Core SPI {@code TaskMonitor} specification to be used by
029 * implementations to provide {@code TaskEvent}s to applications.</p>
030 * <p>Example: Monitoring a task<br/>
031 * <pre>
032 * Task task = new ConcreteTask();
033 * try
034 * {
035 *   // Start monitoring.
036 *   this.getTaskMonitor().monitor(task);
037 *
038 *   // Perform operations updating <i>task</i> which is now polled for changes.
039 *   ...
040 *
041 * }
042 * finally
043 * {
044 *   this.getTaskMonitor().finish(task);
045 * }</pre></p>
046 *
047 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
048 * @version $JDTAUS: TaskMonitor.java 8641 2012-09-27 06:45:17Z schulte $
049 * @see org.jdtaus.core.container.Container
050 */
051public interface TaskMonitor extends TaskEventSource
052{
053    //--TaskMonitor-------------------------------------------------------------
054
055    /**
056     * Starts monitoring a {@code Task}.
057     *
058     * @param task the task to monitor.
059     *
060     * @throws NullPointerException if {@code task} is {@code null}.
061     */
062    void monitor( Task task );
063
064    /**
065     * Stops monitoring a {@code Task}.
066     *
067     * @param task the task to stop monitoring.
068     *
069     * @throws NullPointerException if {@code task} is {@code null}.
070     */
071    void finish( Task task );
072
073    //-------------------------------------------------------------TaskMonitor--
074}