Skip to content

Commit d368e9c

Browse files
committed
Merge pull request #15775 from Johnny Lim
* gh-15775: Polish "Use class for @ConditionalOnClass" Use class for @ConditionalOnClass Closes gh-15775
2 parents 5ae7aef + ab8fcf0 commit d368e9c

File tree

7 files changed

+16
-14
lines changed

7 files changed

+16
-14
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchConfigurerConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -54,7 +54,7 @@ public BasicBatchConfigurer batchConfigurer(BatchProperties properties,
5454
}
5555

5656
@Configuration
57-
@ConditionalOnClass(name = "javax.persistence.EntityManagerFactory")
57+
@ConditionalOnClass(EntityManagerFactory.class)
5858
@ConditionalOnBean(name = "entityManagerFactory")
5959
static class JpaBatchConfiguration {
6060

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceJmxConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -75,7 +75,7 @@ public void validateMBeans() {
7575

7676
@Configuration
7777
@ConditionalOnProperty(prefix = "spring.datasource", name = "jmx-enabled")
78-
@ConditionalOnClass(name = "org.apache.tomcat.jdbc.pool.DataSourceProxy")
78+
@ConditionalOnClass(DataSourceProxy.class)
7979
@ConditionalOnSingleCandidate(DataSource.class)
8080
static class TomcatDataSourceJmxConfiguration {
8181

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -34,6 +34,7 @@
3434
import org.apache.commons.logging.LogFactory;
3535
import org.glassfish.jersey.jackson.JacksonFeature;
3636
import org.glassfish.jersey.server.ResourceConfig;
37+
import org.glassfish.jersey.server.spring.SpringComponentProvider;
3738
import org.glassfish.jersey.servlet.ServletContainer;
3839
import org.glassfish.jersey.servlet.ServletProperties;
3940

@@ -76,8 +77,7 @@
7677
* @author Stephane Nicoll
7778
*/
7879
@Configuration
79-
@ConditionalOnClass(name = { "org.glassfish.jersey.server.spring.SpringComponentProvider",
80-
"javax.servlet.ServletRegistration" })
80+
@ConditionalOnClass({ SpringComponentProvider.class, ServletRegistration.class })
8181
@ConditionalOnBean(type = "org.glassfish.jersey.server.ResourceConfig")
8282
@ConditionalOnWebApplication(type = Type.SERVLET)
8383
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisEmbeddedServerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* @author Stephane Nicoll
4444
*/
4545
@Configuration
46-
@ConditionalOnClass(name = ArtemisConnectionFactoryFactory.EMBEDDED_JMS_CLASS)
46+
@ConditionalOnClass(EmbeddedJMS.class)
4747
@ConditionalOnProperty(prefix = "spring.artemis.embedded", name = "enabled", havingValue = "true", matchIfMissing = true)
4848
class ArtemisEmbeddedServerConfiguration {
4949

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -307,7 +307,7 @@ private void mapReactiveProperties(Reactive properties,
307307
}
308308

309309
@Configuration
310-
@ConditionalOnClass(name = "nz.net.ultraq.thymeleaf.LayoutDialect")
310+
@ConditionalOnClass(LayoutDialect.class)
311311
protected static class ThymeleafWebLayoutConfiguration {
312312

313313
@Bean

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/reactive/WebSocketReactiveAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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 javax.websocket.server.ServerContainer;
2121

2222
import org.apache.catalina.startup.Tomcat;
23+
import org.apache.tomcat.websocket.server.WsSci;
2324

2425
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
2526
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
@@ -47,7 +48,7 @@
4748
public class WebSocketReactiveAutoConfiguration {
4849

4950
@Configuration
50-
@ConditionalOnClass(name = "org.apache.tomcat.websocket.server.WsSci", value = Tomcat.class)
51+
@ConditionalOnClass({ Tomcat.class, WsSci.class })
5152
static class TomcatWebSocketConfiguration {
5253

5354
@Bean

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 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 javax.websocket.server.ServerContainer;
2121

2222
import org.apache.catalina.startup.Tomcat;
23+
import org.apache.tomcat.websocket.server.WsSci;
2324
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
2425

2526
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
@@ -58,7 +59,7 @@
5859
public class WebSocketServletAutoConfiguration {
5960

6061
@Configuration
61-
@ConditionalOnClass(name = "org.apache.tomcat.websocket.server.WsSci", value = Tomcat.class)
62+
@ConditionalOnClass({ Tomcat.class, WsSci.class })
6263
static class TomcatWebSocketConfiguration {
6364

6465
@Bean

0 commit comments

Comments
 (0)