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