From 9b88d8643e4f7a311d2b228d2bce5c043bba82b5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 31 Aug 2007 22:49:33 +0000
Subject: [PATCH] Create configuration definitions for "generic" objects in the server configuration.  This also includes allocating object classes for each of these types.  This will help make it easier for users to create new instances of these kinds of configuration objects because they will not need to know the fully-qualified name of the Java class that implements the associated logic.

---
 opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java b/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
index 870c436..7fa812d 100644
--- a/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
+++ b/opends/src/server/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -25,7 +25,6 @@
  *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  */
 package org.opends.server.plugins;
-import org.opends.messages.Message;
 
 
 
@@ -37,8 +36,10 @@
 import java.util.Set;
 import java.util.UUID;
 
+import org.opends.messages.Message;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.meta.PluginCfgDefn;
+import org.opends.server.admin.std.server.EntryUUIDPluginCfg;
 import org.opends.server.admin.std.server.PluginCfg;
 import org.opends.server.api.plugin.DirectoryServerPlugin;
 import org.opends.server.api.plugin.LDIFPluginResult;
@@ -58,7 +59,6 @@
 import org.opends.server.types.operation.PreOperationAddOperation;
 
 import static org.opends.messages.PluginMessages.*;
-
 import static org.opends.server.util.StaticUtils.*;
 
 
@@ -73,8 +73,8 @@
  * will have identical entryUUID values.
  */
 public final class EntryUUIDPlugin
-       extends DirectoryServerPlugin<PluginCfg>
-       implements ConfigurationChangeListener<PluginCfg>
+       extends DirectoryServerPlugin<EntryUUIDPluginCfg>
+       implements ConfigurationChangeListener<EntryUUIDPluginCfg>
 {
   /**
    * The name of the entryUUID attribute type.
@@ -86,6 +86,9 @@
   // The attribute type for the "entryUUID" attribute.
   private final AttributeType entryUUIDType;
 
+  // The current configuration for this plugin.
+  private EntryUUIDPluginCfg currentConfig;
+
 
 
   /**
@@ -101,8 +104,7 @@
 
     // Get the entryUUID attribute type.  This needs to be done in the
     // constructor in order to make the associated variables "final".
-    AttributeType at = DirectoryConfig.getAttributeType(ENTRYUUID,
-                                                        false);
+    AttributeType at = DirectoryConfig.getAttributeType(ENTRYUUID, false);
     if (at == null)
     {
       String definition =
@@ -128,10 +130,11 @@
    */
   @Override()
   public final void initializePlugin(Set<PluginType> pluginTypes,
-                                     PluginCfg configuration)
+                                     EntryUUIDPluginCfg configuration)
          throws ConfigException
   {
-    configuration.addChangeListener(this);
+    currentConfig = configuration;
+    configuration.addEntryUUIDChangeListener(this);
 
     // Make sure that the plugin has been enabled for the appropriate types.
     for (PluginType t : pluginTypes)
@@ -158,6 +161,17 @@
    * {@inheritDoc}
    */
   @Override()
+  public final void finalizePlugin()
+  {
+    currentConfig.removeEntryUUIDChangeListener(this);
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override()
   public final LDIFPluginResult doLDIFImport(LDIFImportConfig importConfig,
                                              Entry entry)
   {
@@ -237,7 +251,8 @@
   public boolean isConfigurationAcceptable(PluginCfg configuration,
                                            List<Message> unacceptableReasons)
   {
-    return isConfigurationChangeAcceptable(configuration, unacceptableReasons);
+    EntryUUIDPluginCfg cfg = (EntryUUIDPluginCfg) configuration;
+    return isConfigurationChangeAcceptable(cfg, unacceptableReasons);
   }
 
 
@@ -245,7 +260,8 @@
   /**
    * {@inheritDoc}
    */
-  public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+  public boolean isConfigurationChangeAcceptable(
+                      EntryUUIDPluginCfg configuration,
                       List<Message> unacceptableReasons)
   {
     boolean configAcceptable = true;
@@ -278,9 +294,10 @@
   /**
    * {@inheritDoc}
    */
-  public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+  public ConfigChangeResult applyConfigurationChange(
+                                 EntryUUIDPluginCfg configuration)
   {
-    // No implementation is required.
+    currentConfig = configuration;
     return new ConfigChangeResult(ResultCode.SUCCESS, false);
   }
 }

--
Gitblit v1.10.0