DATACMNS-416 - Added means to enforce eager instantiation of CDI repositories.

The CDI extension now eagerly instantiates repository beans that are annotated with the newly introduced @Eager annotation. This is necessary to prevent the initialization procedure from interfering with potentially already executed business logic.

To achieve this CdiRepositoryExtensionSupport provides a new method registerBean(…) that has to be called by store implementations. The extension will then keep track of beans that require eager initialization and trigger it when the container has finished validation.
This commit is contained in:
Oliver Gierke
2014-01-12 17:54:52 +01:00
parent bf3437f39c
commit df1373aa81
4 changed files with 91 additions and 9 deletions

View File

@@ -40,7 +40,9 @@ public class DummyCdiExtension extends CdiRepositoryExtensionSupport {
@SuppressWarnings({ "rawtypes", "unchecked" })
void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager) {
for (Entry<Class<?>, Set<Annotation>> type : getRepositoryTypes()) {
afterBeanDiscovery.addBean(new DummyCdiRepositoryBean(type.getValue(), type.getKey(), beanManager));
DummyCdiRepositoryBean bean = new DummyCdiRepositoryBean(type.getValue(), type.getKey(), beanManager);
registerBean(bean);
afterBeanDiscovery.addBean(bean);
}
}