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 org.forgerock.opendj.config.AdministratorAction;
031import org.forgerock.opendj.config.BooleanPropertyDefinition;
032import org.forgerock.opendj.config.ClassPropertyDefinition;
033import org.forgerock.opendj.config.client.ConcurrentModificationException;
034import org.forgerock.opendj.config.client.ManagedObject;
035import org.forgerock.opendj.config.client.MissingMandatoryPropertiesException;
036import org.forgerock.opendj.config.client.OperationRejectedException;
037import org.forgerock.opendj.config.DefaultBehaviorProvider;
038import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
039import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
040import org.forgerock.opendj.config.ManagedObjectDefinition;
041import org.forgerock.opendj.config.PropertyOption;
042import org.forgerock.opendj.config.PropertyProvider;
043import org.forgerock.opendj.config.server.ConfigurationChangeListener;
044import org.forgerock.opendj.config.server.ServerManagedObject;
045import org.forgerock.opendj.config.Tag;
046import org.forgerock.opendj.ldap.DN;
047import org.forgerock.opendj.ldap.LdapException;
048import org.forgerock.opendj.server.config.client.HTTPAccessLogPublisherCfgClient;
049import org.forgerock.opendj.server.config.server.HTTPAccessLogPublisherCfg;
050import org.forgerock.opendj.server.config.server.LogPublisherCfg;
051
052
053
054/**
055 * An interface for querying the HTTP Access Log Publisher managed
056 * object definition meta information.
057 * <p>
058 * HTTP Access Log Publishers are responsible for distributing HTTP
059 * access log messages from the HTTP access logger to a destination.
060 */
061public final class HTTPAccessLogPublisherCfgDefn extends ManagedObjectDefinition<HTTPAccessLogPublisherCfgClient, HTTPAccessLogPublisherCfg> {
062
063  // The singleton configuration definition instance.
064  private static final HTTPAccessLogPublisherCfgDefn INSTANCE = new HTTPAccessLogPublisherCfgDefn();
065
066
067
068  // The "java-class" property definition.
069  private static final ClassPropertyDefinition PD_JAVA_CLASS;
070
071
072
073  // Build the "java-class" property definition.
074  static {
075      ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class");
076      builder.setOption(PropertyOption.MANDATORY);
077      builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "java-class"));
078      DefaultBehaviorProvider<String> provider = new DefinedDefaultBehaviorProvider<String>("org.opends.server.loggers.HTTPAccessLogPublisher");
079      builder.setDefaultBehaviorProvider(provider);
080      builder.addInstanceOf("org.opends.server.loggers.LogPublisher");
081      PD_JAVA_CLASS = builder.getInstance();
082      INSTANCE.registerPropertyDefinition(PD_JAVA_CLASS);
083  }
084
085
086
087  // Register the tags associated with this managed object definition.
088  static {
089    INSTANCE.registerTag(Tag.valueOf("logging"));
090  }
091
092
093
094  /**
095   * Get the HTTP Access Log Publisher configuration definition
096   * singleton.
097   *
098   * @return Returns the HTTP Access Log Publisher configuration
099   *         definition singleton.
100   */
101  public static HTTPAccessLogPublisherCfgDefn getInstance() {
102    return INSTANCE;
103  }
104
105
106
107  /**
108   * Private constructor.
109   */
110  private HTTPAccessLogPublisherCfgDefn() {
111    super("http-access-log-publisher", LogPublisherCfgDefn.getInstance());
112  }
113
114
115
116  /**
117   * {@inheritDoc}
118   */
119  public HTTPAccessLogPublisherCfgClient createClientConfiguration(
120      ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl) {
121    return new HTTPAccessLogPublisherCfgClientImpl(impl);
122  }
123
124
125
126  /**
127   * {@inheritDoc}
128   */
129  public HTTPAccessLogPublisherCfg createServerConfiguration(
130      ServerManagedObject<? extends HTTPAccessLogPublisherCfg> impl) {
131    return new HTTPAccessLogPublisherCfgServerImpl(impl);
132  }
133
134
135
136  /**
137   * {@inheritDoc}
138   */
139  public Class<HTTPAccessLogPublisherCfg> getServerConfigurationClass() {
140    return HTTPAccessLogPublisherCfg.class;
141  }
142
143
144
145  /**
146   * Get the "enabled" property definition.
147   * <p>
148   * Indicates whether the HTTP Access Log Publisher is enabled for
149   * use.
150   *
151   * @return Returns the "enabled" property definition.
152   */
153  public BooleanPropertyDefinition getEnabledPropertyDefinition() {
154    return LogPublisherCfgDefn.getInstance().getEnabledPropertyDefinition();
155  }
156
157
158
159  /**
160   * Get the "java-class" property definition.
161   * <p>
162   * The fully-qualified name of the Java class that provides the HTTP
163   * Access Log Publisher implementation.
164   *
165   * @return Returns the "java-class" property definition.
166   */
167  public ClassPropertyDefinition getJavaClassPropertyDefinition() {
168    return PD_JAVA_CLASS;
169  }
170
171
172
173  /**
174   * Managed object client implementation.
175   */
176  private static class HTTPAccessLogPublisherCfgClientImpl implements
177    HTTPAccessLogPublisherCfgClient {
178
179    // Private implementation.
180    private ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl;
181
182
183
184    // Private constructor.
185    private HTTPAccessLogPublisherCfgClientImpl(
186        ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl) {
187      this.impl = impl;
188    }
189
190
191
192    /**
193     * {@inheritDoc}
194     */
195    public Boolean isEnabled() {
196      return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition());
197    }
198
199
200
201    /**
202     * {@inheritDoc}
203     */
204    public void setEnabled(boolean value) {
205      impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value);
206    }
207
208
209
210    /**
211     * {@inheritDoc}
212     */
213    public String getJavaClass() {
214      return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition());
215    }
216
217
218
219    /**
220     * {@inheritDoc}
221     */
222    public void setJavaClass(String value) {
223      impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value);
224    }
225
226
227
228    /**
229     * {@inheritDoc}
230     */
231    public ManagedObjectDefinition<? extends HTTPAccessLogPublisherCfgClient, ? extends HTTPAccessLogPublisherCfg> definition() {
232      return INSTANCE;
233    }
234
235
236
237    /**
238     * {@inheritDoc}
239     */
240    public PropertyProvider properties() {
241      return impl;
242    }
243
244
245
246    /**
247     * {@inheritDoc}
248     */
249    public void commit() throws ManagedObjectAlreadyExistsException,
250        MissingMandatoryPropertiesException, ConcurrentModificationException,
251        OperationRejectedException, LdapException {
252      impl.commit();
253    }
254
255  }
256
257
258
259  /**
260   * Managed object server implementation.
261   */
262  private static class HTTPAccessLogPublisherCfgServerImpl implements
263    HTTPAccessLogPublisherCfg {
264
265    // Private implementation.
266    private ServerManagedObject<? extends HTTPAccessLogPublisherCfg> 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 HTTPAccessLogPublisherCfgServerImpl(ServerManagedObject<? extends HTTPAccessLogPublisherCfg> 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 addHTTPAccessChangeListener(
289        ConfigurationChangeListener<HTTPAccessLogPublisherCfg> listener) {
290      impl.registerChangeListener(listener);
291    }
292
293
294
295    /**
296     * {@inheritDoc}
297     */
298    public void removeHTTPAccessChangeListener(
299        ConfigurationChangeListener<HTTPAccessLogPublisherCfg> listener) {
300      impl.deregisterChangeListener(listener);
301    }
302    /**
303     * {@inheritDoc}
304     */
305    public void addChangeListener(
306        ConfigurationChangeListener<LogPublisherCfg> listener) {
307      impl.registerChangeListener(listener);
308    }
309
310
311
312    /**
313     * {@inheritDoc}
314     */
315    public void removeChangeListener(
316        ConfigurationChangeListener<LogPublisherCfg> 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 HTTPAccessLogPublisherCfg> configurationClass() {
344      return HTTPAccessLogPublisherCfg.class;
345    }
346
347
348
349    /**
350     * {@inheritDoc}
351     */
352    public DN dn() {
353      return impl.getDN();
354    }
355
356  }
357}