commit
d044eaf69d
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
|
|
@ -52,10 +52,6 @@ public enum WebApplicationType {
|
|||
|
||||
private static final String WEBFLUX_INDICATOR_CLASS = "org.springframework.web.reactive.DispatcherHandler";
|
||||
|
||||
private static final String SERVLET_APPLICATION_CONTEXT_CLASS = "org.springframework.web.context.WebApplicationContext";
|
||||
|
||||
private static final String REACTIVE_APPLICATION_CONTEXT_CLASS = "org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext";
|
||||
|
||||
static WebApplicationType deduceFromClasspath() {
|
||||
if (ClassUtils.isPresent(WEBFLUX_INDICATOR_CLASS, null)
|
||||
&& !ClassUtils.isPresent(WEBMVC_INDICATOR_CLASS, null)) {
|
||||
|
|
@ -69,23 +65,4 @@ public enum WebApplicationType {
|
|||
return WebApplicationType.SERVLET;
|
||||
}
|
||||
|
||||
static WebApplicationType deduceFromApplicationContext(Class<?> applicationContextClass) {
|
||||
if (isAssignable(SERVLET_APPLICATION_CONTEXT_CLASS, applicationContextClass)) {
|
||||
return WebApplicationType.SERVLET;
|
||||
}
|
||||
if (isAssignable(REACTIVE_APPLICATION_CONTEXT_CLASS, applicationContextClass)) {
|
||||
return WebApplicationType.REACTIVE;
|
||||
}
|
||||
return WebApplicationType.NONE;
|
||||
}
|
||||
|
||||
private static boolean isAssignable(String target, Class<?> type) {
|
||||
try {
|
||||
return ClassUtils.resolveClassName(target, null).isAssignableFrom(type);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue