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 java.util.Collection;
032 import java.util.SortedSet;
033 import org.opends.server.admin.AdministratorAction;
034 import org.opends.server.admin.AliasDefaultBehaviorProvider;
035 import org.opends.server.admin.BooleanPropertyDefinition;
036 import org.opends.server.admin.client.AuthorizationException;
037 import org.opends.server.admin.client.CommunicationException;
038 import org.opends.server.admin.client.ConcurrentModificationException;
039 import org.opends.server.admin.client.ManagedObject;
040 import org.opends.server.admin.client.MissingMandatoryPropertiesException;
041 import org.opends.server.admin.client.OperationRejectedException;
042 import org.opends.server.admin.DefaultBehaviorProvider;
043 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
044 import org.opends.server.admin.EnumPropertyDefinition;
045 import org.opends.server.admin.IntegerPropertyDefinition;
046 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
047 import org.opends.server.admin.ManagedObjectDefinition;
048 import org.opends.server.admin.PropertyIsReadOnlyException;
049 import org.opends.server.admin.PropertyOption;
050 import org.opends.server.admin.PropertyProvider;
051 import org.opends.server.admin.server.ConfigurationChangeListener;
052 import org.opends.server.admin.server.ServerManagedObject;
053 import org.opends.server.admin.std.client.DebugTargetCfgClient;
054 import org.opends.server.admin.std.server.DebugTargetCfg;
055 import org.opends.server.admin.StringPropertyDefinition;
056 import org.opends.server.admin.Tag;
057 import org.opends.server.admin.TopCfgDefn;
058 import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
059 import org.opends.server.types.DN;
060
061
062
063 /**
064 * An interface for querying the Debug Target managed object
065 * definition meta information.
066 * <p>
067 * Debug Targets define the types of messages logged by the debug
068 * logPublisher.
069 */
070 public final class DebugTargetCfgDefn extends ManagedObjectDefinition<DebugTargetCfgClient, DebugTargetCfg> {
071
072 // The singleton configuration definition instance.
073 private static final DebugTargetCfgDefn INSTANCE = new DebugTargetCfgDefn();
074
075
076
077 /**
078 * Defines the set of permissable values for the "debug-category" property.
079 * <p>
080 * Specifies the debug message categories to be logged.
081 */
082 public static enum DebugCategory {
083
084 /**
085 * Exception caught
086 */
087 CAUGHT("caught"),
088
089
090
091 /**
092 * Constructor entry
093 */
094 CONSTRUCTOR("constructor"),
095
096
097
098 /**
099 * Raw data dump
100 */
101 DATA("data"),
102
103
104
105 /**
106 * Access to a backend database.
107 */
108 DATABASE_ACCESS("database-access"),
109
110
111
112 /**
113 * Method entry
114 */
115 ENTER("enter"),
116
117
118
119 /**
120 * Method exit
121 */
122 EXIT("exit"),
123
124
125
126 /**
127 * Arbitrary debug message
128 */
129 MESSAGE("message"),
130
131
132
133 /**
134 * Protocol element dump
135 */
136 PROTOCOL("protocol"),
137
138
139
140 /**
141 * Exception throw from method
142 */
143 THROWN("thrown");
144
145
146
147 // String representation of the value.
148 private final String name;
149
150
151
152 // Private constructor.
153 private DebugCategory(String name) { this.name = name; }
154
155
156
157 /**
158 * {@inheritDoc}
159 */
160 public String toString() { return name; }
161
162 }
163
164
165
166 /**
167 * Defines the set of permissable values for the "debug-level" property.
168 * <p>
169 * Specifies the lowest severity level of debug messages to log.
170 */
171 public static enum DebugLevel {
172
173 /**
174 * Messages with any severity level are logged.
175 */
176 ALL("all"),
177
178
179
180 /**
181 * No messages are logged.
182 */
183 DISABLED("disabled"),
184
185
186
187 /**
188 * Messages with severity level of ERROR or higher are logged.
189 */
190 ERROR("error"),
191
192
193
194 /**
195 * Messages with severity level of INFO or higher are logged.
196 */
197 INFO("info"),
198
199
200
201 /**
202 * Messages with severity level of VERBOSE or higher are logged.
203 */
204 VERBOSE("verbose"),
205
206
207
208 /**
209 * Messages with severity level of WARNING or higher are logged.
210 */
211 WARNING("warning");
212
213
214
215 // String representation of the value.
216 private final String name;
217
218
219
220 // Private constructor.
221 private DebugLevel(String name) { this.name = name; }
222
223
224
225 /**
226 * {@inheritDoc}
227 */
228 public String toString() { return name; }
229
230 }
231
232
233
234 // The "debug-category" property definition.
235 private static final EnumPropertyDefinition<DebugCategory> PD_DEBUG_CATEGORY;
236
237
238
239 // The "debug-level" property definition.
240 private static final EnumPropertyDefinition<DebugLevel> PD_DEBUG_LEVEL;
241
242
243
244 // The "debug-scope" property definition.
245 private static final StringPropertyDefinition PD_DEBUG_SCOPE;
246
247
248
249 // The "include-throwable-cause" property definition.
250 private static final BooleanPropertyDefinition PD_INCLUDE_THROWABLE_CAUSE;
251
252
253
254 // The "omit-method-entry-arguments" property definition.
255 private static final BooleanPropertyDefinition PD_OMIT_METHOD_ENTRY_ARGUMENTS;
256
257
258
259 // The "omit-method-return-value" property definition.
260 private static final BooleanPropertyDefinition PD_OMIT_METHOD_RETURN_VALUE;
261
262
263
264 // The "throwable-stack-frames" property definition.
265 private static final IntegerPropertyDefinition PD_THROWABLE_STACK_FRAMES;
266
267
268
269 // Build the "debug-category" property definition.
270 static {
271 EnumPropertyDefinition.Builder<DebugCategory> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "debug-category");
272 builder.setOption(PropertyOption.MULTI_VALUED);
273 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "debug-category"));
274 builder.setDefaultBehaviorProvider(new AliasDefaultBehaviorProvider<DebugCategory>(INSTANCE, "debug-category"));
275 builder.setEnumClass(DebugCategory.class);
276 PD_DEBUG_CATEGORY = builder.getInstance();
277 INSTANCE.registerPropertyDefinition(PD_DEBUG_CATEGORY);
278 }
279
280
281
282 // Build the "debug-level" property definition.
283 static {
284 EnumPropertyDefinition.Builder<DebugLevel> builder = EnumPropertyDefinition.createBuilder(INSTANCE, "debug-level");
285 builder.setOption(PropertyOption.MANDATORY);
286 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "debug-level"));
287 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<DebugLevel>());
288 builder.setEnumClass(DebugLevel.class);
289 PD_DEBUG_LEVEL = builder.getInstance();
290 INSTANCE.registerPropertyDefinition(PD_DEBUG_LEVEL);
291 }
292
293
294
295 // Build the "debug-scope" property definition.
296 static {
297 StringPropertyDefinition.Builder builder = StringPropertyDefinition.createBuilder(INSTANCE, "debug-scope");
298 builder.setOption(PropertyOption.READ_ONLY);
299 builder.setOption(PropertyOption.MANDATORY);
300 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "debug-scope"));
301 builder.setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
302 builder.setPattern("^([A-Za-z][A-Za-z0-9_]*\\.)*[A-Za-z][A-Za-z0-9_]*(#[A-Za-z][A-Za-z0-9_]*)?$", "STRING");
303 PD_DEBUG_SCOPE = builder.getInstance();
304 INSTANCE.registerPropertyDefinition(PD_DEBUG_SCOPE);
305 }
306
307
308
309 // Build the "include-throwable-cause" property definition.
310 static {
311 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "include-throwable-cause");
312 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "include-throwable-cause"));
313 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
314 builder.setDefaultBehaviorProvider(provider);
315 PD_INCLUDE_THROWABLE_CAUSE = builder.getInstance();
316 INSTANCE.registerPropertyDefinition(PD_INCLUDE_THROWABLE_CAUSE);
317 }
318
319
320
321 // Build the "omit-method-entry-arguments" property definition.
322 static {
323 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "omit-method-entry-arguments");
324 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "omit-method-entry-arguments"));
325 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
326 builder.setDefaultBehaviorProvider(provider);
327 PD_OMIT_METHOD_ENTRY_ARGUMENTS = builder.getInstance();
328 INSTANCE.registerPropertyDefinition(PD_OMIT_METHOD_ENTRY_ARGUMENTS);
329 }
330
331
332
333 // Build the "omit-method-return-value" property definition.
334 static {
335 BooleanPropertyDefinition.Builder builder = BooleanPropertyDefinition.createBuilder(INSTANCE, "omit-method-return-value");
336 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "omit-method-return-value"));
337 DefaultBehaviorProvider<Boolean> provider = new DefinedDefaultBehaviorProvider<Boolean>("false");
338 builder.setDefaultBehaviorProvider(provider);
339 PD_OMIT_METHOD_RETURN_VALUE = builder.getInstance();
340 INSTANCE.registerPropertyDefinition(PD_OMIT_METHOD_RETURN_VALUE);
341 }
342
343
344
345 // Build the "throwable-stack-frames" property definition.
346 static {
347 IntegerPropertyDefinition.Builder builder = IntegerPropertyDefinition.createBuilder(INSTANCE, "throwable-stack-frames");
348 builder.setAdministratorAction(new AdministratorAction(AdministratorAction.Type.NONE, INSTANCE, "throwable-stack-frames"));
349 DefaultBehaviorProvider<Integer> provider = new DefinedDefaultBehaviorProvider<Integer>("0");
350 builder.setDefaultBehaviorProvider(provider);
351 builder.setLowerLimit(0);
352 PD_THROWABLE_STACK_FRAMES = builder.getInstance();
353 INSTANCE.registerPropertyDefinition(PD_THROWABLE_STACK_FRAMES);
354 }
355
356
357
358 // Register the tags associated with this managed object definition.
359 static {
360 INSTANCE.registerTag(Tag.valueOf("logging"));
361 }
362
363
364
365 /**
366 * Get the Debug Target configuration definition singleton.
367 *
368 * @return Returns the Debug Target configuration definition
369 * singleton.
370 */
371 public static DebugTargetCfgDefn getInstance() {
372 return INSTANCE;
373 }
374
375
376
377 /**
378 * Private constructor.
379 */
380 private DebugTargetCfgDefn() {
381 super("debug-target", TopCfgDefn.getInstance());
382 }
383
384
385
386 /**
387 * {@inheritDoc}
388 */
389 public DebugTargetCfgClient createClientConfiguration(
390 ManagedObject<? extends DebugTargetCfgClient> impl) {
391 return new DebugTargetCfgClientImpl(impl);
392 }
393
394
395
396 /**
397 * {@inheritDoc}
398 */
399 public DebugTargetCfg createServerConfiguration(
400 ServerManagedObject<? extends DebugTargetCfg> impl) {
401 return new DebugTargetCfgServerImpl(impl);
402 }
403
404
405
406 /**
407 * {@inheritDoc}
408 */
409 public Class<DebugTargetCfg> getServerConfigurationClass() {
410 return DebugTargetCfg.class;
411 }
412
413
414
415 /**
416 * Get the "debug-category" property definition.
417 * <p>
418 * Specifies the debug message categories to be logged.
419 *
420 * @return Returns the "debug-category" property definition.
421 */
422 public EnumPropertyDefinition<DebugCategory> getDebugCategoryPropertyDefinition() {
423 return PD_DEBUG_CATEGORY;
424 }
425
426
427
428 /**
429 * Get the "debug-level" property definition.
430 * <p>
431 * Specifies the lowest severity level of debug messages to log.
432 *
433 * @return Returns the "debug-level" property definition.
434 */
435 public EnumPropertyDefinition<DebugLevel> getDebugLevelPropertyDefinition() {
436 return PD_DEBUG_LEVEL;
437 }
438
439
440
441 /**
442 * Get the "debug-scope" property definition.
443 * <p>
444 * Specifies the fully-qualified OpenDS Java package, class, or
445 * method affected by the settings in this target definition. Use the
446 * number character (#) to separate the class name and the method
447 * name (that is, org.opends.server.core.DirectoryServer#startUp).
448 *
449 * @return Returns the "debug-scope" property definition.
450 */
451 public StringPropertyDefinition getDebugScopePropertyDefinition() {
452 return PD_DEBUG_SCOPE;
453 }
454
455
456
457 /**
458 * Get the "include-throwable-cause" property definition.
459 * <p>
460 * Specifies the property to indicate whether to include the cause
461 * of exceptions in exception thrown and caught messages.
462 *
463 * @return Returns the "include-throwable-cause" property definition.
464 */
465 public BooleanPropertyDefinition getIncludeThrowableCausePropertyDefinition() {
466 return PD_INCLUDE_THROWABLE_CAUSE;
467 }
468
469
470
471 /**
472 * Get the "omit-method-entry-arguments" property definition.
473 * <p>
474 * Specifies the property to indicate whether to include method
475 * arguments in debug messages.
476 *
477 * @return Returns the "omit-method-entry-arguments" property definition.
478 */
479 public BooleanPropertyDefinition getOmitMethodEntryArgumentsPropertyDefinition() {
480 return PD_OMIT_METHOD_ENTRY_ARGUMENTS;
481 }
482
483
484
485 /**
486 * Get the "omit-method-return-value" property definition.
487 * <p>
488 * Specifies the property to indicate whether to include the return
489 * value in debug messages.
490 *
491 * @return Returns the "omit-method-return-value" property definition.
492 */
493 public BooleanPropertyDefinition getOmitMethodReturnValuePropertyDefinition() {
494 return PD_OMIT_METHOD_RETURN_VALUE;
495 }
496
497
498
499 /**
500 * Get the "throwable-stack-frames" property definition.
501 * <p>
502 * Specifies the property to indicate the number of stack frames to
503 * include in the stack trace for method entry and exception thrown
504 * messages.
505 *
506 * @return Returns the "throwable-stack-frames" property definition.
507 */
508 public IntegerPropertyDefinition getThrowableStackFramesPropertyDefinition() {
509 return PD_THROWABLE_STACK_FRAMES;
510 }
511
512
513
514 /**
515 * Managed object client implementation.
516 */
517 private static class DebugTargetCfgClientImpl implements
518 DebugTargetCfgClient {
519
520 // Private implementation.
521 private ManagedObject<? extends DebugTargetCfgClient> impl;
522
523
524
525 // Private constructor.
526 private DebugTargetCfgClientImpl(
527 ManagedObject<? extends DebugTargetCfgClient> impl) {
528 this.impl = impl;
529 }
530
531
532
533 /**
534 * {@inheritDoc}
535 */
536 public SortedSet<DebugCategory> getDebugCategory() {
537 return impl.getPropertyValues(INSTANCE.getDebugCategoryPropertyDefinition());
538 }
539
540
541
542 /**
543 * {@inheritDoc}
544 */
545 public void setDebugCategory(Collection<DebugCategory> values) {
546 impl.setPropertyValues(INSTANCE.getDebugCategoryPropertyDefinition(), values);
547 }
548
549
550
551 /**
552 * {@inheritDoc}
553 */
554 public DebugLevel getDebugLevel() {
555 return impl.getPropertyValue(INSTANCE.getDebugLevelPropertyDefinition());
556 }
557
558
559
560 /**
561 * {@inheritDoc}
562 */
563 public void setDebugLevel(DebugLevel value) {
564 impl.setPropertyValue(INSTANCE.getDebugLevelPropertyDefinition(), value);
565 }
566
567
568
569 /**
570 * {@inheritDoc}
571 */
572 public String getDebugScope() {
573 return impl.getPropertyValue(INSTANCE.getDebugScopePropertyDefinition());
574 }
575
576
577
578 /**
579 * {@inheritDoc}
580 */
581 public void setDebugScope(String value) throws PropertyIsReadOnlyException {
582 impl.setPropertyValue(INSTANCE.getDebugScopePropertyDefinition(), value);
583 }
584
585
586
587 /**
588 * {@inheritDoc}
589 */
590 public boolean isIncludeThrowableCause() {
591 return impl.getPropertyValue(INSTANCE.getIncludeThrowableCausePropertyDefinition());
592 }
593
594
595
596 /**
597 * {@inheritDoc}
598 */
599 public void setIncludeThrowableCause(Boolean value) {
600 impl.setPropertyValue(INSTANCE.getIncludeThrowableCausePropertyDefinition(), value);
601 }
602
603
604
605 /**
606 * {@inheritDoc}
607 */
608 public boolean isOmitMethodEntryArguments() {
609 return impl.getPropertyValue(INSTANCE.getOmitMethodEntryArgumentsPropertyDefinition());
610 }
611
612
613
614 /**
615 * {@inheritDoc}
616 */
617 public void setOmitMethodEntryArguments(Boolean value) {
618 impl.setPropertyValue(INSTANCE.getOmitMethodEntryArgumentsPropertyDefinition(), value);
619 }
620
621
622
623 /**
624 * {@inheritDoc}
625 */
626 public boolean isOmitMethodReturnValue() {
627 return impl.getPropertyValue(INSTANCE.getOmitMethodReturnValuePropertyDefinition());
628 }
629
630
631
632 /**
633 * {@inheritDoc}
634 */
635 public void setOmitMethodReturnValue(Boolean value) {
636 impl.setPropertyValue(INSTANCE.getOmitMethodReturnValuePropertyDefinition(), value);
637 }
638
639
640
641 /**
642 * {@inheritDoc}
643 */
644 public int getThrowableStackFrames() {
645 return impl.getPropertyValue(INSTANCE.getThrowableStackFramesPropertyDefinition());
646 }
647
648
649
650 /**
651 * {@inheritDoc}
652 */
653 public void setThrowableStackFrames(Integer value) {
654 impl.setPropertyValue(INSTANCE.getThrowableStackFramesPropertyDefinition(), value);
655 }
656
657
658
659 /**
660 * {@inheritDoc}
661 */
662 public ManagedObjectDefinition<? extends DebugTargetCfgClient, ? extends DebugTargetCfg> definition() {
663 return INSTANCE;
664 }
665
666
667
668 /**
669 * {@inheritDoc}
670 */
671 public PropertyProvider properties() {
672 return impl;
673 }
674
675
676
677 /**
678 * {@inheritDoc}
679 */
680 public void commit() throws ManagedObjectAlreadyExistsException,
681 MissingMandatoryPropertiesException, ConcurrentModificationException,
682 OperationRejectedException, AuthorizationException,
683 CommunicationException {
684 impl.commit();
685 }
686
687 }
688
689
690
691 /**
692 * Managed object server implementation.
693 */
694 private static class DebugTargetCfgServerImpl implements
695 DebugTargetCfg {
696
697 // Private implementation.
698 private ServerManagedObject<? extends DebugTargetCfg> impl;
699
700 // The value of the "debug-category" property.
701 private final SortedSet<DebugCategory> pDebugCategory;
702
703 // The value of the "debug-level" property.
704 private final DebugLevel pDebugLevel;
705
706 // The value of the "debug-scope" property.
707 private final String pDebugScope;
708
709 // The value of the "include-throwable-cause" property.
710 private final boolean pIncludeThrowableCause;
711
712 // The value of the "omit-method-entry-arguments" property.
713 private final boolean pOmitMethodEntryArguments;
714
715 // The value of the "omit-method-return-value" property.
716 private final boolean pOmitMethodReturnValue;
717
718 // The value of the "throwable-stack-frames" property.
719 private final int pThrowableStackFrames;
720
721
722
723 // Private constructor.
724 private DebugTargetCfgServerImpl(ServerManagedObject<? extends DebugTargetCfg> impl) {
725 this.impl = impl;
726 this.pDebugCategory = impl.getPropertyValues(INSTANCE.getDebugCategoryPropertyDefinition());
727 this.pDebugLevel = impl.getPropertyValue(INSTANCE.getDebugLevelPropertyDefinition());
728 this.pDebugScope = impl.getPropertyValue(INSTANCE.getDebugScopePropertyDefinition());
729 this.pIncludeThrowableCause = impl.getPropertyValue(INSTANCE.getIncludeThrowableCausePropertyDefinition());
730 this.pOmitMethodEntryArguments = impl.getPropertyValue(INSTANCE.getOmitMethodEntryArgumentsPropertyDefinition());
731 this.pOmitMethodReturnValue = impl.getPropertyValue(INSTANCE.getOmitMethodReturnValuePropertyDefinition());
732 this.pThrowableStackFrames = impl.getPropertyValue(INSTANCE.getThrowableStackFramesPropertyDefinition());
733 }
734
735
736
737 /**
738 * {@inheritDoc}
739 */
740 public void addChangeListener(
741 ConfigurationChangeListener<DebugTargetCfg> listener) {
742 impl.registerChangeListener(listener);
743 }
744
745
746
747 /**
748 * {@inheritDoc}
749 */
750 public void removeChangeListener(
751 ConfigurationChangeListener<DebugTargetCfg> listener) {
752 impl.deregisterChangeListener(listener);
753 }
754
755
756
757 /**
758 * {@inheritDoc}
759 */
760 public SortedSet<DebugCategory> getDebugCategory() {
761 return pDebugCategory;
762 }
763
764
765
766 /**
767 * {@inheritDoc}
768 */
769 public DebugLevel getDebugLevel() {
770 return pDebugLevel;
771 }
772
773
774
775 /**
776 * {@inheritDoc}
777 */
778 public String getDebugScope() {
779 return pDebugScope;
780 }
781
782
783
784 /**
785 * {@inheritDoc}
786 */
787 public boolean isIncludeThrowableCause() {
788 return pIncludeThrowableCause;
789 }
790
791
792
793 /**
794 * {@inheritDoc}
795 */
796 public boolean isOmitMethodEntryArguments() {
797 return pOmitMethodEntryArguments;
798 }
799
800
801
802 /**
803 * {@inheritDoc}
804 */
805 public boolean isOmitMethodReturnValue() {
806 return pOmitMethodReturnValue;
807 }
808
809
810
811 /**
812 * {@inheritDoc}
813 */
814 public int getThrowableStackFrames() {
815 return pThrowableStackFrames;
816 }
817
818
819
820 /**
821 * {@inheritDoc}
822 */
823 public Class<? extends DebugTargetCfg> configurationClass() {
824 return DebugTargetCfg.class;
825 }
826
827
828
829 /**
830 * {@inheritDoc}
831 */
832 public DN dn() {
833 return impl.getDN();
834 }
835
836 }
837 }