16
16
17
17
package org .springframework .data .couchbase .core .mapping ;
18
18
19
- import java .util .Optional ;
20
-
21
19
import org .springframework .beans .BeansException ;
22
20
import org .springframework .context .ApplicationContext ;
23
21
import org .springframework .context .ApplicationContextAware ;
24
- import org .springframework .context .ApplicationEventPublisher ;
25
- import org .springframework .data .couchbase .core .index .CouchbasePersistentEntityIndexCreator ;
26
22
import org .springframework .data .mapping .context .AbstractMappingContext ;
27
- import org .springframework .data .mapping .context .MappingContextEvent ;
28
23
import org .springframework .data .mapping .model .FieldNamingStrategy ;
29
24
import org .springframework .data .mapping .model .Property ;
30
25
import org .springframework .data .mapping .model .PropertyNameFieldNamingStrategy ;
36
31
* {@link BasicCouchbasePersistentEntity} and {@link BasicCouchbasePersistentProperty} as primary abstractions.
37
32
*
38
33
* @author Michael Nitschinger
39
- * @author Michael Reiche
40
34
*/
41
35
public class CouchbaseMappingContext
42
36
extends AbstractMappingContext <BasicCouchbasePersistentEntity <?>, CouchbasePersistentProperty >
@@ -56,8 +50,6 @@ public class CouchbaseMappingContext
56
50
private FieldNamingStrategy fieldNamingStrategy = DEFAULT_NAMING_STRATEGY ;
57
51
58
52
private boolean autoIndexCreation = true ;
59
- private ApplicationEventPublisher eventPublisher ;
60
- private CouchbasePersistentEntityIndexCreator indexCreator = null ;
61
53
62
54
/**
63
55
* Configures the {@link FieldNamingStrategy} to be used to determine the field name if no manual mapping is applied.
@@ -109,15 +101,6 @@ protected CouchbasePersistentProperty createPersistentProperty(Property property
109
101
@ Override
110
102
public void setApplicationContext (final ApplicationContext applicationContext ) throws BeansException {
111
103
context = applicationContext ;
112
- super .setApplicationContext (applicationContext );
113
- }
114
-
115
- @ Override
116
- public void setApplicationEventPublisher (ApplicationEventPublisher applicationEventPublisher ) {
117
- eventPublisher = applicationEventPublisher ;
118
- if (this .eventPublisher == null ) {
119
- this .eventPublisher = context ;
120
- }
121
104
}
122
105
123
106
public boolean isAutoIndexCreation () {
@@ -128,45 +111,4 @@ public void setAutoIndexCreation(boolean autoCreateIndexes) {
128
111
this .autoIndexCreation = autoCreateIndexes ;
129
112
}
130
113
131
- /**
132
- * override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has
133
- * already been cached
134
- *
135
- * @param typeInformation - entity type
136
- */
137
- @ Override
138
- protected Optional <BasicCouchbasePersistentEntity <?>> addPersistentEntity (TypeInformation <?> typeInformation ) {
139
- Optional <BasicCouchbasePersistentEntity <?>> entity = super .addPersistentEntity (typeInformation );
140
-
141
- if (this .eventPublisher != null && entity .isPresent ()) {
142
- if (this .indexCreator != null ) {
143
- if (!indexCreator .hasSeen (entity .get ())) {
144
- this .eventPublisher .publishEvent (new MappingContextEvent (this , entity .get ()));
145
- }
146
- }
147
- }
148
- return entity ;
149
- }
150
-
151
- /**
152
- * override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has
153
- * already been cached. Instead, user our own addPersistEntity that will.
154
- *
155
- * @param typeInformation - entity type
156
- */
157
- @ Override
158
- public BasicCouchbasePersistentEntity <?> getPersistentEntity (TypeInformation <?> typeInformation ) {
159
- Optional <BasicCouchbasePersistentEntity <?>> entity = addPersistentEntity (typeInformation );
160
- return entity .isPresent () ? entity .get () : null ;
161
- }
162
-
163
- /**
164
- * capture the indexCreator when it has been added as a listener. only publishEvent() if the indexCreator hasn't
165
- * already seen the class.
166
- *
167
- * @param indexCreator
168
- */
169
- public void setIndexCreator (CouchbasePersistentEntityIndexCreator indexCreator ) {
170
- this .indexCreator = indexCreator ;
171
- }
172
114
}
0 commit comments