001 /*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License"). You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.admin;
028
029
030
031 /**
032 * A default behavior provider which retrieves default values from a
033 * managed object in an absolute location. It should be used by
034 * properties which inherit their default value(s) from properties
035 * held in an other managed object.
036 *
037 * @param <T>
038 * The type of values represented by this provider.
039 */
040 public final class AbsoluteInheritedDefaultBehaviorProvider<T> extends
041 DefaultBehaviorProvider<T> {
042
043 // The absolute path to the managed object containing the property.
044 private ManagedObjectPath<?, ?> path = null;
045
046 // The string representation of the managed object path specifying
047 // the absolute location of the managed object.
048 private final String pathString;
049
050 // The name of the property containing the inherited default values.
051 private final String propertyName;
052
053
054
055 /**
056 * Create an absolute inherited default behavior provider associated
057 * with the managed object at the specified absolute location.
058 *
059 * @param pathString
060 * The string representation of the managed object path
061 * specifying the absolute location of the managed object.
062 * @param propertyName
063 * The name of the property containing the inherited
064 * default values.
065 */
066 public AbsoluteInheritedDefaultBehaviorProvider(String pathString,
067 String propertyName) {
068 this.pathString = pathString;
069 this.propertyName = propertyName;
070 }
071
072
073
074 /**
075 * {@inheritDoc}
076 */
077 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) {
078 return v.visitAbsoluteInherited(this, p);
079 }
080
081
082
083 /**
084 * Get the definition of the parent managed object containing the
085 * inherited default values.
086 *
087 * @return Returns the definition of the parent managed object
088 * containing the inherited default values.
089 */
090 public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() {
091 return path.getManagedObjectDefinition();
092 }
093
094
095
096 /**
097 * Get the absolute path of the managed object containing the
098 * property which has the default values.
099 *
100 * @return Returns the absolute path of the managed object
101 * containing the property which has the default values.
102 */
103 public ManagedObjectPath<?, ?> getManagedObjectPath() {
104 return path;
105 }
106
107
108
109 /**
110 * Gets the name of the property containing the inherited default
111 * values.
112 *
113 * @return Returns the name of the property containing the inherited
114 * default values.
115 */
116 public String getPropertyName() {
117 return propertyName;
118 }
119
120
121
122 /**
123 * {@inheritDoc}
124 */
125 @Override
126 protected void initialize() throws Exception {
127 // Decode the path.
128 path = ManagedObjectPath.valueOf(pathString);
129 }
130
131 }