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 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2014-2015 ForgeRock AS.
016 */
017package org.opends.server.tasks;
018import org.forgerock.i18n.LocalizableMessage;
019
020
021
022import org.opends.server.api.DirectoryThread;
023import org.opends.server.core.DirectoryServer;
024
025
026
027
028/**
029 * This class defines a thread that will be spawned to invoke the Directory
030 * Server shutdown process.  This needs to be a separate thread because the task
031 * that creates it has to complete before the server can really shut down.
032 */
033public class ShutdownTaskThread
034       extends DirectoryThread
035{
036  /**
037   * The fully-qualified name of this class.
038   */
039  private static final String CLASS_NAME =
040       "org.opends.server.tasks.ShutdownTaskThread";
041
042
043
044  /** The shutdown message that will be used. */
045  private LocalizableMessage shutdownMessage;
046
047
048
049  /**
050   * Creates a new instance of this shutdown task thread with the provided
051   * message.
052   *
053   * @param  shutdownMessage  The shutdown message that will be used.
054   */
055  public ShutdownTaskThread(LocalizableMessage shutdownMessage)
056  {
057    super("Shutdown Task Thread");
058
059
060    this.shutdownMessage = shutdownMessage;
061
062    setDaemon(true);
063  }
064
065
066
067  /**
068   * Invokes the Directory Server shutdown process.
069   */
070  public void run()
071  {
072    DirectoryServer.shutDown(CLASS_NAME, shutdownMessage);
073  }
074}
075