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