34
34
import java .util .concurrent .locks .Lock ;
35
35
import java .util .concurrent .locks .ReentrantReadWriteLock ;
36
36
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 ;
40
38
import org .springframework .context .ApplicationEventPublisher ;
41
39
import org .springframework .context .ApplicationEventPublisherAware ;
42
- import org .springframework .context .ApplicationListener ;
43
- import org .springframework .context .event .ContextRefreshedEvent ;
44
40
import org .springframework .data .mapping .PersistentEntity ;
45
41
import org .springframework .data .mapping .PersistentProperty ;
46
42
import org .springframework .data .mapping .PropertyPath ;
67
63
* @author Oliver Gierke
68
64
*/
69
65
public 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 {
72
67
73
68
private final ConcurrentMap <TypeInformation <?>, E > persistentEntities = new ConcurrentHashMap <TypeInformation <?>, E >();
74
69
75
- private ApplicationContext applicationContext ;
76
70
private ApplicationEventPublisher applicationEventPublisher ;
77
71
78
72
private Set <? extends Class <?>> initialEntitySet = new HashSet <Class <?>>();
@@ -83,20 +77,6 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
83
77
private final Lock read = lock .readLock ();
84
78
private final Lock write = lock .writeLock ();
85
79
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
-
100
80
/*
101
81
* (non-Javadoc)
102
82
* @see org.springframework.context.ApplicationEventPublisherAware#setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
@@ -324,16 +304,12 @@ protected E addPersistentEntity(TypeInformation<?> typeInformation) {
324
304
protected abstract P createPersistentProperty (Field field , PropertyDescriptor descriptor , E owner ,
325
305
SimpleTypeHolder simpleTypeHolder );
326
306
327
- /*
307
+ /*
328
308
* (non-Javadoc)
329
- * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent )
309
+ * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet( )
330
310
*/
331
- public void onApplicationEvent (ContextRefreshedEvent event ) {
332
-
333
- if (!event .getApplicationContext ().equals (applicationContext )) {
334
- return ;
335
- }
336
-
311
+ @ Override
312
+ public void afterPropertiesSet () {
337
313
initialize ();
338
314
}
339
315
0 commit comments