3434import java .util .concurrent .locks .Lock ;
3535import java .util .concurrent .locks .ReentrantReadWriteLock ;
3636
37- import org .springframework .beans .BeansException ;
38- import org .springframework .context .ApplicationContext ;
39- import org .springframework .context .ApplicationContextAware ;
37+ import org .springframework .beans .factory .InitializingBean ;
4038import org .springframework .context .ApplicationEventPublisher ;
4139import org .springframework .context .ApplicationEventPublisherAware ;
42- import org .springframework .context .ApplicationListener ;
43- import org .springframework .context .event .ContextRefreshedEvent ;
4440import org .springframework .data .mapping .PersistentEntity ;
4541import org .springframework .data .mapping .PersistentProperty ;
4642import org .springframework .data .mapping .PropertyPath ;
6763 * @author Oliver Gierke
6864 */
6965public abstract class AbstractMappingContext <E extends MutablePersistentEntity <?, P >, P extends PersistentProperty <P >>
70- implements MappingContext <E , P >, ApplicationContextAware , ApplicationEventPublisherAware ,
71- ApplicationListener <ContextRefreshedEvent > {
66+ implements MappingContext <E , P >, ApplicationEventPublisherAware , InitializingBean {
7267
7368 private final ConcurrentMap <TypeInformation <?>, E > persistentEntities = new ConcurrentHashMap <TypeInformation <?>, E >();
7469
75- private ApplicationContext applicationContext ;
7670 private ApplicationEventPublisher applicationEventPublisher ;
7771
7872 private Set <? extends Class <?>> initialEntitySet = new HashSet <Class <?>>();
@@ -83,20 +77,6 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
8377 private final Lock read = lock .readLock ();
8478 private final Lock write = lock .writeLock ();
8579
86- /*
87- * (non-Javadoc)
88- * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
89- */
90- public void setApplicationContext (ApplicationContext applicationContext ) throws BeansException {
91-
92- this .applicationContext = applicationContext ;
93-
94- // Default publisher
95- if (this .applicationEventPublisher == null ) {
96- this .applicationEventPublisher = applicationContext ;
97- }
98- }
99-
10080 /*
10181 * (non-Javadoc)
10282 * @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
@@ -324,16 +304,12 @@ protected E addPersistentEntity(TypeInformation<?> typeInformation) {
324304 protected abstract P createPersistentProperty (Field field , PropertyDescriptor descriptor , E owner ,
325305 SimpleTypeHolder simpleTypeHolder );
326306
327- /*
307+ /*
328308 * (non-Javadoc)
329- * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent )
309+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet( )
330310 */
331- public void onApplicationEvent (ContextRefreshedEvent event ) {
332-
333- if (!event .getApplicationContext ().equals (applicationContext )) {
334- return ;
335- }
336-
311+ @ Override
312+ public void afterPropertiesSet () {
337313 initialize ();
338314 }
339315
0 commit comments