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 /** {@inheritDoc} */ 117 public HTTPAccessLogPublisherCfgClient createClientConfiguration( 118 ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl) { 119 return new HTTPAccessLogPublisherCfgClientImpl(impl); 120 } 121 122 123 124 /** {@inheritDoc} */ 125 public HTTPAccessLogPublisherCfg createServerConfiguration( 126 ServerManagedObject<? extends HTTPAccessLogPublisherCfg> impl) { 127 return new HTTPAccessLogPublisherCfgServerImpl(impl); 128 } 129 130 131 132 /** {@inheritDoc} */ 133 public Class<HTTPAccessLogPublisherCfg> getServerConfigurationClass() { 134 return HTTPAccessLogPublisherCfg.class; 135 } 136 137 138 139 /** 140 * Get the "enabled" property definition. 141 * <p> 142 * Indicates whether the HTTP Access Log Publisher is enabled for 143 * use. 144 * 145 * @return Returns the "enabled" property definition. 146 */ 147 public BooleanPropertyDefinition getEnabledPropertyDefinition() { 148 return LogPublisherCfgDefn.getInstance().getEnabledPropertyDefinition(); 149 } 150 151 152 153 /** 154 * Get the "java-class" property definition. 155 * <p> 156 * The fully-qualified name of the Java class that provides the HTTP 157 * Access Log Publisher implementation. 158 * 159 * @return Returns the "java-class" property definition. 160 */ 161 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 162 return PD_JAVA_CLASS; 163 } 164 165 166 167 /** 168 * Managed object client implementation. 169 */ 170 private static class HTTPAccessLogPublisherCfgClientImpl implements 171 HTTPAccessLogPublisherCfgClient { 172 173 /** Private implementation. */ 174 private ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl; 175 176 177 178 /** Private constructor. */ 179 private HTTPAccessLogPublisherCfgClientImpl( 180 ManagedObject<? extends HTTPAccessLogPublisherCfgClient> impl) { 181 this.impl = impl; 182 } 183 184 185 186 /** {@inheritDoc} */ 187 public Boolean isEnabled() { 188 return impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 189 } 190 191 192 193 /** {@inheritDoc} */ 194 public void setEnabled(boolean value) { 195 impl.setPropertyValue(INSTANCE.getEnabledPropertyDefinition(), value); 196 } 197 198 199 200 /** {@inheritDoc} */ 201 public String getJavaClass() { 202 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 203 } 204 205 206 207 /** {@inheritDoc} */ 208 public void setJavaClass(String value) { 209 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 210 } 211 212 213 214 /** {@inheritDoc} */ 215 public ManagedObjectDefinition<? extends HTTPAccessLogPublisherCfgClient, ? extends HTTPAccessLogPublisherCfg> definition() { 216 return INSTANCE; 217 } 218 219 220 221 /** {@inheritDoc} */ 222 public PropertyProvider properties() { 223 return impl; 224 } 225 226 227 228 /** {@inheritDoc} */ 229 public void commit() throws ManagedObjectAlreadyExistsException, 230 MissingMandatoryPropertiesException, ConcurrentModificationException, 231 OperationRejectedException, LdapException { 232 impl.commit(); 233 } 234 235 236 237 /** {@inheritDoc} */ 238 public String toString() { 239 return impl.toString(); 240 } 241 } 242 243 244 245 /** 246 * Managed object server implementation. 247 */ 248 private static class HTTPAccessLogPublisherCfgServerImpl implements 249 HTTPAccessLogPublisherCfg { 250 251 /** Private implementation. */ 252 private ServerManagedObject<? extends HTTPAccessLogPublisherCfg> impl; 253 254 /** The value of the "enabled" property. */ 255 private final boolean pEnabled; 256 257 /** The value of the "java-class" property. */ 258 private final String pJavaClass; 259 260 261 262 /** Private constructor. */ 263 private HTTPAccessLogPublisherCfgServerImpl(ServerManagedObject<? extends HTTPAccessLogPublisherCfg> impl) { 264 this.impl = impl; 265 this.pEnabled = impl.getPropertyValue(INSTANCE.getEnabledPropertyDefinition()); 266 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 267 } 268 269 270 271 /** {@inheritDoc} */ 272 public void addHTTPAccessChangeListener( 273 ConfigurationChangeListener<HTTPAccessLogPublisherCfg> listener) { 274 impl.registerChangeListener(listener); 275 } 276 277 278 279 /** {@inheritDoc} */ 280 public void removeHTTPAccessChangeListener( 281 ConfigurationChangeListener<HTTPAccessLogPublisherCfg> listener) { 282 impl.deregisterChangeListener(listener); 283 } 284 /** {@inheritDoc} */ 285 public void addChangeListener( 286 ConfigurationChangeListener<LogPublisherCfg> listener) { 287 impl.registerChangeListener(listener); 288 } 289 290 291 292 /** {@inheritDoc} */ 293 public void removeChangeListener( 294 ConfigurationChangeListener<LogPublisherCfg> listener) { 295 impl.deregisterChangeListener(listener); 296 } 297 298 299 300 /** {@inheritDoc} */ 301 public boolean isEnabled() { 302 return pEnabled; 303 } 304 305 306 307 /** {@inheritDoc} */ 308 public String getJavaClass() { 309 return pJavaClass; 310 } 311 312 313 314 /** {@inheritDoc} */ 315 public Class<? extends HTTPAccessLogPublisherCfg> configurationClass() { 316 return HTTPAccessLogPublisherCfg.class; 317 } 318 319 320 321 /** {@inheritDoc} */ 322 public DN dn() { 323 return impl.getDN(); 324 } 325 326 327 328 /** {@inheritDoc} */ 329 public String toString() { 330 return impl.toString(); 331 } 332 } 333}