1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache license, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the license for the specific language governing permissions and 15 * limitations under the license. 16 */ 17 package org.apache.logging.log4j.core.config.plugins; 18 19 import java.lang.annotation.Documented; 20 import java.lang.annotation.ElementType; 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.lang.annotation.Target; 24 25 import org.apache.logging.log4j.core.config.plugins.visitors.PluginAttributeVisitor; 26 import org.apache.logging.log4j.util.Strings; 27 28 /** 29 * Identifies a Plugin Attribute and its default value. Note that only one of the defaultFoo attributes will be 30 * used based on the type this annotation is attached to. Thus, for primitive types, the default<i>Type</i> 31 * attribute will be used for some <i>Type</i>. However, for more complex types (including enums), the default 32 * string value is used instead and should correspond to the string that would correctly convert to the appropriate 33 * enum value using {@link Enum#valueOf(Class, String) Enum.valueOf}. 34 */ 35 @Documented 36 @Retention(RetentionPolicy.RUNTIME) 37 @Target({ElementType.PARAMETER, ElementType.FIELD}) 38 @PluginVisitorStrategy(PluginAttributeVisitor.class) 39 public @interface PluginAttribute { 40 41 /** 42 * Specifies the default boolean value to use. 43 */ 44 boolean defaultBoolean() default false; 45 46 /** 47 * Specifies the default byte value to use. 48 */ 49 byte defaultByte() default 0; 50 51 /** 52 * Specifies the default byte value to use. 53 */ 54 char defaultChar() default 0; 55 56 /** 57 * Specifies the default {@link Class} value to use. 58 */ 59 Class<?> defaultClass() default Object.class; 60 61 /** 62 * Specifies the default double floating point value to use. 63 */ 64 double defaultDouble() default 0.0d; 65 66 /** 67 * Specifies the default floating point value to use. 68 */ 69 float defaultFloat() default 0.0f; 70 71 /** 72 * Specifies the default integer value to use. 73 */ 74 int defaultInt() default 0; 75 76 /** 77 * Specifies the default long value to use. 78 */ 79 long defaultLong() default 0L; 80 81 /** 82 * Specifies the default long value to use. 83 */ 84 short defaultShort() default 0; 85 86 /** 87 * Specifies the default value this attribute should use if none is provided or if the provided value is invalid. 88 */ 89 String defaultString() default Strings.EMPTY; 90 91 // TODO: could we allow a blank value and infer the attribute name through reflection? 92 /** 93 * Specifies the name of the attribute (case-insensitive) this annotation corresponds to. 94 */ 95 String value(); 96 97 /** 98 * Indicates that this attribute is a sensitive one that shouldn't be logged directly. Such attributes will instead 99 * be output as a hashed value. 100 */ 101 boolean sensitive() default false; 102 103 }