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-2012 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.common.api;
028    
029    import com.unboundid.directory.sdk.common.internal.UnboundIDExtension;
030    import com.unboundid.directory.sdk.common.types.InstallExtensionDetails;
031    import com.unboundid.directory.sdk.common.types.PostManageExtensionPluginResult;
032    import com.unboundid.directory.sdk.common.types.PreManageExtensionPluginResult;
033    import com.unboundid.directory.sdk.common.types.UpdateExtensionDetails;
034    import com.unboundid.directory.sdk.ds.internal.DirectoryServerExtension;
035    import com.unboundid.directory.sdk.proxy.internal.DirectoryProxyServerExtension;
036    import com.unboundid.directory.sdk.sync.internal.SynchronizationServerExtension;
037    import com.unboundid.util.Extensible;
038    import com.unboundid.util.ThreadSafety;
039    import com.unboundid.util.ThreadSafetyLevel;
040    
041    /**
042     * This class defines an API that may be implemented by extensions which will
043     * be managed by the manage-extension tool. This API allows extensions to
044     * perform custom operations during the install/update process.
045     * <BR><BR>
046     * This plugin will be invoked during the following phases:
047     * <UL>
048     * <LI>before install -- Invoked when an extension is first installed before
049     *     any files are copied to the server installation.</LI>
050     * <LI>after install -- Invoked when an extension is first installed after
051     *     all files are copied to the server installation.</LI>
052     * <LI>before update -- Invoked when an extension is updated before any files
053     *     are updated.</LI>
054     * <LI>after update -- Invoked when an extension is updated after all files
055     *     are updated.</LI>
056     * </UL>
057     */
058    @Extensible()
059    @DirectoryServerExtension()
060    @DirectoryProxyServerExtension(appliesToLocalContent=true,
061         appliesToRemoteContent=true)
062    @SynchronizationServerExtension(appliesToLocalContent=true,
063         appliesToSynchronizedContent=false)
064    @ThreadSafety(level= ThreadSafetyLevel.INTERFACE_THREADSAFE)
065    public abstract class ManageExtensionPlugin implements UnboundIDExtension
066    {
067      /**
068       * Invoked when an extension is first installed before shutting down
069       * the server and any files are copied to the server installation.
070       *
071       * @param details The state of the install before any files are copied.
072       * @return Whether to continue the installation process.
073       */
074      public PreManageExtensionPluginResult preInstall(
075          final InstallExtensionDetails details)
076      {
077        // No default implementation
078        return PreManageExtensionPluginResult.SUCCESS;
079      }
080    
081      /**
082       * Invoked when an extension is first installed after all files are copied
083       * to the server installation but before restarting the server.
084       *
085       * @param details The state of the install after all files are copied.
086       * @return Whether the server should be restarted after the install if
087       *                 previous started.
088       */
089      public PostManageExtensionPluginResult postInstall(
090          final InstallExtensionDetails details)
091      {
092        // No default implementation
093        return PostManageExtensionPluginResult.SUCCESS;
094      }
095    
096      /**
097       * Invoked when an extension is updated before shutting down the server and
098       * any files are updated to the server installation.
099       *
100       * @param details The state of the update before any files are updated.
101       * @return Whether to continue the update process.
102       */
103      public PreManageExtensionPluginResult preUpdate(
104          final UpdateExtensionDetails details)
105      {
106        // No default implementation
107        return PreManageExtensionPluginResult.SUCCESS;
108      }
109    
110      /**
111       * Invoked when an extension is updated after all files are update to the
112       * server installation but before restarting the server.
113       *
114       * @param details The state of the update after all files are updated.
115       * @return Whether the server should be restarted after the update if
116       *                 previous started.
117       */
118      public PostManageExtensionPluginResult postUpdate(
119          final UpdateExtensionDetails details)
120      {
121        // No default implementation
122        return PostManageExtensionPluginResult.SUCCESS;
123      }
124    }