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