/** * Inspects the given {@link ApplicationContext} for {@link ReactiveMongoPersistentEntityIndexCreator} and those in * turn if they were registered for the current {@link MappingContext}. If no creator for the current * {@link MappingContext} can be found we manually add the internally created one as {@link ApplicationListener} to * make sure indexes get created appropriately for entity types persisted through this {@link ReactiveMongoTemplate} * instance. * * @param context must not be {@literal null}. */ private void prepareIndexCreator(ApplicationContext context) { String[] indexCreators = context.getBeanNamesForType(ReactiveMongoPersistentEntityIndexCreator.class); for (String creator : indexCreators) { ReactiveMongoPersistentEntityIndexCreator creatorBean = context.getBean(creator, ReactiveMongoPersistentEntityIndexCreator.class); if (creatorBean.isIndexCreatorFor(mappingContext)) { return; } } if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).addApplicationListener(indexCreatorListener); } }
/** * Inspects the given {@link ApplicationContext} for {@link ReactiveMongoPersistentEntityIndexCreator} and those in * turn if they were registered for the current {@link MappingContext}. If no creator for the current * {@link MappingContext} can be found we manually add the internally created one as {@link ApplicationListener} to * make sure indexes get created appropriately for entity types persisted through this {@link ReactiveMongoTemplate} * instance. * * @param context must not be {@literal null}. */ private void prepareIndexCreator(ApplicationContext context) { String[] indexCreators = context.getBeanNamesForType(ReactiveMongoPersistentEntityIndexCreator.class); for (String creator : indexCreators) { ReactiveMongoPersistentEntityIndexCreator creatorBean = context.getBean(creator, ReactiveMongoPersistentEntityIndexCreator.class); if (creatorBean.isIndexCreatorFor(mappingContext)) { return; } } if (context instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) context).addApplicationListener(indexCreatorListener); } }