Polishing
Backport Bot / build (push) Waiting to run
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
Deploy Docs / Dispatch docs deployment (push) Waiting to run
Details
Backport Bot / build (push) Waiting to run
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:21], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:ubuntu-latest name:Linux]) (push) Waiting to run
Details
Deploy Docs / Dispatch docs deployment (push) Waiting to run
Details
This commit is contained in:
parent
4190209ead
commit
b6aa6899a8
|
@ -40,8 +40,7 @@ public interface BeanRegistrationAotContribution {
|
||||||
* default code generation isn't suitable.
|
* default code generation isn't suitable.
|
||||||
* @param generationContext the generation context
|
* @param generationContext the generation context
|
||||||
* @param codeFragments the existing code fragments
|
* @param codeFragments the existing code fragments
|
||||||
* @return the code fragments to use, may be the original instance or a
|
* @return the code fragments to use, may be the original instance or a wrapper
|
||||||
* wrapper
|
|
||||||
*/
|
*/
|
||||||
default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments(
|
default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments(
|
||||||
GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) {
|
GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) {
|
||||||
|
@ -77,8 +76,7 @@ public interface BeanRegistrationAotContribution {
|
||||||
return defaultCodeFragments.apply(codeFragments);
|
return defaultCodeFragments.apply(codeFragments);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void applyTo(GenerationContext generationContext,
|
public void applyTo(GenerationContext generationContext, BeanRegistrationCode beanRegistrationCode) {
|
||||||
BeanRegistrationCode beanRegistrationCode) {
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,14 +31,15 @@ import org.springframework.javapoet.CodeBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the various fragments of code needed to register a bean.
|
* Generate the various fragments of code needed to register a bean.
|
||||||
* <p>
|
*
|
||||||
* A default implementation is provided that suits most needs and custom code
|
* <p>A default implementation is provided that suits most needs and custom code
|
||||||
* fragments are only expected to be used by library authors having built custom
|
* fragments are only expected to be used by library authors having built custom
|
||||||
* arrangement on top of the core container.
|
* arrangement on top of the core container.
|
||||||
* <p>
|
*
|
||||||
* Users are not expected to implement this interface directly, but rather extends
|
* <p>Users are not expected to implement this interface directly, but rather
|
||||||
* from {@link BeanRegistrationCodeFragmentsDecorator} and only override the
|
* extends from {@link BeanRegistrationCodeFragmentsDecorator} and only override
|
||||||
* necessary method(s).
|
* the necessary method(s).
|
||||||
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
@ -48,12 +49,12 @@ import org.springframework.javapoet.CodeBlock;
|
||||||
public interface BeanRegistrationCodeFragments {
|
public interface BeanRegistrationCodeFragments {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The variable name to used when creating the bean definition.
|
* The variable name used when creating the bean definition.
|
||||||
*/
|
*/
|
||||||
String BEAN_DEFINITION_VARIABLE = "beanDefinition";
|
String BEAN_DEFINITION_VARIABLE = "beanDefinition";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The variable name to used when creating the bean definition.
|
* The variable name used when creating the bean definition.
|
||||||
*/
|
*/
|
||||||
String INSTANCE_SUPPLIER_VARIABLE = "instanceSupplier";
|
String INSTANCE_SUPPLIER_VARIABLE = "instanceSupplier";
|
||||||
|
|
||||||
|
@ -69,8 +70,7 @@ public interface BeanRegistrationCodeFragments {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the code that defines the new bean definition instance.
|
* Generate the code that defines the new bean definition instance.
|
||||||
* <p>
|
* <p>This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
|
||||||
* This should declare a variable named {@value BEAN_DEFINITION_VARIABLE}
|
|
||||||
* so that further fragments can refer to the variable to further tune
|
* so that further fragments can refer to the variable to further tune
|
||||||
* the bean definition.
|
* the bean definition.
|
||||||
* @param generationContext the generation context
|
* @param generationContext the generation context
|
||||||
|
@ -94,14 +94,13 @@ public interface BeanRegistrationCodeFragments {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the code that sets the instance supplier on the bean definition.
|
* Generate the code that sets the instance supplier on the bean definition.
|
||||||
* <p>
|
* <p>The {@code postProcessors} represent methods to be exposed once the
|
||||||
* The {@code postProcessors} represent methods to be exposed once the
|
|
||||||
* instance has been created to further configure it. Each method should
|
* instance has been created to further configure it. Each method should
|
||||||
* accept two parameters, the {@link RegisteredBean} and the bean
|
* accept two parameters, the {@link RegisteredBean} and the bean
|
||||||
* instance, and should return the modified bean instance.
|
* instance, and should return the modified bean instance.
|
||||||
* @param generationContext the generation context
|
* @param generationContext the generation context
|
||||||
* @param beanRegistrationCode the bean registration code
|
* @param beanRegistrationCode the bean registration code
|
||||||
* @param instanceSupplierCode the instance supplier code supplier code
|
* @param instanceSupplierCode the instance supplier code
|
||||||
* @param postProcessors any instance post processors that should be applied
|
* @param postProcessors any instance post processors that should be applied
|
||||||
* @return the generated code
|
* @return the generated code
|
||||||
* @see #generateInstanceSupplierCode
|
* @see #generateInstanceSupplierCode
|
||||||
|
|
|
@ -58,6 +58,7 @@ class BeanRegistrationCodeGenerator implements BeanRegistrationCode {
|
||||||
this.codeFragments = codeFragments;
|
this.codeFragments = codeFragments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClassName getClassName() {
|
public ClassName getClassName() {
|
||||||
return this.className;
|
return this.className;
|
||||||
|
|
|
@ -246,7 +246,7 @@ class DefaultBeanRegistrationCodeFragments implements BeanRegistrationCodeFragme
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasInstanceSupplier() {
|
private boolean hasInstanceSupplier() {
|
||||||
return this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null;
|
return (this.registeredBean.getMergedBeanDefinition().getInstanceSupplier() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of {@link BeanFactoryInitializationAotContribution AOT
|
* A collection of {@link BeanFactoryInitializationAotContribution AOT contributions}
|
||||||
* contributions} obtained from {@link BeanFactoryInitializationAotProcessor AOT
|
* obtained from {@link BeanFactoryInitializationAotProcessor AOT processors}.
|
||||||
* processors}.
|
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 6.0
|
* @since 6.0
|
||||||
|
@ -47,14 +46,12 @@ class BeanFactoryInitializationAotContributions {
|
||||||
this(beanFactory, AotServices.factoriesAndBeans(beanFactory));
|
this(beanFactory, AotServices.factoriesAndBeans(beanFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory,
|
BeanFactoryInitializationAotContributions(DefaultListableBeanFactory beanFactory, AotServices.Loader loader) {
|
||||||
AotServices.Loader loader) {
|
|
||||||
this.contributions = getContributions(beanFactory, getProcessors(loader));
|
this.contributions = getContributions(beanFactory, getProcessors(loader));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<BeanFactoryInitializationAotProcessor> getProcessors(
|
private static List<BeanFactoryInitializationAotProcessor> getProcessors(AotServices.Loader loader) {
|
||||||
AotServices.Loader loader) {
|
|
||||||
List<BeanFactoryInitializationAotProcessor> processors = new ArrayList<>(
|
List<BeanFactoryInitializationAotProcessor> processors = new ArrayList<>(
|
||||||
loader.load(BeanFactoryInitializationAotProcessor.class).asList());
|
loader.load(BeanFactoryInitializationAotProcessor.class).asList());
|
||||||
processors.add(new RuntimeHintsBeanFactoryInitializationAotProcessor());
|
processors.add(new RuntimeHintsBeanFactoryInitializationAotProcessor());
|
||||||
|
@ -62,8 +59,8 @@ class BeanFactoryInitializationAotContributions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<BeanFactoryInitializationAotContribution> getContributions(
|
private List<BeanFactoryInitializationAotContribution> getContributions(
|
||||||
DefaultListableBeanFactory beanFactory,
|
DefaultListableBeanFactory beanFactory, List<BeanFactoryInitializationAotProcessor> processors) {
|
||||||
List<BeanFactoryInitializationAotProcessor> processors) {
|
|
||||||
List<BeanFactoryInitializationAotContribution> contributions = new ArrayList<>();
|
List<BeanFactoryInitializationAotContribution> contributions = new ArrayList<>();
|
||||||
for (BeanFactoryInitializationAotProcessor processor : processors) {
|
for (BeanFactoryInitializationAotProcessor processor : processors) {
|
||||||
BeanFactoryInitializationAotContribution contribution = processAheadOfTime(processor, beanFactory);
|
BeanFactoryInitializationAotContribution contribution = processAheadOfTime(processor, beanFactory);
|
||||||
|
@ -75,8 +72,8 @@ class BeanFactoryInitializationAotContributions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BeanFactoryInitializationAotContribution processAheadOfTime(BeanFactoryInitializationAotProcessor processor,
|
private BeanFactoryInitializationAotContribution processAheadOfTime(
|
||||||
DefaultListableBeanFactory beanFactory) {
|
BeanFactoryInitializationAotProcessor processor, DefaultListableBeanFactory beanFactory) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return processor.processAheadOfTime(beanFactory);
|
return processor.processAheadOfTime(beanFactory);
|
||||||
|
@ -92,6 +89,7 @@ class BeanFactoryInitializationAotContributions {
|
||||||
|
|
||||||
void applyTo(GenerationContext generationContext,
|
void applyTo(GenerationContext generationContext,
|
||||||
BeanFactoryInitializationCode beanFactoryInitializationCode) {
|
BeanFactoryInitializationCode beanFactoryInitializationCode) {
|
||||||
|
|
||||||
for (BeanFactoryInitializationAotContribution contribution : this.contributions) {
|
for (BeanFactoryInitializationAotContribution contribution : this.contributions) {
|
||||||
contribution.applyTo(generationContext, beanFactoryInitializationCode);
|
contribution.applyTo(generationContext, beanFactoryInitializationCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ public class HibernateQueryException extends InvalidDataAccessResourceUsageExcep
|
||||||
* Return the HQL query string that was invalid.
|
* Return the HQL query string that was invalid.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
@SuppressWarnings("NullAway")
|
|
||||||
public String getQueryString() {
|
public String getQueryString() {
|
||||||
return ((QueryException) getCause()).getQueryString();
|
QueryException cause = (QueryException) getCause();
|
||||||
|
return (cause != null ? cause.getQueryString() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,6 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
||||||
|
|
||||||
private final ResourcePatternResolver resourcePatternResolver;
|
private final ResourcePatternResolver resourcePatternResolver;
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private TypeFilter[] entityTypeFilters = DEFAULT_ENTITY_TYPE_FILTERS;
|
private TypeFilter[] entityTypeFilters = DEFAULT_ENTITY_TYPE_FILTERS;
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,11 +378,9 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
||||||
* the current class descriptor contained in the metadata reader.
|
* the current class descriptor contained in the metadata reader.
|
||||||
*/
|
*/
|
||||||
private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException {
|
private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFactory readerFactory) throws IOException {
|
||||||
if (this.entityTypeFilters != null) {
|
for (TypeFilter filter : this.entityTypeFilters) {
|
||||||
for (TypeFilter filter : this.entityTypeFilters) {
|
if (filter.match(reader, readerFactory)) {
|
||||||
if (filter.match(reader, readerFactory)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue