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.EntryCacheMonitorProviderCfgClient;
039import org.opends.server.admin.std.server.EntryCacheMonitorProviderCfg;
040import org.opends.server.admin.std.server.MonitorProviderCfg;
041import org.opends.server.admin.Tag;
042
043
044
045/**
046 * An interface for querying the Entry Cache Monitor Provider managed
047 * object definition meta information.
048 * <p>
049 * The Entry Cache Monitor Provider exposes monitor information about
050 * the state of OpenDJ directory server entry caches.
051 */
052public final class EntryCacheMonitorProviderCfgDefn extends ManagedObjectDefinition<EntryCacheMonitorProviderCfgClient, EntryCacheMonitorProviderCfg> {
053
054  // The singleton configuration definition instance.
055  private static final EntryCacheMonitorProviderCfgDefn INSTANCE = new EntryCacheMonitorProviderCfgDefn();
056
057
058
059  // The "java-class" property definition.
060  private static final ClassPropertyDefinition PD_JAVA_CLASS;
061
062
063
064  // Build the "java-class" property definition.
065  static {
066      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
067      builder.setOption(PropertyOption.MANDATORY);
068      builder.setOption(PropertyOption.ADVANCED);
069      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
070      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.monitors.EntryCacheMonitorProvider");
071      builder.setDefaultBehaviorProvider(provider);
072      builder.addInstanceOf("org.opends.server.api.MonitorProvider");
073      PD_JAVA_CLASS = builder.getInstance();
074      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
075  }
076
077
078
079  // Register the tags associated with this managed object definition.
080  static {
081    INSTANCE.registerTag(Tag.valueOf("core-server"));
082  }
083
084
085
086  /**
087   * Get the Entry Cache Monitor Provider configuration definition
088   * singleton.
089   *
090   * @return Returns the Entry Cache Monitor Provider configuration
091   *         definition singleton.
092   */
093  public static EntryCacheMonitorProviderCfgDefn getInstance() {
094    return INSTANCE;
095  }
096
097
098
099  /**
100   * Private constructor.
101   */
102  private EntryCacheMonitorProviderCfgDefn() {
103    super("entry-cache-monitor-provider", MonitorProviderCfgDefn.getInstance());
104  }
105
106
107
108  /**
109   * {@inheritDoc}
110   */
111  public EntryCacheMonitorProviderCfgClient createClientConfiguration(
112      ManagedObject<? extends EntryCacheMonitorProviderCfgClient> impl) {
113    return new EntryCacheMonitorProviderCfgClientImpl(impl);
114  }
115
116
117
118  /**
119   * {@inheritDoc}
120   */
121  public EntryCacheMonitorProviderCfg createServerConfiguration(
122      ServerManagedObject<? extends EntryCacheMonitorProviderCfg> impl) {
123    return new EntryCacheMonitorProviderCfgServerImpl(impl);
124  }
125
126
127
128  /**
129   * {@inheritDoc}
130   */
131  public Class<EntryCacheMonitorProviderCfg> getServerConfigurationClass() {
132    return EntryCacheMonitorProviderCfg.class;
133  }
134
135
136
137  /**
138   * Get the "enabled" property definition.
139   * <p>
140   * Indicates whether the Entry Cache Monitor Provider is enabled for
141   * use.
142   *
143   * @return Returns the "enabled" property definition.
144   */
145  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
146    return MonitorProviderCfgDefn.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 Entry Cache Monitor Provider 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 EntryCacheMonitorProviderCfgClientImpl implements
169    EntryCacheMonitorProviderCfgClient {
170
171    // Private implementation.
172    private ManagedObject<? extends EntryCacheMonitorProviderCfgClient> impl;
173
174
175
176    // Private constructor.
177    private EntryCacheMonitorProviderCfgClientImpl(
178        ManagedObject<? extends EntryCacheMonitorProviderCfgClient> 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 EntryCacheMonitorProviderCfgClient, ? extends EntryCacheMonitorProviderCfg> 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 EntryCacheMonitorProviderCfgServerImpl implements
262    EntryCacheMonitorProviderCfg {
263
264    // Private implementation.
265    private ServerManagedObject<? extends EntryCacheMonitorProviderCfg> 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 EntryCacheMonitorProviderCfgServerImpl(ServerManagedObject<? extends EntryCacheMonitorProviderCfg> 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 addEntryCacheChangeListener(
288        ConfigurationChangeListener<EntryCacheMonitorProviderCfg> listener) {
289      impl.registerChangeListener(listener);
290    }
291
292
293
294    /**
295     * {@inheritDoc}
296     */
297    public void removeEntryCacheChangeListener(
298        ConfigurationChangeListener<EntryCacheMonitorProviderCfg> listener) {
299      impl.deregisterChangeListener(listener);
300    }
301    /**
302     * {@inheritDoc}
303     */
304    public void addChangeListener(
305        ConfigurationChangeListener<MonitorProviderCfg> listener) {
306      impl.registerChangeListener(listener);
307    }
308
309
310
311    /**
312     * {@inheritDoc}
313     */
314    public void removeChangeListener(
315        ConfigurationChangeListener<MonitorProviderCfg> 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 EntryCacheMonitorProviderCfg> configurationClass() {
343      return EntryCacheMonitorProviderCfg.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}