001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2008 Sun Microsystems, Inc. 015 */ 016package org.forgerock.opendj.config; 017 018/** 019 * A default behavior provider which retrieves default values from a managed 020 * object in an absolute location. It should be used by properties which inherit 021 * their default value(s) from properties held in an other managed object. 022 * 023 * @param <T> 024 * The type of values represented by this provider. 025 */ 026public final class AbsoluteInheritedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { 027 028 /** The absolute path to the managed object containing the property. */ 029 private ManagedObjectPath<?, ?> path; 030 031 /** 032 * The string representation of the managed object path specifying 033 * the absolute location of the managed object. 034 */ 035 private final String pathString; 036 037 /** The name of the property containing the inherited default values. */ 038 private final String propertyName; 039 040 /** 041 * Create an absolute inherited default behavior provider associated with 042 * the managed object at the specified absolute location. 043 * 044 * @param pathString 045 * The string representation of the managed object path 046 * specifying the absolute location of the managed object. 047 * @param propertyName 048 * The name of the property containing the inherited default 049 * values. 050 */ 051 public AbsoluteInheritedDefaultBehaviorProvider(String pathString, String propertyName) { 052 this.pathString = pathString; 053 this.propertyName = propertyName; 054 } 055 056 /** {@inheritDoc} */ 057 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { 058 return v.visitAbsoluteInherited(this, p); 059 } 060 061 /** 062 * Get the definition of the parent managed object containing the inherited 063 * default values. 064 * 065 * @return Returns the definition of the parent managed object containing 066 * the inherited default values. 067 */ 068 public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() { 069 return path.getManagedObjectDefinition(); 070 } 071 072 /** 073 * Get the absolute path of the managed object containing the property which 074 * has the default values. 075 * 076 * @return Returns the absolute path of the managed object containing the 077 * property which has the default values. 078 */ 079 public ManagedObjectPath<?, ?> getManagedObjectPath() { 080 return path; 081 } 082 083 /** 084 * Gets the name of the property containing the inherited default values. 085 * 086 * @return Returns the name of the property containing the inherited default 087 * values. 088 */ 089 public String getPropertyName() { 090 return propertyName; 091 } 092 093 /** {@inheritDoc} */ 094 @Override 095 protected void initialize() throws Exception { 096 // Decode the path. 097 path = ManagedObjectPath.valueOf(pathString); 098 } 099 100}