001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2014-2015 ForgeRock AS
026 */
027package org.opends.server.tasks;
028
029import org.forgerock.i18n.LocalizableMessage;
030
031import org.opends.server.core.DirectoryServer;
032import org.opends.server.api.DirectoryThread;
033
034/**
035 * This class defines a thread that will be spawned to invoke a Directory Server
036 * in-core restart.  That is, the server will perform an internal shutdown, and
037 * will then re-bootstrap and start itself up again without ever exiting the
038 * JVM.
039 * <BR><BR>
040 * Note that there are two significant differences between this thread and the
041 * shutdown task thread (other than the obvious difference that this one does a
042 * restart while the other does a shutdown):  this class extends
043 * <CODE>java.lang.Thread</CODE> instead of
044 * <CODE>org.opends.server.core.DirectoryThread</CODE>, and this thread is not a
045 * daemon thread.  These changes are needed to guarantee that the JVM does not
046 * exit before we get a chance to restart it if all non-daemon threads go away.
047 */
048public class RestartTaskThread
049       extends DirectoryThread
050{
051  /**
052   * The fully-qualified name of this class.
053   */
054  private static final String CLASS_NAME =
055       "org.opends.server.tasks.RestartTaskThread";
056
057
058
059  /** The shutdown message that will be used. */
060  private LocalizableMessage shutdownMessage;
061
062
063
064  /**
065   * Creates a new instance of this shutdown task thread with the provided
066   * message.
067   *
068   * @param  shutdownMessage  The shutdown message that will be used.
069   */
070  public RestartTaskThread(LocalizableMessage shutdownMessage)
071  {
072    super("Restart Task Thread");
073
074
075    this.shutdownMessage = shutdownMessage;
076  }
077
078
079
080  /**
081   * Invokes the Directory Server shutdown process.
082   */
083  public void run()
084  {
085    DirectoryServer.restart(CLASS_NAME, shutdownMessage);
086  }
087}
088