Skip to content

Commit 03841b1

Browse files
quaffwilkinsona
authored andcommitted
Use constants for well-known scope names
See gh-43065
1 parent 2fa28fb commit 03841b1

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.typesafe.config.ConfigFactory;
4040

4141
import org.springframework.beans.factory.ObjectProvider;
42+
import org.springframework.beans.factory.config.BeanDefinition;
4243
import org.springframework.boot.autoconfigure.AutoConfiguration;
4344
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
4445
import org.springframework.boot.autoconfigure.cassandra.CassandraProperties.Connection;
@@ -111,7 +112,7 @@ public CqlSession cassandraSession(CqlSessionBuilder cqlSessionBuilder) {
111112

112113
@Bean
113114
@ConditionalOnMissingBean
114-
@Scope("prototype")
115+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
115116
public CqlSessionBuilder cassandraSessionBuilder(DriverConfigLoader driverConfigLoader,
116117
CassandraConnectionDetails connectionDetails,
117118
ObjectProvider<CqlSessionBuilderCustomizer> builderCustomizers, ObjectProvider<SslBundles> sslBundles) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/graphql/rsocket/RSocketGraphQlClientAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import io.rsocket.RSocket;
2121
import io.rsocket.transport.netty.client.TcpClientTransport;
2222

23+
import org.springframework.beans.factory.config.BeanDefinition;
2324
import org.springframework.boot.autoconfigure.AutoConfiguration;
2425
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2526
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -47,7 +48,7 @@
4748
public class RSocketGraphQlClientAutoConfiguration {
4849

4950
@Bean
50-
@Scope("prototype")
51+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
5152
@ConditionalOnMissingBean
5253
public RSocketGraphQlClient.Builder<?> rsocketGraphQlClientBuilder(
5354
RSocketRequester.Builder rsocketRequesterBuilder) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
4444
import org.springframework.aot.hint.RuntimeHintsRegistrar;
4545
import org.springframework.beans.BeanUtils;
4646
import org.springframework.beans.factory.ObjectProvider;
47+
import org.springframework.beans.factory.config.BeanDefinition;
4748
import org.springframework.boot.autoconfigure.AutoConfiguration;
4849
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
4950
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -150,7 +151,7 @@ ParameterNamesModule parameterNamesModule() {
150151
static class JacksonObjectMapperBuilderConfiguration {
151152

152153
@Bean
153-
@Scope("prototype")
154+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
154155
@ConditionalOnMissingBean
155156
Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder(ApplicationContext applicationContext,
156157
List<Jackson2ObjectMapperBuilderCustomizer> customizers) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketRequesterAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import reactor.netty.http.server.HttpServer;
2121

2222
import org.springframework.beans.factory.ObjectProvider;
23+
import org.springframework.beans.factory.config.BeanDefinition;
2324
import org.springframework.boot.autoconfigure.AutoConfiguration;
2425
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2526
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -46,7 +47,7 @@
4647
public class RSocketRequesterAutoConfiguration {
4748

4849
@Bean
49-
@Scope("prototype")
50+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
5051
@ConditionalOnMissingBean
5152
public RSocketRequester.Builder rSocketRequesterBuilder(RSocketStrategies strategies,
5253
ObjectProvider<RSocketConnectorConfigurer> connectorConfigurers) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.autoconfigure.web.client;
1818

1919
import org.springframework.beans.factory.ObjectProvider;
20+
import org.springframework.beans.factory.config.BeanDefinition;
2021
import org.springframework.boot.autoconfigure.AutoConfiguration;
2122
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2223
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -77,7 +78,7 @@ RestClientBuilderConfigurer restClientBuilderConfigurer(ObjectProvider<RestClien
7778
}
7879

7980
@Bean
80-
@Scope("prototype")
81+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
8182
@ConditionalOnMissingBean
8283
RestClient.Builder restClientBuilder(RestClientBuilderConfigurer restClientBuilderConfigurer) {
8384
RestClient.Builder builder = RestClient.builder()

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.autoconfigure.web.reactive.function.client;
1818

1919
import org.springframework.beans.factory.ObjectProvider;
20+
import org.springframework.beans.factory.config.BeanDefinition;
2021
import org.springframework.boot.autoconfigure.AutoConfiguration;
2122
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2223
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -48,7 +49,7 @@
4849
public class WebClientAutoConfiguration {
4950

5051
@Bean
51-
@Scope("prototype")
52+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
5253
@ConditionalOnMissingBean
5354
public WebClient.Builder webClientBuilder(ObjectProvider<WebClientCustomizer> customizerProvider) {
5455
WebClient.Builder builder = WebClient.builder();

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.beans.BeanUtils;
3232
import org.springframework.beans.BeansException;
3333
import org.springframework.beans.factory.FactoryBean;
34+
import org.springframework.beans.factory.config.BeanDefinition;
3435
import org.springframework.beans.factory.config.BeanPostProcessor;
3536
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
3637
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -73,7 +74,7 @@ public static JsonMarshalTestersBeanPostProcessor jsonMarshalTestersBeanPostProc
7374
}
7475

7576
@Bean
76-
@Scope("prototype")
77+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
7778
@ImportRuntimeHints(BasicJsonTesterRuntimeHints.class)
7879
public FactoryBean<BasicJsonTester> basicJsonTesterFactoryBean() {
7980
return new JsonTesterFactoryBean<BasicJsonTester, Void>(BasicJsonTester.class, null);
@@ -84,7 +85,7 @@ public FactoryBean<BasicJsonTester> basicJsonTesterFactoryBean() {
8485
static class JacksonJsonTestersConfiguration {
8586

8687
@Bean
87-
@Scope("prototype")
88+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
8889
@ConditionalOnBean(ObjectMapper.class)
8990
@ImportRuntimeHints(JacksonTesterRuntimeHints.class)
9091
FactoryBean<JacksonTester<?>> jacksonTesterFactoryBean(ObjectMapper mapper) {
@@ -106,7 +107,7 @@ static class JacksonTesterRuntimeHints extends AbstractJsonMarshalTesterRuntimeH
106107
static class GsonJsonTestersConfiguration {
107108

108109
@Bean
109-
@Scope("prototype")
110+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
110111
@ConditionalOnBean(Gson.class)
111112
@ImportRuntimeHints(GsonTesterRuntimeHints.class)
112113
FactoryBean<GsonTester<?>> gsonTesterFactoryBean(Gson gson) {
@@ -128,7 +129,7 @@ static class GsonTesterRuntimeHints extends AbstractJsonMarshalTesterRuntimeHint
128129
static class JsonbJsonTesterConfiguration {
129130

130131
@Bean
131-
@Scope("prototype")
132+
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
132133
@ConditionalOnBean(Jsonb.class)
133134
@ImportRuntimeHints(JsonbJsonTesterRuntimeHints.class)
134135
FactoryBean<JsonbTester<?>> jsonbTesterFactoryBean(Jsonb jsonb) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/AnnotationConfigServletWebServerApplicationContextTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.context.annotation.ScopedProxyMode;
3636
import org.springframework.stereotype.Component;
3737
import org.springframework.web.context.ServletContextAware;
38+
import org.springframework.web.context.WebApplicationContext;
3839
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
3940

4041
import static org.assertj.core.api.Assertions.assertThat;
@@ -154,7 +155,7 @@ public void service(ServletRequest req, ServletResponse res) {
154155
}
155156

156157
@Component
157-
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
158+
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
158159
static class SessionScopedComponent {
159160

160161
}

0 commit comments

Comments
 (0)