|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
29 | 29 | import org.springframework.orm.jpa.JpaVendorAdapter;
|
30 | 30 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
31 | 31 | import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager;
|
| 32 | +import org.springframework.orm.jpa.persistenceunit.PersistenceUnitPostProcessor; |
32 | 33 | import org.springframework.util.ClassUtils;
|
33 | 34 | import org.springframework.util.ObjectUtils;
|
34 | 35 | import org.springframework.util.StringUtils;
|
@@ -58,6 +59,8 @@ public class EntityManagerFactoryBuilder {
|
58 | 59 |
|
59 | 60 | private AsyncTaskExecutor bootstrapExecutor;
|
60 | 61 |
|
| 62 | + private PersistenceUnitPostProcessor[] persistenceUnitPostProcessors; |
| 63 | + |
61 | 64 | /**
|
62 | 65 | * Create a new instance passing in the common pieces that will be shared if multiple
|
63 | 66 | * EntityManagerFactory instances are created.
|
@@ -104,6 +107,17 @@ public void setBootstrapExecutor(AsyncTaskExecutor bootstrapExecutor) {
|
104 | 107 | this.bootstrapExecutor = bootstrapExecutor;
|
105 | 108 | }
|
106 | 109 |
|
| 110 | + /** |
| 111 | + * Set the {@linkplain PersistenceUnitPostProcessor persistence unit post processors} |
| 112 | + * to be applied to the PersistenceUnitInfo used for creating the |
| 113 | + * {@link LocalContainerEntityManagerFactoryBean}. |
| 114 | + * @param persistenceUnitPostProcessors the persistence unit post processors to use |
| 115 | + * @since 2.5.0 |
| 116 | + */ |
| 117 | + public void setPersistenceUnitPostProcessors(PersistenceUnitPostProcessor... persistenceUnitPostProcessors) { |
| 118 | + this.persistenceUnitPostProcessors = persistenceUnitPostProcessors; |
| 119 | + } |
| 120 | + |
107 | 121 | /**
|
108 | 122 | * A fluent builder for a LocalContainerEntityManagerFactoryBean.
|
109 | 123 | */
|
@@ -232,6 +246,10 @@ public LocalContainerEntityManagerFactoryBean build() {
|
232 | 246 | if (EntityManagerFactoryBuilder.this.bootstrapExecutor != null) {
|
233 | 247 | entityManagerFactoryBean.setBootstrapExecutor(EntityManagerFactoryBuilder.this.bootstrapExecutor);
|
234 | 248 | }
|
| 249 | + if (EntityManagerFactoryBuilder.this.persistenceUnitPostProcessors != null) { |
| 250 | + entityManagerFactoryBean.setPersistenceUnitPostProcessors( |
| 251 | + EntityManagerFactoryBuilder.this.persistenceUnitPostProcessors); |
| 252 | + } |
235 | 253 | return entityManagerFactoryBean;
|
236 | 254 | }
|
237 | 255 |
|
|
0 commit comments