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