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