001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the License.
004 *
005 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
006 * specific language governing permission and limitations under the License.
007 *
008 * When distributing Covered Software, include this CDDL Header Notice in each file and include
009 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
010 * Header, with the fields enclosed by brackets [] replaced by your own identifying
011 * information: "Portions copyright [year] [name of copyright owner]".
012 *
013 * Copyright 2015 ForgeRock AS.
014 */
015
016package org.forgerock.util.thread.listener;
017
018/**
019 * Interface used by shutdown managers to allow for thread safe
020 * adding and removing of shutdown listeners.
021 */
022public interface ShutdownManager {
023
024    /**
025     * Adds a ShutdownListener to this ShutdownManager with the default priority.
026     *
027     * @param listener The listener to be added.
028     */
029    void addShutdownListener(ShutdownListener listener);
030
031    /**
032     * Adds a ShutdownListener to this ShutdownManager with the supplied priority.
033     *
034     * @param listener The listener to be added.
035     * @param priority The priority of the listener when added.
036     */
037    void addShutdownListener(ShutdownListener listener, ShutdownPriority priority);
038
039    /**
040     * Reaplces an existing ShutdownListener with the new ShutdownListener.
041     *
042     * @param oldListener To be replaced.
043     * @param newListener The replacement.
044     * @param priority Replacement listeners priority.
045     */
046    void replaceShutdownListener(ShutdownListener oldListener, ShutdownListener newListener, ShutdownPriority priority);
047
048    /**
049     * Removes a ShutdownListener from this ShutdownManager.
050     *
051     * @param listener The listener to be removed.
052     */
053    void removeShutdownListener(ShutdownListener listener);
054
055    /**
056     * Shuts down all the listeners in this ShutdownManager.
057     */
058    void shutdown();
059
060}