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
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2011-2018 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.api;
028
029import com.unboundid.directory.sdk.broker.internal.BrokerExtension;
030import com.unboundid.directory.sdk.common.internal.UnboundIDExtension;
031import com.unboundid.directory.sdk.common.types.InstallExtensionDetails;
032import com.unboundid.directory.sdk.common.types.PostManageExtensionPluginResult;
033import com.unboundid.directory.sdk.common.types.PreManageExtensionPluginResult;
034import com.unboundid.directory.sdk.common.types.UpdateExtensionDetails;
035import com.unboundid.directory.sdk.ds.internal.DirectoryServerExtension;
036import com.unboundid.directory.sdk.metrics.internal.MetricsEngineExtension;
037import com.unboundid.directory.sdk.proxy.internal.DirectoryProxyServerExtension;
038import com.unboundid.directory.sdk.sync.internal.SynchronizationServerExtension;
039import com.unboundid.util.Extensible;
040import com.unboundid.util.ThreadSafety;
041import com.unboundid.util.ThreadSafetyLevel;
042
043/**
044 * This class defines an API that may be implemented by extensions which will
045 * be managed by the manage-extension tool. This API allows extensions to
046 * perform custom operations during the install/update process.
047 * <BR><BR>
048 * This plugin will be invoked during the following phases:
049 * <UL>
050 * <LI>before install -- Invoked when an extension is first installed before
051 *     any files are copied to the server installation.</LI>
052 * <LI>after install -- Invoked when an extension is first installed after
053 *     all files are copied to the server installation.</LI>
054 * <LI>before update -- Invoked when an extension is updated before any files
055 *     are updated.</LI>
056 * <LI>after update -- Invoked when an extension is updated after all files
057 *     are updated.</LI>
058 * </UL>
059 */
060@Extensible()
061@DirectoryServerExtension()
062@DirectoryProxyServerExtension(appliesToLocalContent=true,
063     appliesToRemoteContent=true)
064@SynchronizationServerExtension(appliesToLocalContent=true,
065     appliesToSynchronizedContent=false)
066@MetricsEngineExtension()
067@BrokerExtension()
068@ThreadSafety(level= ThreadSafetyLevel.INTERFACE_THREADSAFE)
069public abstract class ManageExtensionPlugin implements UnboundIDExtension
070{
071  /**
072   * Invoked when an extension is first installed before shutting down
073   * the server and any files are copied to the server installation.
074   *
075   * @param details The state of the install before any files are copied.
076   * @return Whether to continue the installation process.
077   */
078  public PreManageExtensionPluginResult preInstall(
079      final InstallExtensionDetails details)
080  {
081    // No default implementation
082    return PreManageExtensionPluginResult.SUCCESS;
083  }
084
085  /**
086   * Invoked when an extension is first installed after all files are copied
087   * to the server installation but before restarting the server.
088   *
089   * @param details The state of the install after all files are copied.
090   * @return Whether the server should be restarted after the install if
091   *                 previous started.
092   */
093  public PostManageExtensionPluginResult postInstall(
094      final InstallExtensionDetails details)
095  {
096    // No default implementation
097    return PostManageExtensionPluginResult.SUCCESS;
098  }
099
100  /**
101   * Invoked when an extension is updated before shutting down the server and
102   * any files are updated to the server installation.
103   *
104   * @param details The state of the update before any files are updated.
105   * @return Whether to continue the update process.
106   */
107  public PreManageExtensionPluginResult preUpdate(
108      final UpdateExtensionDetails details)
109  {
110    // No default implementation
111    return PreManageExtensionPluginResult.SUCCESS;
112  }
113
114  /**
115   * Invoked when an extension is updated after all files are update to the
116   * server installation but before restarting the server.
117   *
118   * @param details The state of the update after all files are updated.
119   * @return Whether the server should be restarted after the update if
120   *                 previous started.
121   */
122  public PostManageExtensionPluginResult postUpdate(
123      final UpdateExtensionDetails details)
124  {
125    // No default implementation
126    return PostManageExtensionPluginResult.SUCCESS;
127  }
128}