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/LastModPlugin.java | 48 +++++++++++++++++++++++++++++++++---------------
1 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/opends/src/server/org/opends/server/plugins/LastModPlugin.java b/opends/src/server/org/opends/server/plugins/LastModPlugin.java
index 5afc808..ff33ed8 100644
--- a/opends/src/server/org/opends/server/plugins/LastModPlugin.java
+++ b/opends/src/server/org/opends/server/plugins/LastModPlugin.java
@@ -25,7 +25,6 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.plugins;
-import org.opends.messages.Message;
@@ -34,18 +33,22 @@
import java.util.List;
import java.util.Set;
+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.LastModPluginCfg;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.api.plugin.PreOperationPluginResult;
import org.opends.server.config.ConfigException;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.ByteStringFactory;
import org.opends.server.types.ConfigChangeResult;
+import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
@@ -56,13 +59,12 @@
import org.opends.server.types.operation.PreOperationModifyOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
-import static org.opends.server.config.ConfigConstants.*;
-import org.opends.server.types.DebugLogLevel;
import static org.opends.messages.PluginMessages.*;
-
-import static org.opends.server.util.TimeThread.*;
+import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
+import static org.opends.server.util.TimeThread.*;
+
+
/**
* This class implements a Directory Server plugin that will add the
@@ -71,8 +73,8 @@
* whenever the entry is modified or renamed.
*/
public final class LastModPlugin
- extends DirectoryServerPlugin<PluginCfg>
- implements ConfigurationChangeListener<PluginCfg>
+ extends DirectoryServerPlugin<LastModPluginCfg>
+ implements ConfigurationChangeListener<LastModPluginCfg>
{
/**
* The tracer object for the debug logger.
@@ -91,6 +93,9 @@
// The attribute type for the "modifyTimestamp" attribute.
private final AttributeType modifyTimestampType;
+ // The current configuration for this plugin.
+ private LastModPluginCfg currentConfig;
+
/**
@@ -104,7 +109,6 @@
super();
-
// Get the attribute types for the attributes that we will use. This needs
// to be done in the constructor in order to make the associated variables
// "final".
@@ -125,10 +129,11 @@
*/
@Override()
public final void initializePlugin(Set<PluginType> pluginTypes,
- PluginCfg configuration)
+ LastModPluginCfg configuration)
throws ConfigException
{
- configuration.addChangeListener(this);
+ currentConfig = configuration;
+ configuration.addLastModChangeListener(this);
// Make sure that the plugin has been enabled for the appropriate types.
for (PluginType t : pluginTypes)
@@ -156,6 +161,17 @@
* {@inheritDoc}
*/
@Override()
+ public final void finalizePlugin()
+ {
+ currentConfig.removeLastModChangeListener(this);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override()
public final PreOperationPluginResult
doPreOperation(PreOperationAddOperation addOperation)
{
@@ -332,7 +348,8 @@
public boolean isConfigurationAcceptable(PluginCfg configuration,
List<Message> unacceptableReasons)
{
- return isConfigurationChangeAcceptable(configuration, unacceptableReasons);
+ LastModPluginCfg cfg = (LastModPluginCfg) configuration;
+ return isConfigurationChangeAcceptable(cfg, unacceptableReasons);
}
@@ -340,7 +357,7 @@
/**
* {@inheritDoc}
*/
- public boolean isConfigurationChangeAcceptable(PluginCfg configuration,
+ public boolean isConfigurationChangeAcceptable(LastModPluginCfg configuration,
List<Message> unacceptableReasons)
{
boolean configAcceptable = true;
@@ -374,9 +391,10 @@
/**
* {@inheritDoc}
*/
- public ConfigChangeResult applyConfigurationChange(PluginCfg configuration)
+ public ConfigChangeResult applyConfigurationChange(
+ LastModPluginCfg configuration)
{
- // No implementation is required.
+ currentConfig = configuration;
return new ConfigChangeResult(ResultCode.SUCCESS, false);
}
}
--
Gitblit v1.10.0