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 legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2013 ForgeRock AS. 025 */ 026package org.forgerock.opendj.config.server.spi; 027 028import java.util.List; 029import java.util.Set; 030 031import org.forgerock.opendj.config.server.ConfigException; 032import org.forgerock.opendj.ldap.DN; 033import org.forgerock.opendj.ldap.Entry; 034 035/** 036 * Provides configuration entries and listener registration on the entries. 037 */ 038public interface ConfigurationRepository { 039 040 /** 041 * Returns the set of DNs of children of the entry corresponding to the 042 * provided DN. . 043 * 044 * @param dn 045 * DN of a configuration entry. 046 * @return the set of DN of children of the corresponding entry 047 * @throws ConfigException 048 * If a problem occurs during retrieval. 049 */ 050 Set<DN> getChildren(DN dn) throws ConfigException; 051 052 /** 053 * Returns the configuration entry for the provided DN. 054 * 055 * @param dn 056 * DN of the configuration entry 057 * @return the config entry 058 * @throws ConfigException 059 * If a problem occurs while trying to retrieve the requested 060 * entry. 061 */ 062 Entry getEntry(DN dn) throws ConfigException; 063 064 /** 065 * Checks if the provided DN corresponds to a configuration entry. 066 * 067 * @param dn 068 * DN of the configuration entry 069 * @return {@code true} if and only if there is a configuration entry with 070 * this DN 071 * @throws ConfigException 072 * If a problem occurs. 073 */ 074 boolean hasEntry(DN dn) throws ConfigException; 075 076 /** 077 * Registers the provided add listener so that it will be notified if any 078 * new entries are added immediately below the entry corresponding to the 079 * provided DN. 080 * 081 * @param dn 082 * The DN of the configuration entry. 083 * @param listener 084 * The add listener that should be registered. 085 */ 086 void registerAddListener(DN dn, ConfigAddListener listener); 087 088 /** 089 * Registers the provided delete listener so that it will be notified if any 090 * entries are deleted immediately below the entry corresponding to the 091 * provided DN. 092 * 093 * @param dn 094 * The DN of the configuration entry. 095 * @param listener 096 * The delete listener that should be registered. 097 */ 098 void registerDeleteListener(DN dn, ConfigDeleteListener listener); 099 100 /** 101 * Registers the provided change listener so that it will be notified of any 102 * changes to the entry corrresponding to provided DN. No check will be made 103 * to determine whether the provided listener is already registered. 104 * 105 * @param dn 106 * The DN of the configuration entry. 107 * @param listener 108 * The change listener that should be registered. 109 */ 110 void registerChangeListener(DN dn, ConfigChangeListener listener); 111 112 /** 113 * Deregisters the provided add listener so that it will no longer be 114 * notified if any new entries are added immediately below the entry 115 * corresponding to the provided DN. 116 * 117 * @param dn 118 * The DN of the configuration entry. 119 * @param listener 120 * The add listener that should be deregistered. 121 */ 122 void deregisterAddListener(DN dn, ConfigAddListener listener); 123 124 /** 125 * Deregisters the provided delete listener so that it will no longer be 126 * notified if any entries are deleted immediately below the entry 127 * corresponding to the provided DN. 128 * 129 * @param dn 130 * The DN of the configuration entry. 131 * @param listener 132 * The delete listener that should be deregistered. 133 */ 134 void deregisterDeleteListener(DN dn, ConfigDeleteListener listener); 135 136 /** 137 * Attempts to deregister the provided change listener with the provided DN. 138 * 139 * @param dn 140 * The DN of the configuration entry. 141 * @param listener 142 * The change listener to deregister with this DN. 143 * @return <CODE>true</CODE> if the specified listener was deregistered, or 144 * <CODE>false</CODE> if it was not. 145 */ 146 boolean deregisterChangeListener(DN dn, ConfigChangeListener listener); 147 148 /** 149 * Retrieves the add listeners that have been registered with the provided 150 * DN. 151 * 152 * @param dn 153 * The DN of the configuration entry. 154 * @return The list of add listeners. 155 */ 156 List<ConfigAddListener> getAddListeners(DN dn); 157 158 /** 159 * Retrieves the delete listeners that have been registered with the 160 * provided DN. 161 * 162 * @param dn 163 * The DN of the configuration entry. 164 * @return The list of delete listeners. 165 */ 166 List<ConfigDeleteListener> getDeleteListeners(DN dn); 167 168 /** 169 * Retrieves the change listeners that have been registered with the 170 * provided DN. 171 * 172 * @param dn 173 * The DN of the configuration entry. 174 * @return The list of change listeners. 175 */ 176 List<ConfigChangeListener> getChangeListeners(DN dn); 177 178}