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 * Portions Copyright 2015 ForgeRock AS. 016 */ 017package org.opends.server.admin; 018 019 020 021/** 022 * A default behavior provider which retrieves default values from a 023 * managed object in an absolute location. It should be used by 024 * properties which inherit their default value(s) from properties 025 * held in an other managed object. 026 * 027 * @param <T> 028 * The type of values represented by this provider. 029 */ 030public final class AbsoluteInheritedDefaultBehaviorProvider<T> extends 031 DefaultBehaviorProvider<T> { 032 033 /** The absolute path to the managed object containing the property. */ 034 private ManagedObjectPath<?, ?> path; 035 036 /** 037 * The string representation of the managed object path specifying 038 * the absolute location of the managed object. 039 */ 040 private final String pathString; 041 042 /** The name of the property containing the inherited default values. */ 043 private final String propertyName; 044 045 046 047 /** 048 * Create an absolute inherited default behavior provider associated 049 * with the managed object at the specified absolute location. 050 * 051 * @param pathString 052 * The string representation of the managed object path 053 * specifying the absolute location of the managed object. 054 * @param propertyName 055 * The name of the property containing the inherited 056 * default values. 057 */ 058 public AbsoluteInheritedDefaultBehaviorProvider(String pathString, 059 String propertyName) { 060 this.pathString = pathString; 061 this.propertyName = propertyName; 062 } 063 064 065 066 /** {@inheritDoc} */ 067 public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { 068 return v.visitAbsoluteInherited(this, p); 069 } 070 071 072 073 /** 074 * Get the definition of the parent managed object containing the 075 * inherited default values. 076 * 077 * @return Returns the definition of the parent managed object 078 * containing the inherited default values. 079 */ 080 public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() { 081 return path.getManagedObjectDefinition(); 082 } 083 084 085 086 /** 087 * Get the absolute path of the managed object containing the 088 * property which has the default values. 089 * 090 * @return Returns the absolute path of the managed object 091 * containing the property which has the default values. 092 */ 093 public ManagedObjectPath<?, ?> getManagedObjectPath() { 094 return path; 095 } 096 097 098 099 /** 100 * Gets the name of the property containing the inherited default 101 * values. 102 * 103 * @return Returns the name of the property containing the inherited 104 * default values. 105 */ 106 public String getPropertyName() { 107 return propertyName; 108 } 109 110 111 112 /** {@inheritDoc} */ 113 @Override 114 protected void initialize() throws Exception { 115 // Decode the path. 116 path = ManagedObjectPath.valueOf(pathString); 117 } 118 119}