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.SystemInfoMonitorProviderCfgClient;
039import org.opends.server.admin.std.server.MonitorProviderCfg;
040import org.opends.server.admin.std.server.SystemInfoMonitorProviderCfg;
041import org.opends.server.admin.Tag;
042
043
044
045/**
046 * An interface for querying the System Info Monitor Provider managed
047 * object definition meta information.
048 * <p>
049 * The System Info Monitor Provider can be used to publish information
050 * about the system and virtual machine on which the directory server
051 * is running.
052 */
053public final class SystemInfoMonitorProviderCfgDefn extends ManagedObjectDefinition<SystemInfoMonitorProviderCfgClient, SystemInfoMonitorProviderCfg> {
054
055  // The singleton configuration definition instance.
056  private static final SystemInfoMonitorProviderCfgDefn INSTANCE = new SystemInfoMonitorProviderCfgDefn();
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.NONE, INSTANCE, "java-class"));
071      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.monitors.SystemInfoMonitorProvider");
072      builder.setDefaultBehaviorProvider(provider);
073      builder.addInstanceOf("org.opends.server.api.MonitorProvider");
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 System Info Monitor Provider configuration definition
089   * singleton.
090   *
091   * @return Returns the System Info Monitor Provider configuration
092   *         definition singleton.
093   */
094  public static SystemInfoMonitorProviderCfgDefn getInstance() {
095    return INSTANCE;
096  }
097
098
099
100  /**
101   * Private constructor.
102   */
103  private SystemInfoMonitorProviderCfgDefn() {
104    super("system-info-monitor-provider", MonitorProviderCfgDefn.getInstance());
105  }
106
107
108
109  /**
110   * {@inheritDoc}
111   */
112  public SystemInfoMonitorProviderCfgClient createClientConfiguration(
113      ManagedObject<? extends SystemInfoMonitorProviderCfgClient> impl) {
114    return new SystemInfoMonitorProviderCfgClientImpl(impl);
115  }
116
117
118
119  /**
120   * {@inheritDoc}
121   */
122  public SystemInfoMonitorProviderCfg createServerConfiguration(
123      ServerManagedObject<? extends SystemInfoMonitorProviderCfg> impl) {
124    return new SystemInfoMonitorProviderCfgServerImpl(impl);
125  }
126
127
128
129  /**
130   * {@inheritDoc}
131   */
132  public Class<SystemInfoMonitorProviderCfg> getServerConfigurationClass() {
133    return SystemInfoMonitorProviderCfg.class;
134  }
135
136
137
138  /**
139   * Get the "enabled" property definition.
140   * <p>
141   * Indicates whether the System Info Monitor Provider is enabled for
142   * use.
143   *
144   * @return Returns the "enabled" property definition.
145   */
146  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
147    return MonitorProviderCfgDefn.getInstance().getEnabledPropertyDefinition();
148  }
149
150
151
152  /**
153   * Get the "java-class" property definition.
154   * <p>
155   * Specifies the fully-qualified name of the Java class that
156   * provides the System Info Monitor Provider implementation.
157   *
158   * @return Returns the "java-class" property definition.
159   */
160  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
161    return PD_JAVA_CLASS;
162  }
163
164
165
166  /**
167   * Managed object client implementation.
168   */
169  private static class SystemInfoMonitorProviderCfgClientImpl implements
170    SystemInfoMonitorProviderCfgClient {
171
172    // Private implementation.
173    private ManagedObject<? extends SystemInfoMonitorProviderCfgClient> impl;
174
175
176
177    // Private constructor.
178    private SystemInfoMonitorProviderCfgClientImpl(
179        ManagedObject<? extends SystemInfoMonitorProviderCfgClient> impl) {
180      this.impl = impl;
181    }
182
183
184
185    /**
186     * {@inheritDoc}
187     */
188    public Boolean isEnabled() {
189      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
190    }
191
192
193
194    /**
195     * {@inheritDoc}
196     */
197    public void setEnabled(boolean value) {
198      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
199    }
200
201
202
203    /**
204     * {@inheritDoc}
205     */
206    public String getJavaClass() {
207      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
208    }
209
210
211
212    /**
213     * {@inheritDoc}
214     */
215    public void setJavaClass(String value) {
216      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
217    }
218
219
220
221    /**
222     * {@inheritDoc}
223     */
224    public ManagedObjectDefinition<? extends SystemInfoMonitorProviderCfgClient, ? extends SystemInfoMonitorProviderCfg> definition() {
225      return INSTANCE;
226    }
227
228
229
230    /**
231     * {@inheritDoc}
232     */
233    public PropertyProvider properties() {
234      return impl;
235    }
236
237
238
239    /**
240     * {@inheritDoc}
241     */
242    public void commit() throws ManagedObjectAlreadyExistsException,
243        MissingMandatoryPropertiesException, ConcurrentModificationException,
244        OperationRejectedException, AuthorizationException,
245        CommunicationException {
246      impl.commit();
247    }
248
249
250
251    /** {@inheritDoc} */
252    public String toString() {
253      return impl.toString();
254    }
255  }
256
257
258
259  /**
260   * Managed object server implementation.
261   */
262  private static class SystemInfoMonitorProviderCfgServerImpl implements
263    SystemInfoMonitorProviderCfg {
264
265    // Private implementation.
266    private ServerManagedObject<? extends SystemInfoMonitorProviderCfg> impl;
267
268    // The value of the "enabled" property.
269    private final boolean pEnabled;
270
271    // The value of the "java-class" property.
272    private final String pJavaClass;
273
274
275
276    // Private constructor.
277    private SystemInfoMonitorProviderCfgServerImpl(ServerManagedObject<? extends SystemInfoMonitorProviderCfg> impl) {
278      this.impl = impl;
279      this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
280      this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
281    }
282
283
284
285    /**
286     * {@inheritDoc}
287     */
288    public void addSystemInfoChangeListener(
289        ConfigurationChangeListener<SystemInfoMonitorProviderCfg> listener) {
290      impl.registerChangeListener(listener);
291    }
292
293
294
295    /**
296     * {@inheritDoc}
297     */
298    public void removeSystemInfoChangeListener(
299        ConfigurationChangeListener<SystemInfoMonitorProviderCfg> listener) {
300      impl.deregisterChangeListener(listener);
301    }
302    /**
303     * {@inheritDoc}
304     */
305    public void addChangeListener(
306        ConfigurationChangeListener<MonitorProviderCfg> listener) {
307      impl.registerChangeListener(listener);
308    }
309
310
311
312    /**
313     * {@inheritDoc}
314     */
315    public void removeChangeListener(
316        ConfigurationChangeListener<MonitorProviderCfg> listener) {
317      impl.deregisterChangeListener(listener);
318    }
319
320
321
322    /**
323     * {@inheritDoc}
324     */
325    public boolean isEnabled() {
326      return pEnabled;
327    }
328
329
330
331    /**
332     * {@inheritDoc}
333     */
334    public String getJavaClass() {
335      return pJavaClass;
336    }
337
338
339
340    /**
341     * {@inheritDoc}
342     */
343    public Class<? extends SystemInfoMonitorProviderCfg> configurationClass() {
344      return SystemInfoMonitorProviderCfg.class;
345    }
346
347
348
349    /**
350     * {@inheritDoc}
351     */
352    public DN dn() {
353      return impl.getDN();
354    }
355
356
357
358    /** {@inheritDoc} */
359    public String toString() {
360      return impl.toString();
361    }
362  }
363}