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 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.admin.std.meta; 028 029 030 031 import org.opends.server.admin.AdministratorAction; 032 import org.opends.server.admin.ClassPropertyDefinition; 033 import org.opends.server.admin.client.AuthorizationException; 034 import org.opends.server.admin.client.CommunicationException; 035 import org.opends.server.admin.client.ConcurrentModificationException; 036 import org.opends.server.admin.client.ManagedObject; 037 import org.opends.server.admin.client.MissingMandatoryPropertiesException; 038 import org.opends.server.admin.client.OperationRejectedException; 039 import org.opends.server.admin.ManagedObjectAlreadyExistsException; 040 import org.opends.server.admin.ManagedObjectDefinition; 041 import org.opends.server.admin.PropertyOption; 042 import org.opends.server.admin.PropertyProvider; 043 import org.opends.server.admin.server.ConfigurationChangeListener; 044 import org.opends.server.admin.server.ServerManagedObject; 045 import org.opends.server.admin.std.client.WorkQueueCfgClient; 046 import org.opends.server.admin.std.server.WorkQueueCfg; 047 import org.opends.server.admin.Tag; 048 import org.opends.server.admin.TopCfgDefn; 049 import org.opends.server.admin.UndefinedDefaultBehaviorProvider; 050 import org.opends.server.types.DN; 051 052 053 054 /** 055 * An interface for querying the Work Queue managed object definition 056 * meta information. 057 * <p> 058 * The Work Queue provides the configuration for the server work queue 059 * and is responsible for ensuring that requests received from clients 060 * are processed in a timely manner. 061 */ 062 public final class WorkQueueCfgDefn extends ManagedObjectDefinition<WorkQueueCfgClient, WorkQueueCfg> { 063 064 // The singleton configuration definition instance. 065 private static final WorkQueueCfgDefn INSTANCE = new WorkQueueCfgDefn(); 066 067 068 069 // The "java-class" property definition. 070 private static final ClassPropertyDefinition PD_JAVA_CLASS; 071 072 073 074 // Build the "java-class" property definition. 075 static { 076 ClassPropertyDefinition.Builder builder = ClassPropertyDefinition.createBuilder(INSTANCE, "java-class"); 077 builder.setOption(PropertyOption.MANDATORY); 078 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.SERVER_RESTART, INSTANCE, "java-class")); 079 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>()); 080 builder.addInstanceOf("org.opends.server.api.WorkQueue"); 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("core-server")); 090 } 091 092 093 094 /** 095 * Get the Work Queue configuration definition singleton. 096 * 097 * @return Returns the Work Queue configuration definition 098 * singleton. 099 */ 100 public static WorkQueueCfgDefn getInstance() { 101 return INSTANCE; 102 } 103 104 105 106 /** 107 * Private constructor. 108 */ 109 private WorkQueueCfgDefn() { 110 super("work-queue", TopCfgDefn.getInstance()); 111 } 112 113 114 115 /** 116 * {@inheritDoc} 117 */ 118 public WorkQueueCfgClient createClientConfiguration( 119 ManagedObject<? extends WorkQueueCfgClient> impl) { 120 return new WorkQueueCfgClientImpl(impl); 121 } 122 123 124 125 /** 126 * {@inheritDoc} 127 */ 128 public WorkQueueCfg createServerConfiguration( 129 ServerManagedObject<? extends WorkQueueCfg> impl) { 130 return new WorkQueueCfgServerImpl(impl); 131 } 132 133 134 135 /** 136 * {@inheritDoc} 137 */ 138 public Class<WorkQueueCfg> getServerConfigurationClass() { 139 return WorkQueueCfg.class; 140 } 141 142 143 144 /** 145 * Get the "java-class" property definition. 146 * <p> 147 * Specifies the fully-qualified name of the Java class that 148 * provides the Work Queue implementation. 149 * 150 * @return Returns the "java-class" property definition. 151 */ 152 public ClassPropertyDefinition getJavaClassPropertyDefinition() { 153 return PD_JAVA_CLASS; 154 } 155 156 157 158 /** 159 * Managed object client implementation. 160 */ 161 private static class WorkQueueCfgClientImpl implements 162 WorkQueueCfgClient { 163 164 // Private implementation. 165 private ManagedObject<? extends WorkQueueCfgClient> impl; 166 167 168 169 // Private constructor. 170 private WorkQueueCfgClientImpl( 171 ManagedObject<? extends WorkQueueCfgClient> impl) { 172 this.impl = impl; 173 } 174 175 176 177 /** 178 * {@inheritDoc} 179 */ 180 public String getJavaClass() { 181 return impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 182 } 183 184 185 186 /** 187 * {@inheritDoc} 188 */ 189 public void setJavaClass(String value) { 190 impl.setPropertyValue(INSTANCE.getJavaClassPropertyDefinition(), value); 191 } 192 193 194 195 /** 196 * {@inheritDoc} 197 */ 198 public ManagedObjectDefinition<? extends WorkQueueCfgClient, ? extends WorkQueueCfg> definition() { 199 return INSTANCE; 200 } 201 202 203 204 /** 205 * {@inheritDoc} 206 */ 207 public PropertyProvider properties() { 208 return impl; 209 } 210 211 212 213 /** 214 * {@inheritDoc} 215 */ 216 public void commit() throws ManagedObjectAlreadyExistsException, 217 MissingMandatoryPropertiesException, ConcurrentModificationException, 218 OperationRejectedException, AuthorizationException, 219 CommunicationException { 220 impl.commit(); 221 } 222 223 } 224 225 226 227 /** 228 * Managed object server implementation. 229 */ 230 private static class WorkQueueCfgServerImpl implements 231 WorkQueueCfg { 232 233 // Private implementation. 234 private ServerManagedObject<? extends WorkQueueCfg> impl; 235 236 // The value of the "java-class" property. 237 private final String pJavaClass; 238 239 240 241 // Private constructor. 242 private WorkQueueCfgServerImpl(ServerManagedObject<? extends WorkQueueCfg> impl) { 243 this.impl = impl; 244 this.pJavaClass = impl.getPropertyValue(INSTANCE.getJavaClassPropertyDefinition()); 245 } 246 247 248 249 /** 250 * {@inheritDoc} 251 */ 252 public void addChangeListener( 253 ConfigurationChangeListener<WorkQueueCfg> listener) { 254 impl.registerChangeListener(listener); 255 } 256 257 258 259 /** 260 * {@inheritDoc} 261 */ 262 public void removeChangeListener( 263 ConfigurationChangeListener<WorkQueueCfg> listener) { 264 impl.deregisterChangeListener(listener); 265 } 266 267 268 269 /** 270 * {@inheritDoc} 271 */ 272 public String getJavaClass() { 273 return pJavaClass; 274 } 275 276 277 278 /** 279 * {@inheritDoc} 280 */ 281 public Class<? extends WorkQueueCfg> configurationClass() { 282 return WorkQueueCfg.class; 283 } 284 285 286 287 /** 288 * {@inheritDoc} 289 */ 290 public DN dn() { 291 return impl.getDN(); 292 } 293 294 } 295 }