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 2008 Sun Microsystems, Inc. 025 */ 026package org.opends.server.admin.std.meta; 027 028 029 030import java.util.Collection; 031import java.util.SortedSet; 032import org.opends.server.admin.AdministratorAction; 033import org.opends.server.admin.BooleanPropertyDefinition; 034import org.opends.server.admin.ClassPropertyDefinition; 035import org.opends.server.admin.client.AuthorizationException; 036import org.opends.server.admin.client.CommunicationException; 037import org.opends.server.admin.client.ConcurrentModificationException; 038import org.opends.server.admin.client.ManagedObject; 039import org.opends.server.admin.client.MissingMandatoryPropertiesException; 040import org.opends.server.admin.client.OperationRejectedException; 041import org.opends.server.admin.DefaultBehaviorProvider; 042import org.opends.server.admin.DefinedDefaultBehaviorProvider; 043import org.opends.server.admin.EnumPropertyDefinition; 044import org.opends.server.admin.ManagedObjectAlreadyExistsException; 045import org.opends.server.admin.ManagedObjectDefinition; 046import org.opends.server.admin.PropertyOption; 047import org.opends.server.admin.PropertyProvider; 048import org.opends.server.admin.server.ConfigurationChangeListener; 049import org.opends.server.admin.server.ServerManagedObject; 050import org.opends.server.admin.std.client.ChangeNumberControlPluginCfgClient; 051import org.opends.server.admin.std.meta.PluginCfgDefn.PluginType; 052import org.opends.server.admin.std.server.ChangeNumberControlPluginCfg; 053import org.opends.server.admin.std.server.PluginCfg; 054import org.opends.server.admin.Tag; 055import org.opends.server.types.DN; 056 057 058 059/** 060 * An interface for querying the Change Number Control Plugin managed 061 * object definition meta information. 062 * <p> 063 * The Change Number Control Plugin returns the change number 064 * generated by the replication subsystem. 065 */ 066public final class ChangeNumberControlPluginCfgDefn extends ManagedObjectDefinition<ChangeNumberControlPluginCfgClient, ChangeNumberControlPluginCfg> { 067 068 // The singleton configuration definition instance. 069 private static final ChangeNumberControlPluginCfgDefn INSTANCE = new ChangeNumberControlPluginCfgDefn(); 070 071 072 073 // The "java-class" property definition. 074 private static final ClassPropertyDefinition PD_JAVA_CLASS; 075 076 077 078 // The "plugin-type" property definition. 079 private static final EnumPropertyDefinition<PluginType> PD_PLUGIN_TYPE; 080 081 082 083 // Build the "java-class" property definition. 084 static { 085 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 086 builder.setOption(PropertyOption.MANDATORY); 087 builder.setOption(PropertyOption.ADVANCED); 088 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class")); 089 DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.plugins.ChangeNumberControlPlugin"); 090 builder.setDefaultBehaviorProvider(provider); 091 builder.addInstanceOf("org.opends.server.api.plugin.DirectoryServerPlugin"); 092 PD_JAVA_CLASS = builder.getInstance(); 093 INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS); 094 } 095 096 097 098 // Build the "plugin-type" property definition. 099 static { 100 EnumPropertyDefinition.Builder<PluginType> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "plugin-type"); 101 builder.setOption(PropertyOption.MULTI_VALUED); 102 builder.setOption(PropertyOption.MANDATORY); 103 builder.setOption(PropertyOption.ADVANCED); 104 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.COMPONENT_RESTART, INSTANCE, "plugin-type")); 105 DefaultBehaviorProvider<PluginType> provider = new DefinedDefaultBehaviorProvider<PluginType>("postOperationAdd", "postOperationDelete", "postOperationModify", "postOperationModifyDN"); 106 builder.setDefaultBehaviorProvider(provider); 107 builder.setEnumClass(PluginType.class); 108 PD_PLUGIN_TYPE = builder.getInstance(); 109 INSTANCE.registerPropertyDefinition(PD_PLUGIN_TYPE); 110 } 111 112 113 114 // Register the tags associated with this managed object definition. 115 static { 116 INSTANCE.registerTag(Tag.valueOf("core-server")); 117 } 118 119 120 121 /** 122 * Get the Change Number Control Plugin configuration definition 123 * singleton. 124 * 125 * @return Returns the Change Number Control Plugin configuration 126 * definition singleton. 127 */ 128 public static ChangeNumberControlPluginCfgDefn getInstance() { 129 return INSTANCE; 130 } 131 132 133 134 /** 135 * Private constructor. 136 */ 137 private ChangeNumberControlPluginCfgDefn() { 138 super("change-number-control-plugin", PluginCfgDefn.getInstance()); 139 } 140 141 142 143 /** 144 * {@inheritDoc} 145 */ 146 public ChangeNumberControlPluginCfgClient createClientConfiguration( 147 ManagedObject<? extends ChangeNumberControlPluginCfgClient> impl) { 148 return new ChangeNumberControlPluginCfgClientImpl(impl); 149 } 150 151 152 153 /** 154 * {@inheritDoc} 155 */ 156 public ChangeNumberControlPluginCfg createServerConfiguration( 157 ServerManagedObject<? extends ChangeNumberControlPluginCfg> impl) { 158 return new ChangeNumberControlPluginCfgServerImpl(impl); 159 } 160 161 162 163 /** 164 * {@inheritDoc} 165 */ 166 public Class<ChangeNumberControlPluginCfg> getServerConfigurationClass() { 167 return ChangeNumberControlPluginCfg.class; 168 } 169 170 171 172 /** 173 * Get the "enabled" property definition. 174 * <p> 175 * Indicates whether the plug-in is enabled for use. 176 * 177 * @return Returns the "enabled" property definition. 178 */ 179 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 180 return PluginCfgDefn.getInstance().getEnabledPropertyDefinition(); 181 } 182 183 184 185 /** 186 * Get the "invoke-for-internal-operations" property definition. 187 * <p> 188 * Indicates whether the plug-in should be invoked for internal 189 * operations. 190 * <p> 191 * Any plug-in that can be invoked for internal operations must 192 * ensure that it does not create any new internal operatons that can 193 * cause the same plug-in to be re-invoked. 194 * 195 * @return Returns the "invoke-for-internal-operations" property definition. 196 */ 197 public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() { 198 return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition(); 199 } 200 201 202 203 /** 204 * Get the "java-class" property definition. 205 * <p> 206 * Specifies the fully-qualified name of the Java class that 207 * provides the plug-in implementation. 208 * 209 * @return Returns the "java-class" property definition. 210 */ 211 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 212 return PD_JAVA_CLASS; 213 } 214 215 216 217 /** 218 * Get the "plugin-type" property definition. 219 * <p> 220 * Specifies the set of plug-in types for the plug-in, which 221 * specifies the times at which the plug-in is invoked. 222 * 223 * @return Returns the "plugin-type" property definition. 224 */ 225 public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() { 226 return PD_PLUGIN_TYPE; 227 } 228 229 230 231 /** 232 * Managed object client implementation. 233 */ 234 private static class ChangeNumberControlPluginCfgClientImpl implements 235 ChangeNumberControlPluginCfgClient { 236 237 // Private implementation. 238 private ManagedObject<? extends ChangeNumberControlPluginCfgClient> impl; 239 240 241 242 // Private constructor. 243 private ChangeNumberControlPluginCfgClientImpl( 244 ManagedObject<? extends ChangeNumberControlPluginCfgClient> impl) { 245 this.impl = impl; 246 } 247 248 249 250 /** 251 * {@inheritDoc} 252 */ 253 public Boolean isEnabled() { 254 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 255 } 256 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 public void setEnabled(boolean value) { 263 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 264 } 265 266 267 268 /** 269 * {@inheritDoc} 270 */ 271 public boolean isInvokeForInternalOperations() { 272 return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 273 } 274 275 276 277 /** 278 * {@inheritDoc} 279 */ 280 public void setInvokeForInternalOperations(Boolean value) { 281 impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value); 282 } 283 284 285 286 /** 287 * {@inheritDoc} 288 */ 289 public String getJavaClass() { 290 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 291 } 292 293 294 295 /** 296 * {@inheritDoc} 297 */ 298 public void setJavaClass(String value) { 299 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 300 } 301 302 303 304 /** 305 * {@inheritDoc} 306 */ 307 public SortedSet<PluginType> getPluginType() { 308 return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 309 } 310 311 312 313 /** 314 * {@inheritDoc} 315 */ 316 public void setPluginType(Collection<PluginType> values) { 317 impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values); 318 } 319 320 321 322 /** 323 * {@inheritDoc} 324 */ 325 public ManagedObjectDefinition<? extends ChangeNumberControlPluginCfgClient, ? extends ChangeNumberControlPluginCfg> definition() { 326 return INSTANCE; 327 } 328 329 330 331 /** 332 * {@inheritDoc} 333 */ 334 public PropertyProvider properties() { 335 return impl; 336 } 337 338 339 340 /** 341 * {@inheritDoc} 342 */ 343 public void commit() throws ManagedObjectAlreadyExistsException, 344 MissingMandatoryPropertiesException, ConcurrentModificationException, 345 OperationRejectedException, AuthorizationException, 346 CommunicationException { 347 impl.commit(); 348 } 349 350 351 352 /** {@inheritDoc} */ 353 public String toString() { 354 return impl.toString(); 355 } 356 } 357 358 359 360 /** 361 * Managed object server implementation. 362 */ 363 private static class ChangeNumberControlPluginCfgServerImpl implements 364 ChangeNumberControlPluginCfg { 365 366 // Private implementation. 367 private ServerManagedObject<? extends ChangeNumberControlPluginCfg> impl; 368 369 // The value of the "enabled" property. 370 private final boolean pEnabled; 371 372 // The value of the "invoke-for-internal-operations" property. 373 private final boolean pInvokeForInternalOperations; 374 375 // The value of the "java-class" property. 376 private final String pJavaClass; 377 378 // The value of the "plugin-type" property. 379 private final SortedSet<PluginType> pPluginType; 380 381 382 383 // Private constructor. 384 private ChangeNumberControlPluginCfgServerImpl(ServerManagedObject<? extends ChangeNumberControlPluginCfg> impl) { 385 this.impl = impl; 386 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 387 this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition()); 388 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 389 this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition()); 390 } 391 392 393 394 /** 395 * {@inheritDoc} 396 */ 397 public void addChangeNumberControlChangeListener( 398 ConfigurationChangeListener<ChangeNumberControlPluginCfg> listener) { 399 impl.registerChangeListener(listener); 400 } 401 402 403 404 /** 405 * {@inheritDoc} 406 */ 407 public void removeChangeNumberControlChangeListener( 408 ConfigurationChangeListener<ChangeNumberControlPluginCfg> listener) { 409 impl.deregisterChangeListener(listener); 410 } 411 /** 412 * {@inheritDoc} 413 */ 414 public void addChangeListener( 415 ConfigurationChangeListener<PluginCfg> listener) { 416 impl.registerChangeListener(listener); 417 } 418 419 420 421 /** 422 * {@inheritDoc} 423 */ 424 public void removeChangeListener( 425 ConfigurationChangeListener<PluginCfg> listener) { 426 impl.deregisterChangeListener(listener); 427 } 428 429 430 431 /** 432 * {@inheritDoc} 433 */ 434 public boolean isEnabled() { 435 return pEnabled; 436 } 437 438 439 440 /** 441 * {@inheritDoc} 442 */ 443 public boolean isInvokeForInternalOperations() { 444 return pInvokeForInternalOperations; 445 } 446 447 448 449 /** 450 * {@inheritDoc} 451 */ 452 public String getJavaClass() { 453 return pJavaClass; 454 } 455 456 457 458 /** 459 * {@inheritDoc} 460 */ 461 public SortedSet<PluginType> getPluginType() { 462 return pPluginType; 463 } 464 465 466 467 /** 468 * {@inheritDoc} 469 */ 470 public Class<? extends ChangeNumberControlPluginCfg> configurationClass() { 471 return ChangeNumberControlPluginCfg.class; 472 } 473 474 475 476 /** 477 * {@inheritDoc} 478 */ 479 public DN dn() { 480 return impl.getDN(); 481 } 482 483 484 485 /** {@inheritDoc} */ 486 public String toString() { 487 return impl.toString(); 488 } 489 } 490}