bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * CDDL HEADER START
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * The contents of this file are subject to the terms of the
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * Common Development and Distribution License, Version 1.0 only
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * (the "License"). You may not use this file except in compliance
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * with the License.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * or http://forgerock.org/license/CDDLv1.0.html.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * See the License for the specific language governing permissions
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * and limitations under the License.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * When distributing Covered Code, include this CDDL HEADER in each
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * file and include the License file at legal-notices/CDDLv1_0.txt.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * If applicable, add the following below this CDDL HEADER, with the
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * fields enclosed by brackets "[]" replaced with your own identifying
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * information:
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * Portions Copyright [yyyy] [name of copyright owner]
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * CDDL HEADER END
a3d3ab94806056d2355afea6fe8daac41059b9fbludovicp * Copyright 2006-2008 Sun Microsystems, Inc.
bedb386242727f98834c64397487f48d5eb6116cboliimport static org.opends.server.loggers.ErrorLogger.logError;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swiftimport org.opends.server.api.plugin.PluginType;
98a1007979c3bb0ffa38f3eecff66b174172be67treydrakeimport org.opends.server.api.plugin.DirectoryServerPlugin;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swiftimport org.opends.server.config.ConfigException;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swiftimport org.opends.server.types.ConfigChangeResult;
98a1007979c3bb0ffa38f3eecff66b174172be67treydrakeimport org.opends.server.types.InitializationException;
98a1007979c3bb0ffa38f3eecff66b174172be67treydrakeimport org.opends.server.admin.server.ConfigurationChangeListener;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swiftimport com.example.opends.server.ExamplePluginCfg;
cd845149d3f0adb85c23d522477ffb6d7c16cc7ectissotimport static com.example.opends.messages.ExamplePluginMessages.*;
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * The example plugin implementation class. This plugin will output
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * the configured message to the error log during server start up.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake DirectoryServerPlugin<ExamplePluginCfg> implements
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // The current configuration.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift * Default constructor.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * Performs any initialization necessary for this plugin. This will
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * be called as soon as the plugin has been loaded and before it is
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * registered with the server.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @param pluginTypes The set of plugin types that indicate the
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * ways in which this plugin will be invoked.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @param configuration The configuration for this plugin.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @throws ConfigException If the provided entry does not contain
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * a valid configuration for this plugin.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @throws InitializationException If a problem occurs while
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * initializing the plugin that is
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * not related to the server
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * configuration.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift public void initializePlugin(Set<PluginType> pluginTypes,
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // This plugin may only be used as a server startup plugin.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // This is fine.
cd845149d3f0adb85c23d522477ffb6d7c16cc7ectissot Message message = ERR_INITIALIZE_PLUGIN.get(String.valueOf(t));
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Register change listeners. These are not really necessary for
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // this plugin since it is only used during server start-up.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Save the configuration.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * Performs any processing that should be done when the Directory
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * Server is in the process of starting. This method will be called
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * after virtually all other initialization has been performed but
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * before the connection handlers are started.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @return The result of the startup plugin processing.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Log the provided message.
cd845149d3f0adb85c23d522477ffb6d7c16cc7ectissot Message message = NOTE_DO_STARTUP.get(String.valueOf(config.getMessage()));
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * Applies the configuration changes to this change listener.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @param config
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * The new configuration containing the changes.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @return Returns information about the result of changing the
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * configuration.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift public ConfigChangeResult applyConfigurationChange(
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // The new configuration has already been validated.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Log a message to say that the configuration has changed. This
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // isn't necessary, but we'll do it just to show that the change
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // has taken effect.
cd845149d3f0adb85c23d522477ffb6d7c16cc7ectissot Message message = NOTE_APPLY_CONFIGURATION_CHANGE.get(
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Update the configuration.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // Update was successfull, no restart required.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift return new ConfigChangeResult(ResultCode.SUCCESS, false);
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * Indicates whether the proposed change to the configuration is
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * acceptable to this change listener.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @param config
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * The new configuration containing the changes.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @param messages
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * A list that can be used to hold messages about why the
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * provided configuration is not acceptable.
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * @return Returns <code>true</code> if the proposed change is
98a1007979c3bb0ffa38f3eecff66b174172be67treydrake * acceptable, or <code>false</code> if it is not.
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift public boolean isConfigurationChangeAcceptable(
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suter ExamplePluginCfg config, List<Message> messages) {
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // The only thing that can be validated here is the plugin's
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // message. However, it is always going to be valid, so let's
bb8874d71cdd8e5288297b9727703437c6dfcfedmatthew_swift // always return true.