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