Provide @ConditionalOn… annotations for all concrete conditions
Closes gh-41044
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012-2025 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.devtools.autoconfigure;
|
||||
|
||||
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;
|
||||
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
/**
|
||||
* {@link Conditional @Conditional} that matches when DevTools is enabled.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Documented
|
||||
@Conditional(OnEnabledDevToolsCondition.class)
|
||||
public @interface ConditionalOnEnabledDevTools {
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -58,7 +58,8 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
* @since 1.3.3
|
||||
*/
|
||||
@ConditionalOnClass(DataSource.class)
|
||||
@Conditional({ OnEnabledDevToolsCondition.class, DevToolsDataSourceCondition.class })
|
||||
@ConditionalOnEnabledDevTools
|
||||
@Conditional(DevToolsDataSourceCondition.class)
|
||||
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
|
||||
@Import(DatabaseShutdownExecutorEntityManagerFactoryDependsOnPostProcessor.class)
|
||||
public class DevToolsDataSourceAutoConfiguration {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -49,7 +49,8 @@ import org.springframework.core.type.MethodMetadata;
|
||||
* @since 2.5.6
|
||||
*/
|
||||
@ConditionalOnClass(ConnectionFactory.class)
|
||||
@Conditional({ OnEnabledDevToolsCondition.class, DevToolsConnectionFactoryCondition.class })
|
||||
@ConditionalOnEnabledDevTools
|
||||
@Conditional(DevToolsConnectionFactoryCondition.class)
|
||||
@AutoConfiguration(after = R2dbcAutoConfiguration.class)
|
||||
public class DevToolsR2dbcAutoConfiguration {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -28,7 +28,10 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @since 2.2.0
|
||||
* @deprecated since 3.5.0 for removal in 3.7.0 in favor of
|
||||
* {@link ConditionalOnEnabledDevTools @ConditionalOnEnabledDevTools}
|
||||
*/
|
||||
@Deprecated(since = "3.5.0", forRemoval = true)
|
||||
public class OnEnabledDevToolsCondition extends SpringBootCondition {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.springframework.boot.devtools.restart.server.HttpRestartServer;
|
||||
import org.springframework.boot.devtools.restart.server.HttpRestartServerHandler;
|
||||
import org.springframework.boot.devtools.restart.server.SourceDirectoryUrlFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.log.LogMessage;
|
||||
@@ -61,7 +60,7 @@ import org.springframework.http.server.ServerHttpRequest;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@AutoConfiguration(after = SecurityAutoConfiguration.class)
|
||||
@Conditional(OnEnabledDevToolsCondition.class)
|
||||
@ConditionalOnEnabledDevTools
|
||||
@ConditionalOnProperty("spring.devtools.remote.secret")
|
||||
@ConditionalOnClass({ Filter.class, ServerHttpRequest.class })
|
||||
@Import(RemoteDevtoolsSecurityConfiguration.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2025 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.
|
||||
@@ -65,6 +65,7 @@ class OnEnabledDevToolsConditionTests {
|
||||
static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings("removal")
|
||||
@Conditional(OnEnabledDevToolsCondition.class)
|
||||
String test() {
|
||||
return "hello";
|
||||
|
||||
Reference in New Issue
Block a user