Polishing
This commit is contained in:
parent
0b02a5e073
commit
f19433f2d8
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -21,8 +21,8 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
|
|||
/**
|
||||
* Interface to be implemented by
|
||||
* {@link org.springframework.context.annotation.Configuration @Configuration}
|
||||
* classes annotated with {@link EnableLoadTimeWeaving @EnableLoadTimeWeaving} that wish to
|
||||
* customize the {@link LoadTimeWeaver} instance to be used.
|
||||
* classes annotated with {@link EnableLoadTimeWeaving @EnableLoadTimeWeaving}
|
||||
* that wish to customize the {@link LoadTimeWeaver} instance to be used.
|
||||
*
|
||||
* <p>See {@link org.springframework.scheduling.annotation.EnableAsync @EnableAsync}
|
||||
* for usage examples and information on how a default {@code LoadTimeWeaver}
|
||||
|
|
@ -36,9 +36,9 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
|
|||
public interface LoadTimeWeavingConfigurer {
|
||||
|
||||
/**
|
||||
* Create, configure and return the {@code LoadTimeWeaver} instance to be used. Note
|
||||
* that it is unnecessary to annotate this method with {@code @Bean}, because the
|
||||
* object returned will automatically be registered as a bean by
|
||||
* Create, configure and return the {@code LoadTimeWeaver} instance to be used.
|
||||
* Note that it is unnecessary to annotate this method with {@code @Bean}
|
||||
* because the object returned will automatically be registered as a bean by
|
||||
* {@link LoadTimeWeavingConfiguration#loadTimeWeaver()}
|
||||
*/
|
||||
LoadTimeWeaver getLoadTimeWeaver();
|
||||
|
|
|
|||
|
|
@ -772,7 +772,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
|||
|
||||
// Detect a LoadTimeWeaver and prepare for weaving, if found in the meantime
|
||||
// (e.g. through an @Bean method registered by ConfigurationClassPostProcessor)
|
||||
if (!NativeDetector.inNativeImage() && beanFactory.getTempClassLoader() == null && beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
|
||||
if (!NativeDetector.inNativeImage() && beanFactory.getTempClassLoader() == null &&
|
||||
beanFactory.containsBean(LOAD_TIME_WEAVER_BEAN_NAME)) {
|
||||
beanFactory.addBeanPostProcessor(new LoadTimeWeaverAwareProcessor(beanFactory));
|
||||
beanFactory.setTempClassLoader(new ContextTypeMatchClassLoader(beanFactory.getBeanClassLoader()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class EnableLoadTimeWeavingTests {
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.DISABLED)
|
||||
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.DISABLED)
|
||||
static class EnableLTWConfig_withAjWeavingDisabled implements LoadTimeWeavingConfigurer {
|
||||
|
||||
@Override
|
||||
|
|
@ -88,8 +88,9 @@ class EnableLoadTimeWeavingTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.AUTODETECT)
|
||||
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.AUTODETECT)
|
||||
static class EnableLTWConfig_withAjWeavingAutodetect implements LoadTimeWeavingConfigurer {
|
||||
|
||||
@Override
|
||||
|
|
@ -98,8 +99,9 @@ class EnableLoadTimeWeavingTests {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
|
||||
@EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED)
|
||||
static class EnableLTWConfig_withAjWeavingEnabled implements LoadTimeWeavingConfigurer {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -85,16 +85,13 @@ public class ReflectiveLoadTimeWeaverTests {
|
|||
|
||||
private int numTimesAddTransformerCalled = 0;
|
||||
|
||||
|
||||
public int getNumTimesGetThrowawayClassLoaderCalled() {
|
||||
return this.numTimesAddTransformerCalled;
|
||||
}
|
||||
|
||||
|
||||
public void addTransformer(ClassFileTransformer transformer) {
|
||||
++this.numTimesAddTransformerCalled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -102,18 +99,15 @@ public class ReflectiveLoadTimeWeaverTests {
|
|||
|
||||
private int numTimesGetThrowawayClassLoaderCalled = 0;
|
||||
|
||||
|
||||
@Override
|
||||
public int getNumTimesGetThrowawayClassLoaderCalled() {
|
||||
return this.numTimesGetThrowawayClassLoaderCalled;
|
||||
}
|
||||
|
||||
|
||||
public ClassLoader getThrowawayClassLoader() {
|
||||
++this.numTimesGetThrowawayClassLoaderCalled;
|
||||
return getClass().getClassLoader();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 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.
|
||||
|
|
@ -507,16 +507,8 @@ public abstract class ReflectionUtils {
|
|||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
public static boolean isEqualsMethod(@Nullable Method method) {
|
||||
if (method == null) {
|
||||
return false;
|
||||
}
|
||||
if (method.getParameterCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
if (!method.getName().equals("equals")) {
|
||||
return false;
|
||||
}
|
||||
return method.getParameterTypes()[0] == Object.class;
|
||||
return (method != null && method.getParameterCount() == 1 && method.getName().equals("equals") &&
|
||||
method.getParameterTypes()[0] == Object.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -524,7 +516,7 @@ public abstract class ReflectionUtils {
|
|||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public static boolean isHashCodeMethod(@Nullable Method method) {
|
||||
return method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode");
|
||||
return (method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue