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.std.meta; 028 029 030 031 import org.opends.server.admin.BooleanPropertyDefinition; 032 import org.opends.server.admin.ClassPropertyDefinition; 033 import org.opends.server.admin.client.AuthorizationException; 034 import org.opends.server.admin.client.CommunicationException; 035 import org.opends.server.admin.client.ConcurrentModificationException; 036 import org.opends.server.admin.client.ManagedObject; 037 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 038 import org.opends.server.admin.client.OperationRejectedException; 039 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 040 import org.opends.server.admin.ManagedObjectDefinition; 041 import org.opends.server.admin.PropertyProvider; 042 import org.opends.server.admin.server.ConfigurationChangeListener; 043 import org.opends.server.admin.server.ServerManagedObject; 044 import org.opends.server.admin.std.client.EqualityMatchingRuleCfgClient; 045 import org.opends.server.admin.std.server.EqualityMatchingRuleCfg; 046 import org.opends.server.admin.std.server.MatchingRuleCfg; 047 import org.opends.server.admin.Tag; 048 import org.opends.server.types.DN; 049 050 051 052 /** 053 * An interface for querying the Equality Matching Rule managed object 054 * definition meta information. 055 * <p> 056 * Equality Matching Rules define a set of rules for performing 057 * equality matching operations against assertion values (that is, to 058 * determine whether an attribute value equals an assertion value). 059 */ 060 public final class EqualityMatchingRuleCfgDefn extends ManagedObjectDefinition<EqualityMatchingRuleCfgClient, EqualityMatchingRuleCfg> { 061 062 // The singleton configuration definition instance. 063 private static final EqualityMatchingRuleCfgDefn INSTANCE = new EqualityMatchingRuleCfgDefn(); 064 065 066 067 // Register the tags associated with this managed object definition. 068 static { 069 INSTANCE.registerTag(Tag.valueOf("core-server")); 070 } 071 072 073 074 /** 075 * Get the Equality Matching Rule configuration definition 076 * singleton. 077 * 078 * @return Returns the Equality Matching Rule configuration 079 * definition singleton. 080 */ 081 public static EqualityMatchingRuleCfgDefn getInstance() { 082 return INSTANCE; 083 } 084 085 086 087 /** 088 * Private constructor. 089 */ 090 private EqualityMatchingRuleCfgDefn() { 091 super("equality-matching-rule", MatchingRuleCfgDefn.getInstance()); 092 } 093 094 095 096 /** 097 * {@inheritDoc} 098 */ 099 public EqualityMatchingRuleCfgClient createClientConfiguration( 100 ManagedObject<? extends EqualityMatchingRuleCfgClient> impl) { 101 return new EqualityMatchingRuleCfgClientImpl(impl); 102 } 103 104 105 106 /** 107 * {@inheritDoc} 108 */ 109 public EqualityMatchingRuleCfg createServerConfiguration( 110 ServerManagedObject<? extends EqualityMatchingRuleCfg> impl) { 111 return new EqualityMatchingRuleCfgServerImpl(impl); 112 } 113 114 115 116 /** 117 * {@inheritDoc} 118 */ 119 public Class<EqualityMatchingRuleCfg> getServerConfigurationClass() { 120 return EqualityMatchingRuleCfg.class; 121 } 122 123 124 125 /** 126 * Get the "enabled" property definition. 127 * <p> 128 * Indicates whether the Equality Matching Rule is enabled for use. 129 * 130 * @return Returns the "enabled" property definition. 131 */ 132 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 133 return MatchingRuleCfgDefn.getInstance().getEnabledPropertyDefinition(); 134 } 135 136 137 138 /** 139 * Get the "java-class" property definition. 140 * <p> 141 * Specifies the fully-qualified name of the Java class that 142 * provides the Equality Matching Rule implementation. 143 * 144 * @return Returns the "java-class" property definition. 145 */ 146 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 147 return MatchingRuleCfgDefn.getInstance().getJavaClassPropertyDefinition(); 148 } 149 150 151 152 /** 153 * Managed object client implementation. 154 */ 155 private static class EqualityMatchingRuleCfgClientImpl implements 156 EqualityMatchingRuleCfgClient { 157 158 // Private implementation. 159 private ManagedObject<? extends EqualityMatchingRuleCfgClient> impl; 160 161 162 163 // Private constructor. 164 private EqualityMatchingRuleCfgClientImpl( 165 ManagedObject<? extends EqualityMatchingRuleCfgClient> impl) { 166 this.impl = impl; 167 } 168 169 170 171 /** 172 * {@inheritDoc} 173 */ 174 public Boolean isEnabled() { 175 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 176 } 177 178 179 180 /** 181 * {@inheritDoc} 182 */ 183 public void setEnabled(boolean value) { 184 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 185 } 186 187 188 189 /** 190 * {@inheritDoc} 191 */ 192 public String getJavaClass() { 193 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 194 } 195 196 197 198 /** 199 * {@inheritDoc} 200 */ 201 public void setJavaClass(String value) { 202 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 203 } 204 205 206 207 /** 208 * {@inheritDoc} 209 */ 210 public ManagedObjectDefinition<? extends EqualityMatchingRuleCfgClient, ? extends EqualityMatchingRuleCfg> definition() { 211 return INSTANCE; 212 } 213 214 215 216 /** 217 * {@inheritDoc} 218 */ 219 public PropertyProvider properties() { 220 return impl; 221 } 222 223 224 225 /** 226 * {@inheritDoc} 227 */ 228 public void commit() throws ManagedObjectAlreadyExistsException, 229 MissingMandatoryPropertiesException, ConcurrentModificationException, 230 OperationRejectedException, AuthorizationException, 231 CommunicationException { 232 impl.commit(); 233 } 234 235 } 236 237 238 239 /** 240 * Managed object server implementation. 241 */ 242 private static class EqualityMatchingRuleCfgServerImpl implements 243 EqualityMatchingRuleCfg { 244 245 // Private implementation. 246 private ServerManagedObject<? extends EqualityMatchingRuleCfg> impl; 247 248 // The value of the "enabled" property. 249 private final boolean pEnabled; 250 251 // The value of the "java-class" property. 252 private final String pJavaClass; 253 254 255 256 // Private constructor. 257 private EqualityMatchingRuleCfgServerImpl(ServerManagedObject<? extends EqualityMatchingRuleCfg> impl) { 258 this.impl = impl; 259 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 260 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 261 } 262 263 264 265 /** 266 * {@inheritDoc} 267 */ 268 public void addEqualityChangeListener( 269 ConfigurationChangeListener<EqualityMatchingRuleCfg> listener) { 270 impl.registerChangeListener(listener); 271 } 272 273 274 275 /** 276 * {@inheritDoc} 277 */ 278 public void removeEqualityChangeListener( 279 ConfigurationChangeListener<EqualityMatchingRuleCfg> listener) { 280 impl.deregisterChangeListener(listener); 281 } 282 /** 283 * {@inheritDoc} 284 */ 285 public void addChangeListener( 286 ConfigurationChangeListener<MatchingRuleCfg> listener) { 287 impl.registerChangeListener(listener); 288 } 289 290 291 292 /** 293 * {@inheritDoc} 294 */ 295 public void removeChangeListener( 296 ConfigurationChangeListener<MatchingRuleCfg> listener) { 297 impl.deregisterChangeListener(listener); 298 } 299 300 301 302 /** 303 * {@inheritDoc} 304 */ 305 public boolean isEnabled() { 306 return pEnabled; 307 } 308 309 310 311 /** 312 * {@inheritDoc} 313 */ 314 public String getJavaClass() { 315 return pJavaClass; 316 } 317 318 319 320 /** 321 * {@inheritDoc} 322 */ 323 public Class<? extends EqualityMatchingRuleCfg> configurationClass() { 324 return EqualityMatchingRuleCfg.class; 325 } 326 327 328 329 /** 330 * {@inheritDoc} 331 */ 332 public DN dn() { 333 return impl.getDN(); 334 } 335 336 } 337 }