diff --git a/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/processor/Annotations.java b/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/processor/Annotations.java index cae6559..d51e6b2 100644 --- a/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/processor/Annotations.java +++ b/log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/processor/Annotations.java @@ -53,8 +53,10 @@ final class Annotations { private static final Collection PLUGIN_ATTRIBUTE_ANNOTATION_NAMES = Arrays.asList( "org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute", "org.apache.logging.log4j.core.config.plugins.PluginAttribute", + "org.apache.logging.log4j.core.config.plugins.PluginValue", "org.apache.logging.log4j.plugins.PluginAttribute", - "org.apache.logging.log4j.plugins.PluginBuilderAttribute"); + "org.apache.logging.log4j.plugins.PluginBuilderAttribute", + "org.apache.logging.log4j.plugins.PluginValue"); private static final Collection PLUGIN_ELEMENT_ANNOTATION_NAMES = Arrays.asList( "org.apache.logging.log4j.core.config.plugins.PluginElement", "org.apache.logging.log4j.plugins.PluginElement"); diff --git a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/expected-plugins.xml b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/expected-plugins.xml index 39f6806..1289db0 100644 --- a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/expected-plugins.xml +++ b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/expected-plugins.xml @@ -86,6 +86,9 @@ A `String` attribute. + + An attribute that can be also be inserted as content of the XML element. + @@ -154,6 +157,9 @@ It also implements: A `double` attribute. + + An attribute that can be also be inserted as content of the XML element. + An `enum` attribute. diff --git a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyAppender.java b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyAppender.java index 37a47ef..47648ca 100644 --- a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyAppender.java +++ b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyAppender.java @@ -26,6 +26,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.config.plugins.PluginFactory; import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required; +import org.apache.logging.log4j.plugins.PluginValue; /** * Example plugin @@ -115,6 +116,11 @@ public static final class Builder extends ParentBuilder private @PluginBuilderAttribute double undocumentedAttribute; + /** + * An attribute that can be also be inserted as content of the XML element. + */ + private @PluginValue int valueAttribute; + private Object notAnAttribute; /** diff --git a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyOldLayout.java b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyOldLayout.java index 670b7fa..bbc7bba 100644 --- a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyOldLayout.java +++ b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j2/MyOldLayout.java @@ -21,6 +21,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.config.plugins.PluginFactory; import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required; +import org.apache.logging.log4j.plugins.PluginValue; /** * Example plugin without a builder. @@ -42,6 +43,7 @@ public final class MyOldLayout implements Layout { * @param enumAttr An {@code enum} attribute. * @param nestedLayout An element with multiplicity {@code 1}. * @param filters An element with multiplicity {@code n}. + * @param valueAttribute An attribute that can be also be inserted as content of the XML element. */ @PluginFactory public static MyOldLayout newLayout( @@ -57,7 +59,8 @@ public static MyOldLayout newLayout( final @PluginAttribute("otherName") String origName, final @PluginAttribute("enumAttr") MyEnum enumAttr, final @PluginElement("nestedLayout") Layout nestedLayout, - final @PluginElement("filters") Filter[] filters) { + final @PluginElement("filters") Filter[] filters, + final @PluginValue("elementValue") int valueAttribute) { return null; } } diff --git a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyAppender.java b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyAppender.java index 3024620..6c88741 100644 --- a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyAppender.java +++ b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyAppender.java @@ -27,6 +27,7 @@ import org.apache.logging.log4j.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.plugins.PluginElement; import org.apache.logging.log4j.plugins.PluginFactory; +import org.apache.logging.log4j.plugins.PluginValue; import org.apache.logging.log4j.plugins.validation.constraints.Required; /** @@ -118,6 +119,11 @@ public static final class Builder extends ParentBuilder private @PluginBuilderAttribute double undocumentedAttribute; + /** + * An attribute that can be also be inserted as content of the XML element. + */ + private @PluginValue int valueAttribute; + private Object notAnAttribute; /** diff --git a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyOldLayout.java b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyOldLayout.java index 41b08c7..3f33594 100644 --- a/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyOldLayout.java +++ b/log4j-docgen/src/test/resources/DescriptorGeneratorTest/java-of-log4j3/MyOldLayout.java @@ -20,6 +20,7 @@ import org.apache.logging.log4j.plugins.Plugin; import org.apache.logging.log4j.plugins.PluginAttribute; import org.apache.logging.log4j.plugins.PluginElement; +import org.apache.logging.log4j.plugins.PluginValue; import org.apache.logging.log4j.plugins.validation.constraints.Required; /** @@ -42,6 +43,7 @@ public final class MyOldLayout implements Layout { * @param enumAttr An {@code enum} attribute. * @param nestedLayout An element with multiplicity {@code 1}. * @param filters An element with multiplicity {@code n}. + * @param valueAttribute An attribute that can be also be inserted as content of the XML element. */ @Factory public static MyOldLayout newLayout( @@ -57,7 +59,8 @@ public static MyOldLayout newLayout( final @PluginAttribute("otherName") String origName, final @PluginAttribute MyEnum enumAttr, final @PluginElement Layout nestedLayout, - final @PluginElement Filter[] filters) { + final @PluginElement Filter[] filters, + final @PluginValue("elementValue") int valueAttribute) { return null; } } diff --git a/src/changelog/0.9.0/add-plugin-value-annotation.xml b/src/changelog/0.9.0/add-plugin-value-annotation.xml new file mode 100644 index 0000000..3a56de3 --- /dev/null +++ b/src/changelog/0.9.0/add-plugin-value-annotation.xml @@ -0,0 +1,8 @@ + + + + Add support for the `@PluginValue` annotation. +