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