mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
24.14.2007 0365065aa3b626d057966eb1ddf947b5508c0912
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.
1 files modified
26 ■■■■ changed files
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java 26 ●●●● patch | view | raw | blame | history
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);
  }