Polish "Replace AotApplicationContextInitializer with interface"
Closes gh-29157
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -67,14 +68,14 @@ public interface AotApplicationContextInitializer<C extends ConfigurableApplicat
|
||||
logger.debug("Initializing ApplicationContext with AOT");
|
||||
for (String initializerClassName : initializerClassNames) {
|
||||
logger.trace(LogMessage.format("Applying %s", initializerClassName));
|
||||
instantiateInitializer(classLoader, initializerClassName)
|
||||
instantiateInitializer(initializerClassName, classLoader)
|
||||
.initialize(applicationContext);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <C extends ConfigurableApplicationContext> ApplicationContextInitializer<C> instantiateInitializer(
|
||||
ClassLoader classLoader, String initializerClassName) {
|
||||
String initializerClassName, @Nullable ClassLoader classLoader) {
|
||||
try {
|
||||
Class<?> initializerClass = ClassUtils.resolveClassName(initializerClassName, classLoader);
|
||||
Assert.isAssignable(ApplicationContextInitializer.class, initializerClass);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-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.
|
||||
* 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.context.aot;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
/**
|
||||
* Initializes a {@link ConfigurableApplicationContext} using AOT optimizations.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 6.0
|
||||
* @deprecated in favor of {@link AotApplicationContextInitializer}
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
public class ApplicationContextAotInitializer {
|
||||
|
||||
/**
|
||||
* Initialize the specified application context using the specified
|
||||
* {@link ApplicationContextInitializer} class names. Each class is
|
||||
* expected to have a default constructor.
|
||||
* @param context the context to initialize
|
||||
* @param initializerClassNames the application context initializer class names
|
||||
*/
|
||||
public void initialize(ConfigurableApplicationContext context, String... initializerClassNames) {
|
||||
AotApplicationContextInitializer.forInitializerClasses(initializerClassNames).initialize(context);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user