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