Polish "Use constants for well-known scope names"
See gh-43065
This commit is contained in:
parent
03841b1229
commit
5d63335a5c
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -160,7 +160,7 @@ public class BeansEndpoint {
|
||||||
|
|
||||||
private BeanDescriptor(String[] aliases, String scope, Class<?> type, String resource, String[] dependencies) {
|
private BeanDescriptor(String[] aliases, String scope, Class<?> type, String resource, String[] dependencies) {
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
this.scope = (StringUtils.hasText(scope) ? scope : BeanDefinition.SCOPE_SINGLETON);
|
this.scope = (StringUtils.hasText(scope) ? scope : ConfigurableBeanFactory.SCOPE_SINGLETON);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.dependencies = dependencies;
|
this.dependencies = dependencies;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import com.typesafe.config.Config;
|
||||||
import com.typesafe.config.ConfigFactory;
|
import com.typesafe.config.ConfigFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection;
|
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection;
|
||||||
|
|
@ -112,7 +112,7 @@ public class CassandraAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public CqlSessionBuilder cassandraSessionBuilder(DriverConfigLoader driverConfigLoader,
|
public CqlSessionBuilder cassandraSessionBuilder(DriverConfigLoader driverConfigLoader,
|
||||||
CassandraConnectionDetails connectionDetails,
|
CassandraConnectionDetails connectionDetails,
|
||||||
ObjectProvider<CqlSessionBuilderCustomizer> builderCustomizers, ObjectProvider<SslBundles> sslBundles) {
|
ObjectProvider<CqlSessionBuilderCustomizer> builderCustomizers, ObjectProvider<SslBundles> sslBundles) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import graphql.GraphQL;
|
||||||
import io.rsocket.RSocket;
|
import io.rsocket.RSocket;
|
||||||
import io.rsocket.transport.netty.client.TcpClientTransport;
|
import io.rsocket.transport.netty.client.TcpClientTransport;
|
||||||
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
|
@ -48,7 +48,7 @@ import org.springframework.util.MimeTypeUtils;
|
||||||
public class RSocketGraphQlClientAutoConfiguration {
|
public class RSocketGraphQlClientAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public RSocketGraphQlClient.Builder<?> rsocketGraphQlClientBuilder(
|
public RSocketGraphQlClient.Builder<?> rsocketGraphQlClientBuilder(
|
||||||
RSocketRequester.Builder rsocketRequesterBuilder) {
|
RSocketRequester.Builder rsocketRequesterBuilder) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ import org.springframework.aot.hint.RuntimeHints;
|
||||||
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
|
@ -151,7 +151,7 @@ public class JacksonAutoConfiguration {
|
||||||
static class JacksonObjectMapperBuilderConfiguration {
|
static class JacksonObjectMapperBuilderConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder(ApplicationContext applicationContext,
|
Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder(ApplicationContext applicationContext,
|
||||||
List<Jackson2ObjectMapperBuilderCustomizer> customizers) {
|
List<Jackson2ObjectMapperBuilderCustomizer> customizers) {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import io.rsocket.transport.netty.server.TcpServerTransport;
|
||||||
import reactor.netty.http.server.HttpServer;
|
import reactor.netty.http.server.HttpServer;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
|
@ -47,7 +47,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
|
||||||
public class RSocketRequesterAutoConfiguration {
|
public class RSocketRequesterAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public RSocketRequester.Builder rSocketRequesterBuilder(RSocketStrategies strategies,
|
public RSocketRequester.Builder rSocketRequesterBuilder(RSocketStrategies strategies,
|
||||||
ObjectProvider<RSocketConnectorConfigurer> connectorConfigurers) {
|
ObjectProvider<RSocketConnectorConfigurer> connectorConfigurers) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package org.springframework.boot.autoconfigure.web.client;
|
package org.springframework.boot.autoconfigure.web.client;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
|
@ -78,7 +78,7 @@ public class RestClientAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
RestClient.Builder restClientBuilder(RestClientBuilderConfigurer restClientBuilderConfigurer) {
|
RestClient.Builder restClientBuilder(RestClientBuilderConfigurer restClientBuilderConfigurer) {
|
||||||
RestClient.Builder builder = RestClient.builder()
|
RestClient.Builder builder = RestClient.builder()
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package org.springframework.boot.autoconfigure.web.reactive.function.client;
|
package org.springframework.boot.autoconfigure.web.reactive.function.client;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
|
@ -49,7 +49,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||||
public class WebClientAutoConfiguration {
|
public class WebClientAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public WebClient.Builder webClientBuilder(ObjectProvider<WebClientCustomizer> customizerProvider) {
|
public WebClient.Builder webClientBuilder(ObjectProvider<WebClientCustomizer> customizerProvider) {
|
||||||
WebClient.Builder builder = WebClient.builder();
|
WebClient.Builder builder = WebClient.builder();
|
||||||
|
|
|
||||||
|
|
@ -407,7 +407,7 @@ The following example uses HtmlUnit:
|
||||||
include::code:MyHtmlUnitTests[]
|
include::code:MyHtmlUnitTests[]
|
||||||
|
|
||||||
NOTE: By default, Spring Boot puts `WebDriver` beans in a special "`scope`" to ensure that the driver exits after each test and that a new instance is injected.
|
NOTE: By default, Spring Boot puts `WebDriver` beans in a special "`scope`" to ensure that the driver exits after each test and that a new instance is injected.
|
||||||
If you do not want this behavior, you can add `@Scope("singleton")` to your `WebDriver` `@Bean` definition.
|
If you do not want this behavior, you can add `@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)` to your `WebDriver` `@Bean` definition.
|
||||||
|
|
||||||
WARNING: The `webDriver` scope created by Spring Boot will replace any user defined scope of the same name.
|
WARNING: The `webDriver` scope created by Spring Boot will replace any user defined scope of the same name.
|
||||||
If you define your own `webDriver` scope you may find it stops working when you use `@WebMvcTest`.
|
If you define your own `webDriver` scope you may find it stops working when you use `@WebMvcTest`.
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
|
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
|
@ -74,7 +74,7 @@ public class JsonTestersAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ImportRuntimeHints(BasicJsonTesterRuntimeHints.class)
|
@ImportRuntimeHints(BasicJsonTesterRuntimeHints.class)
|
||||||
public FactoryBean<BasicJsonTester> basicJsonTesterFactoryBean() {
|
public FactoryBean<BasicJsonTester> basicJsonTesterFactoryBean() {
|
||||||
return new JsonTesterFactoryBean<BasicJsonTester, Void>(BasicJsonTester.class, null);
|
return new JsonTesterFactoryBean<BasicJsonTester, Void>(BasicJsonTester.class, null);
|
||||||
|
|
@ -85,7 +85,7 @@ public class JsonTestersAutoConfiguration {
|
||||||
static class JacksonJsonTestersConfiguration {
|
static class JacksonJsonTestersConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnBean(ObjectMapper.class)
|
@ConditionalOnBean(ObjectMapper.class)
|
||||||
@ImportRuntimeHints(JacksonTesterRuntimeHints.class)
|
@ImportRuntimeHints(JacksonTesterRuntimeHints.class)
|
||||||
FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(ObjectMapper mapper) {
|
FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(ObjectMapper mapper) {
|
||||||
|
|
@ -107,7 +107,7 @@ public class JsonTestersAutoConfiguration {
|
||||||
static class GsonJsonTestersConfiguration {
|
static class GsonJsonTestersConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnBean(Gson.class)
|
@ConditionalOnBean(Gson.class)
|
||||||
@ImportRuntimeHints(GsonTesterRuntimeHints.class)
|
@ImportRuntimeHints(GsonTesterRuntimeHints.class)
|
||||||
FactoryBean<GsonTester<?>> gsonTesterFactoryBean(Gson gson) {
|
FactoryBean<GsonTester<?>> gsonTesterFactoryBean(Gson gson) {
|
||||||
|
|
@ -129,7 +129,7 @@ public class JsonTestersAutoConfiguration {
|
||||||
static class JsonbJsonTesterConfiguration {
|
static class JsonbJsonTesterConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConditionalOnBean(Jsonb.class)
|
@ConditionalOnBean(Jsonb.class)
|
||||||
@ImportRuntimeHints(JsonbJsonTesterRuntimeHints.class)
|
@ImportRuntimeHints(JsonbJsonTesterRuntimeHints.class)
|
||||||
FactoryBean<JsonbTester<?>> jsonbTesterFactoryBean(Jsonb jsonb) {
|
FactoryBean<JsonbTester<?>> jsonbTesterFactoryBean(Jsonb jsonb) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -24,6 +24,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -63,7 +64,7 @@ class WebMvcTestWebDriverCustomScopeIntegrationTests {
|
||||||
static class Config {
|
static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope("singleton")
|
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
|
||||||
WebDriverFactory webDriver(MockMvc mockMvc) {
|
WebDriverFactory webDriver(MockMvc mockMvc) {
|
||||||
return new WebDriverFactory(mockMvc);
|
return new WebDriverFactory(mockMvc);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||||
|
|
@ -1497,7 +1498,7 @@ class ConfigurationPropertiesTests {
|
||||||
static class PrototypePropertiesConfiguration {
|
static class PrototypePropertiesConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Scope("prototype")
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
@ConfigurationProperties("example")
|
@ConfigurationProperties("example")
|
||||||
PrototypeBean prototypeBean() {
|
PrototypeBean prototypeBean() {
|
||||||
return new PrototypeBean();
|
return new PrototypeBean();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2022 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue