diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 6a1e2d23fb..6c6d4f5176 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.StringWriter; import java.time.Duration; +import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -58,7 +60,12 @@ import org.springframework.boot.configurationprocessor.metadata.ItemMetadata; * @since 1.2.0 */ @SupportedAnnotationTypes({ ConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.CONTROLLER_ENDPOINT_ANNOTATION, ConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.JMX_ENDPOINT_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.REST_CONTROLLER_ENDPOINT_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.SERVLET_ENDPOINT_ANNOTATION, + ConfigurationMetadataAnnotationProcessor.WEB_ENDPOINT_ANNOTATION, "org.springframework.context.annotation.Configuration" }) public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor { @@ -74,8 +81,18 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor static final String DEFAULT_VALUE_ANNOTATION = "org.springframework.boot.context.properties.bind.DefaultValue"; + static final String CONTROLLER_ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint"; + static final String ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.annotation.Endpoint"; + static final String JMX_ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpoint"; + + static final String REST_CONTROLLER_ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint"; + + static final String SERVLET_ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint"; + + static final String WEB_ENDPOINT_ANNOTATION = "org.springframework.boot.actuate.endpoint.web.annotation.WebEndpoint"; + static final String READ_OPERATION_ANNOTATION = "org.springframework.boot.actuate.endpoint.annotation.ReadOperation"; static final String NAME_ANNOTATION = "org.springframework.boot.context.properties.bind.Name"; @@ -109,8 +126,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor return DEFAULT_VALUE_ANNOTATION; } - protected String endpointAnnotation() { - return ENDPOINT_ANNOTATION; + protected Set endpointAnnotations() { + return new HashSet<>(Arrays.asList(CONTROLLER_ENDPOINT_ANNOTATION, ENDPOINT_ANNOTATION, JMX_ENDPOINT_ANNOTATION, + REST_CONTROLLER_ENDPOINT_ANNOTATION, SERVLET_ENDPOINT_ANNOTATION, WEB_ENDPOINT_ANNOTATION)); } protected String readOperationAnnotation() { @@ -138,7 +156,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor this.metadataCollector = new MetadataCollector(env, this.metadataStore.readMetadata()); this.metadataEnv = new MetadataGenerationEnvironment(env, configurationPropertiesAnnotation(), nestedConfigurationPropertyAnnotation(), deprecatedConfigurationPropertyAnnotation(), - constructorBindingAnnotation(), defaultValueAnnotation(), endpointAnnotation(), + constructorBindingAnnotation(), defaultValueAnnotation(), endpointAnnotations(), readOperationAnnotation(), nameAnnotation()); } @@ -151,9 +169,11 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor processElement(element); } } - TypeElement endpointType = this.metadataEnv.getEndpointAnnotationElement(); - if (endpointType != null) { // Is @Endpoint available - getElementsAnnotatedOrMetaAnnotatedWith(roundEnv, endpointType).forEach(this::processEndpoint); + Set endpointTypes = this.metadataEnv.getEndpointAnnotationElements(); + if (!endpointTypes.isEmpty()) { // Are endpoint annotations available + for (TypeElement endpointType : endpointTypes) { + getElementsAnnotatedOrMetaAnnotatedWith(roundEnv, endpointType).forEach(this::processEndpoint); + } } if (roundEnv.processingOver()) { try { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java index 6d127561a5..4e5ad965c5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.processing.Messager; import javax.annotation.processing.ProcessingEnvironment; @@ -91,7 +93,7 @@ class MetadataGenerationEnvironment { private final String defaultValueAnnotation; - private final String endpointAnnotation; + private final Set endpointAnnotations; private final String readOperationAnnotation; @@ -99,7 +101,7 @@ class MetadataGenerationEnvironment { MetadataGenerationEnvironment(ProcessingEnvironment environment, String configurationPropertiesAnnotation, String nestedConfigurationPropertyAnnotation, String deprecatedConfigurationPropertyAnnotation, - String constructorBindingAnnotation, String defaultValueAnnotation, String endpointAnnotation, + String constructorBindingAnnotation, String defaultValueAnnotation, Set endpointAnnotations, String readOperationAnnotation, String nameAnnotation) { this.typeUtils = new TypeUtils(environment); this.elements = environment.getElementUtils(); @@ -110,7 +112,7 @@ class MetadataGenerationEnvironment { this.deprecatedConfigurationPropertyAnnotation = deprecatedConfigurationPropertyAnnotation; this.constructorBindingAnnotation = constructorBindingAnnotation; this.defaultValueAnnotation = defaultValueAnnotation; - this.endpointAnnotation = endpointAnnotation; + this.endpointAnnotations = endpointAnnotations; this.readOperationAnnotation = readOperationAnnotation; this.nameAnnotation = nameAnnotation; } @@ -270,8 +272,9 @@ class MetadataGenerationEnvironment { return getAnnotation(element, this.defaultValueAnnotation); } - TypeElement getEndpointAnnotationElement() { - return this.elements.getTypeElement(this.endpointAnnotation); + Set getEndpointAnnotationElements() { + return this.endpointAnnotations.stream().map(this.elements::getTypeElement).filter(Objects::nonNull) + .collect(Collectors.toSet()); } AnnotationMirror getReadOperationAnnotation(Element element) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java index 4904a1c7fa..3143a3c7c3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,13 +74,18 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene assertThat(new ConfigurationMetadataAnnotationProcessor().getSupportedAnnotationTypes()) .containsExactlyInAnyOrder("org.springframework.boot.context.properties.ConfigurationProperties", "org.springframework.context.annotation.Configuration", - "org.springframework.boot.actuate.endpoint.annotation.Endpoint"); + "org.springframework.boot.actuate.endpoint.annotation.Endpoint", + "org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpoint", + "org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpoint", + "org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint", + "org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpoint", + "org.springframework.boot.actuate.endpoint.web.annotation.WebEndpoint"); } @Test void notAnnotated() { ConfigurationMetadata metadata = compile(NotAnnotated.class); - assertThat(metadata.getItems()).isEmpty(); + assertThat(metadata).isNull(); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/IncrementalBuildMetadataGenerationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/IncrementalBuildMetadataGenerationTests.java index 4fe9d67833..e5333b7d69 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/IncrementalBuildMetadataGenerationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/IncrementalBuildMetadataGenerationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,8 +69,7 @@ class IncrementalBuildMetadataGenerationTests extends AbstractMetadataGeneration assertThat(metadata).has(Metadata.withProperty("bar.counter").withDefaultValue(0)); project.replaceText(BarProperties.class, "@ConfigurationProperties", "//@ConfigurationProperties"); metadata = project.incrementalBuild(BarProperties.class); - assertThat(metadata).has(Metadata.withProperty("foo.counter").withDefaultValue(0)); - assertThat(metadata).isNotEqualTo(Metadata.withProperty("bar.counter")); + assertThat(metadata).isNull(); } @Test diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironmentFactory.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironmentFactory.java index 0b67c60a03..6fbd0e42a2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironmentFactory.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/MetadataGenerationEnvironmentFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package org.springframework.boot.configurationprocessor; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.function.Function; import javax.annotation.processing.ProcessingEnvironment; @@ -31,13 +34,18 @@ class MetadataGenerationEnvironmentFactory implements Function endpointAnnotations = new HashSet<>( + Arrays.asList(TestConfigurationMetadataAnnotationProcessor.CONTROLLER_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.REST_CONTROLLER_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.SERVLET_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.WEB_ENDPOINT_ANNOTATION)); return new MetadataGenerationEnvironment(environment, TestConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_ANNOTATION, TestConfigurationMetadataAnnotationProcessor.NESTED_CONFIGURATION_PROPERTY_ANNOTATION, TestConfigurationMetadataAnnotationProcessor.DEPRECATED_CONFIGURATION_PROPERTY_ANNOTATION, TestConfigurationMetadataAnnotationProcessor.CONSTRUCTOR_BINDING_ANNOTATION, - TestConfigurationMetadataAnnotationProcessor.DEFAULT_VALUE_ANNOTATION, - TestConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.DEFAULT_VALUE_ANNOTATION, endpointAnnotations, TestConfigurationMetadataAnnotationProcessor.READ_OPERATION_ANNOTATION, TestConfigurationMetadataAnnotationProcessor.NAME_ANNOTATION); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java index 149a746c0e..592a5a5f45 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/test/TestConfigurationMetadataAnnotationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import javax.annotation.processing.SupportedAnnotationTypes; import javax.annotation.processing.SupportedSourceVersion; @@ -37,7 +40,14 @@ import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller; * @author Andy Wilkinson * @author Kris De Volder */ -@SupportedAnnotationTypes({ "*" }) +@SupportedAnnotationTypes({ TestConfigurationMetadataAnnotationProcessor.CONFIGURATION_PROPERTIES_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.CONTROLLER_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.JMX_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.REST_CONTROLLER_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.SERVLET_ENDPOINT_ANNOTATION, + TestConfigurationMetadataAnnotationProcessor.WEB_ENDPOINT_ANNOTATION, + "org.springframework.context.annotation.Configuration" }) @SupportedSourceVersion(SourceVersion.RELEASE_6) public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationMetadataAnnotationProcessor { @@ -51,8 +61,18 @@ public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationM public static final String DEFAULT_VALUE_ANNOTATION = "org.springframework.boot.configurationsample.DefaultValue"; + public static final String CONTROLLER_ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.ControllerEndpoint"; + public static final String ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.Endpoint"; + public static final String JMX_ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.JmxEndpoint"; + + public static final String REST_CONTROLLER_ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.RestControllerEndpoint"; + + public static final String SERVLET_ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.ServletEndpoint"; + + public static final String WEB_ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.WebEndpoint"; + public static final String READ_OPERATION_ANNOTATION = "org.springframework.boot.configurationsample.ReadOperation"; public static final String NAME_ANNOTATION = "org.springframework.boot.configurationsample.Name"; @@ -91,8 +111,9 @@ public class TestConfigurationMetadataAnnotationProcessor extends ConfigurationM } @Override - protected String endpointAnnotation() { - return ENDPOINT_ANNOTATION; + protected Set endpointAnnotations() { + return new HashSet<>(Arrays.asList(CONTROLLER_ENDPOINT_ANNOTATION, ENDPOINT_ANNOTATION, JMX_ENDPOINT_ANNOTATION, + REST_CONTROLLER_ENDPOINT_ANNOTATION, SERVLET_ENDPOINT_ANNOTATION, WEB_ENDPOINT_ANNOTATION)); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ControllerEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ControllerEndpoint.java new file mode 100644 index 0000000000..5f055fbe02 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ControllerEndpoint.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Alternative to Spring Boot's {@code @ControllerEndpoint} for testing (removes the need + * for a dependency on the real annotation). + * + * @author Andy Wilkinson + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ControllerEndpoint { + + String id() default ""; + + boolean enableByDefault() default true; + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/MetaEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/JmxEndpoint.java similarity index 77% rename from spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/MetaEndpoint.java rename to spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/JmxEndpoint.java index c2d2fea316..a1e62e6321 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/MetaEndpoint.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/JmxEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,18 +22,19 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.springframework.core.annotation.AliasFor; - +/** + * Alternative to Spring Boot's {@code @JmxEndpoint} for testing (removes the need for a + * dependency on the real annotation). + * + * @author Andy Wilkinson + */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented -@Endpoint -public @interface MetaEndpoint { +public @interface JmxEndpoint { - @AliasFor(annotation = Endpoint.class) - String id(); + String id() default ""; - @AliasFor(annotation = Endpoint.class) boolean enableByDefault() default true; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/RestControllerEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/RestControllerEndpoint.java new file mode 100644 index 0000000000..283b90e567 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/RestControllerEndpoint.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Alternative to Spring Boot's {@code @RestControllerEndpoint} for testing (removes the + * need for a dependency on the real annotation). + * + * @author Andy Wilkinson + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RestControllerEndpoint { + + String id() default ""; + + boolean enableByDefault() default true; + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ServletEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ServletEndpoint.java new file mode 100644 index 0000000000..fecf8b08a3 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/ServletEndpoint.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Alternative to Spring Boot's {@code @ServletEndpoint} for testing (removes the need for + * a dependency on the real annotation). + * + * @author Andy Wilkinson + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ServletEndpoint { + + String id() default ""; + + boolean enableByDefault() default true; + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/WebEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/WebEndpoint.java new file mode 100644 index 0000000000..48b3ee4091 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/WebEndpoint.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.configurationsample; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Alternative to Spring Boot's {@code @WebEndpoint} for testing (removes the need for a + * dependency on the real annotation). + * + * @author Andy Wilkinson + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface WebEndpoint { + + String id() default ""; + + boolean enableByDefault() default true; + +} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SpecificEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SpecificEndpoint.java index d5a3cb3838..49a003a71a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SpecificEndpoint.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SpecificEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,17 +16,17 @@ package org.springframework.boot.configurationsample.endpoint; -import org.springframework.boot.configurationsample.MetaEndpoint; import org.springframework.boot.configurationsample.ReadOperation; +import org.springframework.boot.configurationsample.WebEndpoint; import org.springframework.lang.Nullable; /** - * A meta-annotated endpoint similar to {@code @WebEndpoint} or {@code @JmxEndpoint} in - * Spring Boot. Also with a package private read operation that has an optional argument. + * A meta-annotated endpoint. Also with a package private read operation that has an + * optional argument. * * @author Stephane Nicoll */ -@MetaEndpoint(id = "specific", enableByDefault = true) +@WebEndpoint(id = "specific", enableByDefault = true) public class SpecificEndpoint { @ReadOperation diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/incremental/IncrementalSpecificEndpoint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/incremental/IncrementalSpecificEndpoint.java index 5c6d25cc15..4f682d4b8c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/incremental/IncrementalSpecificEndpoint.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/incremental/IncrementalSpecificEndpoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,15 @@ package org.springframework.boot.configurationsample.endpoint.incremental; -import org.springframework.boot.configurationsample.MetaEndpoint; +import org.springframework.boot.configurationsample.JmxEndpoint; /** - * A meta-annotated endpoint similar to {@code @WebEndpoint} or {@code @JmxEndpoint} in - * Spring Boot. + * A meta-annotated endpoint. * * @author Stephane Nicoll + * @author Andy Wilkinson */ -@MetaEndpoint(id = "incremental") +@JmxEndpoint(id = "incremental") public class IncrementalSpecificEndpoint { }