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-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014 ForgeRock AS 026 */ 027package org.opends.server.api; 028 029import org.opends.server.admin.std.server.BackendCfg; 030import org.opends.server.config.ConfigEntry; 031import org.forgerock.opendj.config.server.ConfigException; 032import org.opends.server.types.DN; 033import org.opends.server.types.DirectoryException; 034import org.opends.server.types.InitializationException; 035 036/** 037 * This class defines the set of methods and structures that must be 038 * implemented by a Directory Server configuration handler. 039 * 040 * @param <C> the BackendCfg class in use with this ConfigHandler 041 */ 042@org.opends.server.types.PublicAPI( 043 stability=org.opends.server.types.StabilityLevel.VOLATILE, 044 mayInstantiate=false, 045 mayExtend=true, 046 mayInvoke=true) 047public abstract class ConfigHandler<C extends BackendCfg> extends Backend<C> 048{ 049 /** 050 * Bootstraps this configuration handler using the information in 051 * the provided configuration file. Depending on this configuration 052 * handler implementation, the provided file may contain either the 053 * entire server configuration or information that is needed to 054 * access the configuration in some other location or repository. 055 * 056 * @param configFile The path to the file to use to initialize 057 * this configuration handler. 058 * @param checkSchema Indicates whether to perform schema checking 059 * on the configuration data. 060 * 061 * @throws InitializationException If a problem occurs while 062 * attempting to initialize this 063 * configuration handler. 064 */ 065 public abstract void initializeConfigHandler(String configFile, 066 boolean checkSchema) 067 throws InitializationException; 068 069 070 071 /** 072 * Finalizes this configuration handler so that it will release any 073 * resources associated with it so that it will no longer be used. 074 * This will be called when the Directory Server is shutting down, 075 * as well as in the startup process once the schema has been read 076 * so that the configuration can be re-read using the updated 077 * schema. 078 */ 079 public abstract void finalizeConfigHandler(); 080 081 082 083 /** 084 * Retrieves the entry that is at the root of the Directory Server 085 * configuration. 086 * 087 * @return The entry that is at the root of the Directory Server 088 * configuration. 089 * 090 * @throws ConfigException If a problem occurs while interacting 091 * with the configuration. 092 */ 093 public abstract ConfigEntry getConfigRootEntry() 094 throws ConfigException; 095 096 097 098 /** 099 * Retrieves the requested entry from the configuration. 100 * 101 * @param entryDN The distinguished name of the configuration 102 * entry to retrieve. 103 * 104 * @return The requested configuration entry. 105 * 106 * @throws ConfigException If a problem occurs while interacting 107 * with the configuration. 108 */ 109 public abstract ConfigEntry getConfigEntry(DN entryDN) 110 throws ConfigException; 111 112 113 114 /** 115 * Retrieves the absolute path of the Directory Server install 116 * root. 117 * 118 * @return The absolute path of the Directory Server install root. 119 */ 120 public abstract String getServerRoot(); 121 122 123 /** 124 * Retrieves the absolute path of the Directory Server instance 125 * root. 126 * 127 * @return The absolute path of the Directory Server instance root. 128 */ 129 public abstract String getInstanceRoot(); 130 131 132 /** 133 * Writes an updated version of the Directory Server configuration 134 * to the repository. This should ensure that the stored 135 * configuration matches the pending configuration. 136 * 137 * @throws DirectoryException If a problem is encountered while 138 * writing the updated configuration. 139 */ 140 public abstract void writeUpdatedConfig() 141 throws DirectoryException; 142 143 144 145 /** 146 * Indicates that the Directory Server has started successfully and 147 * that the configuration handler should save a copy of the current 148 * configuration for use as a "last known good" reference. Note 149 * that this may not be possible with some kinds of configuration 150 * repositories, so it should be a best effort attempt. 151 * <BR><BR> 152 * This method should only be called by the Directory Server itself 153 * when the server has started successfully. It should not be 154 * invoked by any other component at any other time. 155 */ 156 @org.opends.server.types.PublicAPI( 157 stability=org.opends.server.types.StabilityLevel.VOLATILE, 158 mayInstantiate=false, 159 mayExtend=true, 160 mayInvoke=false) 161 public abstract void writeSuccessfulStartupConfig(); 162} 163