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
019import java.util.Arrays;
020import java.util.List;
021
022/**
023 * This class defines the shutdown priorities that are consumed by
024 * <code>com.sun.identity.common.ShutdownManager</code>.
025 */
026public enum ShutdownPriority {
027
028    /**
029     * HIGHEST is the priority pre-defined in the system. Components which are
030     * registered with this priority will be shutdown first.
031     */
032    HIGHEST(3),
033
034    /**
035     * DEFAULT is the priority pre-defined in the system. Components which are
036     * registered with this priority will be shutdown after the componets with
037     * HIGHEST priority.
038     */
039    DEFAULT(2),
040
041    /**
042     * LOWEST is the priority pre-defined in the system. Components which are
043     * registered with this priority will be shutdown after the componets with
044     * HIGHEST or DEFAULT priority.
045     */
046    LOWEST(1);
047
048    private int priority;
049
050    private ShutdownPriority(int priority) {
051        this.priority = priority;
052    }
053
054    /**
055     * Returns the priority.
056     *
057     * @return the priority.
058     */
059    public int getIntValue() {
060        return priority;
061    }
062
063    /**
064     * Returns list of all the priorities (ordered from the highest to the
065     * lowest priority) defined in the system.
066     *
067     * @return list of all the priorities defined in the system.
068     */
069    public static List<ShutdownPriority> getPriorities() {
070        return Arrays.asList(values());
071    }
072}