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