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