Skip to content

Commit 6c6dc13

Browse files
committed
DATACOUCH-677 - Revert "Datacouch 550 autoindex not working in spring boot app (#295)"
This reverts commit 8ebb81b.
1 parent 8ebb81b commit 6c6dc13

File tree

3 files changed

+0
-65
lines changed

3 files changed

+0
-65
lines changed

src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplate.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ private void prepareIndexCreator(final ApplicationContext context) {
166166

167167
if (context instanceof ConfigurableApplicationContext && indexCreator != null) {
168168
((ConfigurableApplicationContext) context).addApplicationListener(indexCreator);
169-
if (mappingContext instanceof CouchbaseMappingContext) {
170-
CouchbaseMappingContext cmc = (CouchbaseMappingContext) mappingContext;
171-
cmc.setIndexCreator(indexCreator);
172-
}
173169
}
174170
}
175171
}

src/main/java/org/springframework/data/couchbase/core/index/CouchbasePersistentEntityIndexCreator.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,4 @@ public boolean isIndexCreatorFor(final MappingContext<?, ?> context) {
121121
return this.mappingContext.equals(context);
122122
}
123123

124-
public boolean hasSeen(CouchbasePersistentEntity<?> entity) {
125-
return classesSeen.containsKey(entity.getType());
126-
}
127124
}

src/main/java/org/springframework/data/couchbase/core/mapping/CouchbaseMappingContext.java

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@
1616

1717
package org.springframework.data.couchbase.core.mapping;
1818

19-
import java.util.Optional;
20-
2119
import org.springframework.beans.BeansException;
2220
import org.springframework.context.ApplicationContext;
2321
import org.springframework.context.ApplicationContextAware;
24-
import org.springframework.context.ApplicationEventPublisher;
25-
import org.springframework.data.couchbase.core.index.CouchbasePersistentEntityIndexCreator;
2622
import org.springframework.data.mapping.context.AbstractMappingContext;
27-
import org.springframework.data.mapping.context.MappingContextEvent;
2823
import org.springframework.data.mapping.model.FieldNamingStrategy;
2924
import org.springframework.data.mapping.model.Property;
3025
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
@@ -36,7 +31,6 @@
3631
* {@link BasicCouchbasePersistentEntity} and {@link BasicCouchbasePersistentProperty} as primary abstractions.
3732
*
3833
* @author Michael Nitschinger
39-
* @author Michael Reiche
4034
*/
4135
public class CouchbaseMappingContext
4236
extends AbstractMappingContext<BasicCouchbasePersistentEntity<?>, CouchbasePersistentProperty>
@@ -56,8 +50,6 @@ public class CouchbaseMappingContext
5650
private FieldNamingStrategy fieldNamingStrategy = DEFAULT_NAMING_STRATEGY;
5751

5852
private boolean autoIndexCreation = true;
59-
private ApplicationEventPublisher eventPublisher;
60-
private CouchbasePersistentEntityIndexCreator indexCreator = null;
6153

6254
/**
6355
* 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
109101
@Override
110102
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
111103
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-
}
121104
}
122105

123106
public boolean isAutoIndexCreation() {
@@ -128,45 +111,4 @@ public void setAutoIndexCreation(boolean autoCreateIndexes) {
128111
this.autoIndexCreation = autoCreateIndexes;
129112
}
130113

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-
}
172114
}

0 commit comments

Comments
 (0)