From 0365065aa3b626d057966eb1ddf947b5508c0912 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 24 Sep 2007 19:14:01 +0000
Subject: [PATCH] Modify the getAllConstraints method to calculate the list of constraints dynamically. Previously the list of constraints was cached which prevented run-time changes from taking effect in sub-definitions.
---
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
index 0f3b9e3..6c043bb 100644
--- a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
+++ b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -82,10 +82,6 @@
// definition.
private final Map<String, RelationDefinition<?, ?>> relationDefinitions;
- // The set of all constraints associated with this managed object
- // definition including inherited constraints.
- private final Collection<Constraint> allConstraints;
-
// The set of all property definitions associated with this managed
// object definition including inherited property definitions.
private final Map<String, PropertyDefinition<?>> allPropertyDefinitions;
@@ -132,7 +128,6 @@
this.constraints = new LinkedList<Constraint>();
this.propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
this.relationDefinitions = new HashMap<String, RelationDefinition<?,?>>();
- this.allConstraints = new LinkedList<Constraint>();
this.allPropertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
this.allRelationDefinitions =
new HashMap<String, RelationDefinition<?, ?>>();
@@ -144,8 +139,6 @@
if (parent != null) {
parent.children.put(name, this);
- allConstraints.addAll(parent.getAllConstraints());
-
for (PropertyDefinition<?> pd : parent.getAllPropertyDefinitions()) {
allPropertyDefinitions.put(pd.getName(), pd);
}
@@ -189,11 +182,22 @@
* object. The returned collection will contain inherited
* constraints.
*
- * @return Returns an unmodifiable collection containing all the
- * constraints associated with this type of managed object.
+ * @return Returns a collection containing all the constraints
+ * associated with this type of managed object. The caller
+ * is free to modify the collection if required.
*/
public final Collection<Constraint> getAllConstraints() {
- return Collections.unmodifiableCollection(allConstraints);
+ // This method does not used a cached set of constraints because
+ // constraints may be updated after child definitions haved been
+ // defined.
+ List<Constraint> allConstraints = new LinkedList<Constraint>();
+
+ if (parent != null) {
+ allConstraints.addAll(parent.getAllConstraints());
+ }
+ allConstraints.addAll(constraints);
+
+ return allConstraints;
}
@@ -746,7 +750,6 @@
*/
protected final void deregisterConstraint(Constraint constraint) {
constraints.remove(constraint);
- allConstraints.remove(constraint);
}
@@ -798,7 +801,6 @@
*/
protected final void registerConstraint(Constraint constraint) {
constraints.add(constraint);
- allConstraints.add(constraint);
}
--
Gitblit v1.10.0