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