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  /** {@inheritDoc} */
098  public FractionalLDIFImportPluginCfgClient createClientConfiguration(
099      ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl) {
100    return new FractionalLDIFImportPluginCfgClientImpl(impl);
101  }
102
103
104
105  /** {@inheritDoc} */
106  public FractionalLDIFImportPluginCfg createServerConfiguration(
107      ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl) {
108    return new FractionalLDIFImportPluginCfgServerImpl(impl);
109  }
110
111
112
113  /** {@inheritDoc} */
114  public Class<FractionalLDIFImportPluginCfg> getServerConfigurationClass() {
115    return FractionalLDIFImportPluginCfg.class;
116  }
117
118
119
120  /**
121   * Get the "enabled" property definition.
122   * <p>
123   * Indicates whether the plug-in is enabled for use.
124   *
125   * @return Returns the "enabled" property definition.
126   */
127  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
128    return PluginCfgDefn.getInstance().getEnabledPropertyDefinition();
129  }
130
131
132
133  /**
134   * Get the "invoke-for-internal-operations" property definition.
135   * <p>
136   * Indicates whether the plug-in should be invoked for internal
137   * operations.
138   * <p>
139   * Any plug-in that can be invoked for internal operations must
140   * ensure that it does not create any new internal operatons that can
141   * cause the same plug-in to be re-invoked.
142   *
143   * @return Returns the "invoke-for-internal-operations" property definition.
144   */
145  public BooleanPropertyDefinition getInvokeForInternalOperationsPropertyDefinition() {
146    return PluginCfgDefn.getInstance().getInvokeForInternalOperationsPropertyDefinition();
147  }
148
149
150
151  /**
152   * Get the "java-class" property definition.
153   * <p>
154   * Specifies the fully-qualified name of the Java class that
155   * provides the plug-in implementation.
156   *
157   * @return Returns the "java-class" property definition.
158   */
159  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
160    return PluginCfgDefn.getInstance().getJavaClassPropertyDefinition();
161  }
162
163
164
165  /**
166   * Get the "plugin-type" property definition.
167   * <p>
168   * Specifies the set of plug-in types for the plug-in, which
169   * specifies the times at which the plug-in is invoked.
170   *
171   * @return Returns the "plugin-type" property definition.
172   */
173  public EnumPropertyDefinition<PluginType> getPluginTypePropertyDefinition() {
174    return PluginCfgDefn.getInstance().getPluginTypePropertyDefinition();
175  }
176
177
178
179  /**
180   * Managed object client implementation.
181   */
182  private static class FractionalLDIFImportPluginCfgClientImpl implements
183    FractionalLDIFImportPluginCfgClient {
184
185    /** Private implementation. */
186    private ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl;
187
188
189
190    /** Private constructor. */
191    private FractionalLDIFImportPluginCfgClientImpl(
192        ManagedObject<? extends FractionalLDIFImportPluginCfgClient> impl) {
193      this.impl = impl;
194    }
195
196
197
198    /** {@inheritDoc} */
199    public Boolean isEnabled() {
200      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
201    }
202
203
204
205    /** {@inheritDoc} */
206    public void setEnabled(boolean value) {
207      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
208    }
209
210
211
212    /** {@inheritDoc} */
213    public boolean isInvokeForInternalOperations() {
214      return impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
215    }
216
217
218
219    /** {@inheritDoc} */
220    public void setInvokeForInternalOperations(Boolean value) {
221      impl.setPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition(), value);
222    }
223
224
225
226    /** {@inheritDoc} */
227    public String getJavaClass() {
228      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
229    }
230
231
232
233    /** {@inheritDoc} */
234    public void setJavaClass(String value) {
235      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
236    }
237
238
239
240    /** {@inheritDoc} */
241    public SortedSet<PluginType> getPluginType() {
242      return impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
243    }
244
245
246
247    /** {@inheritDoc} */
248    public void setPluginType(Collection<PluginType> values) {
249      impl.setPropertyValues(INSTANCE.getPluginTypePropertyDefinition(), values);
250    }
251
252
253
254    /** {@inheritDoc} */
255    public ManagedObjectDefinition<? extends FractionalLDIFImportPluginCfgClient, ? extends FractionalLDIFImportPluginCfg> definition() {
256      return INSTANCE;
257    }
258
259
260
261    /** {@inheritDoc} */
262    public PropertyProvider properties() {
263      return impl;
264    }
265
266
267
268    /** {@inheritDoc} */
269    public void commit() throws ManagedObjectAlreadyExistsException,
270        MissingMandatoryPropertiesException, ConcurrentModificationException,
271        OperationRejectedException, LdapException {
272      impl.commit();
273    }
274
275
276
277    /** {@inheritDoc} */
278    public String toString() {
279      return impl.toString();
280    }
281  }
282
283
284
285  /**
286   * Managed object server implementation.
287   */
288  private static class FractionalLDIFImportPluginCfgServerImpl implements
289    FractionalLDIFImportPluginCfg {
290
291    /** Private implementation. */
292    private ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl;
293
294    /** The value of the "enabled" property. */
295    private final boolean pEnabled;
296
297    /** The value of the "invoke-for-internal-operations" property. */
298    private final boolean pInvokeForInternalOperations;
299
300    /** The value of the "java-class" property. */
301    private final String pJavaClass;
302
303    /** The value of the "plugin-type" property. */
304    private final SortedSet<PluginType> pPluginType;
305
306
307
308    /** Private constructor. */
309    private FractionalLDIFImportPluginCfgServerImpl(ServerManagedObject<? extends FractionalLDIFImportPluginCfg> impl) {
310      this.impl = impl;
311      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
312      this.pInvokeForInternalOperations = impl.getPropertyValue(INSTANCE.getInvokeForInternalOperationsPropertyDefinition());
313      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
314      this.pPluginType = impl.getPropertyValues(INSTANCE.getPluginTypePropertyDefinition());
315    }
316
317
318
319    /** {@inheritDoc} */
320    public void addFractionalLDIFImportChangeListener(
321        ConfigurationChangeListener<FractionalLDIFImportPluginCfg> listener) {
322      impl.registerChangeListener(listener);
323    }
324
325
326
327    /** {@inheritDoc} */
328    public void removeFractionalLDIFImportChangeListener(
329        ConfigurationChangeListener<FractionalLDIFImportPluginCfg> listener) {
330      impl.deregisterChangeListener(listener);
331    }
332    /** {@inheritDoc} */
333    public void addChangeListener(
334        ConfigurationChangeListener<PluginCfg> listener) {
335      impl.registerChangeListener(listener);
336    }
337
338
339
340    /** {@inheritDoc} */
341    public void removeChangeListener(
342        ConfigurationChangeListener<PluginCfg> listener) {
343      impl.deregisterChangeListener(listener);
344    }
345
346
347
348    /** {@inheritDoc} */
349    public boolean isEnabled() {
350      return pEnabled;
351    }
352
353
354
355    /** {@inheritDoc} */
356    public boolean isInvokeForInternalOperations() {
357      return pInvokeForInternalOperations;
358    }
359
360
361
362    /** {@inheritDoc} */
363    public String getJavaClass() {
364      return pJavaClass;
365    }
366
367
368
369    /** {@inheritDoc} */
370    public SortedSet<PluginType> getPluginType() {
371      return pPluginType;
372    }
373
374
375
376    /** {@inheritDoc} */
377    public Class<? extends FractionalLDIFImportPluginCfg> configurationClass() {
378      return FractionalLDIFImportPluginCfg.class;
379    }
380
381
382
383    /** {@inheritDoc} */
384    public DN dn() {
385      return impl.getDN();
386    }
387
388
389
390    /** {@inheritDoc} */
391    public String toString() {
392      return impl.toString();
393    }
394  }
395}