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