DATADOC-271 Re-packaging Mongo cross-store support, removing 'document' in package name
This commit is contained in:
@@ -1,63 +0,0 @@
|
|||||||
package org.springframework.data.persistence.document;
|
|
||||||
|
|
||||||
//public class DocumentBackedTransactionSynchronization {
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.data.persistence.ChangeSetBacked;
|
|
||||||
import org.springframework.data.persistence.ChangeSetPersister;
|
|
||||||
import org.springframework.transaction.support.TransactionSynchronization;
|
|
||||||
|
|
||||||
public class DocumentBackedTransactionSynchronization implements TransactionSynchronization {
|
|
||||||
|
|
||||||
protected final Log log = LogFactory.getLog(getClass());
|
|
||||||
|
|
||||||
private ChangeSetPersister<Object> changeSetPersister;
|
|
||||||
|
|
||||||
private ChangeSetBacked entity;
|
|
||||||
|
|
||||||
private int changeSetTxStatus = -1;
|
|
||||||
|
|
||||||
public DocumentBackedTransactionSynchronization(ChangeSetPersister<Object> changeSetPersister, ChangeSetBacked entity) {
|
|
||||||
this.changeSetPersister = changeSetPersister;
|
|
||||||
this.entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void afterCommit() {
|
|
||||||
log.debug("After Commit called for " + entity);
|
|
||||||
changeSetPersister.persistState(entity, entity.getChangeSet());
|
|
||||||
changeSetTxStatus = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void afterCompletion(int status) {
|
|
||||||
log.debug("After Completion called with status = " + status);
|
|
||||||
if (changeSetTxStatus == 0) {
|
|
||||||
if (status == STATUS_COMMITTED) {
|
|
||||||
// this is good
|
|
||||||
log.debug("ChangedSetBackedTransactionSynchronization completed successfully for " + this.entity);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// this could be bad - TODO: compensate
|
|
||||||
log.error("ChangedSetBackedTransactionSynchronization failed for " + this.entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void beforeCommit(boolean readOnly) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void beforeCompletion() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void flush() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resume() {
|
|
||||||
throw new IllegalStateException("ChangedSetBackedTransactionSynchronization does not support transaction suspension currently.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void suspend() {
|
|
||||||
throw new IllegalStateException("ChangedSetBackedTransactionSynchronization does not support transaction suspension currently.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.springframework.data.persistence.document;
|
package org.springframework.data.persistence.mongodb;
|
||||||
|
|
||||||
import org.springframework.data.persistence.ChangeSetBacked;
|
import org.springframework.data.persistence.ChangeSetBacked;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.springframework.data.persistence.document.mongodb;
|
package org.springframework.data.persistence.mongodb;
|
||||||
|
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package org.springframework.data.persistence.document.mongodb;
|
package org.springframework.data.persistence.mongodb;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
@@ -12,10 +12,10 @@ import org.aspectj.lang.JoinPoint;
|
|||||||
import org.aspectj.lang.reflect.FieldSignature;
|
import org.aspectj.lang.reflect.FieldSignature;
|
||||||
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.data.persistence.document.RelatedDocument;
|
|
||||||
|
|
||||||
import org.springframework.data.persistence.document.DocumentBacked;
|
import org.springframework.data.persistence.mongodb.RelatedDocument;
|
||||||
import org.springframework.data.persistence.document.DocumentBackedTransactionSynchronization;
|
import org.springframework.data.persistence.mongodb.DocumentBacked;
|
||||||
|
import org.springframework.data.persistence.ChangeSetBackedTransactionSynchronization;
|
||||||
import org.springframework.data.persistence.ChangeSet;
|
import org.springframework.data.persistence.ChangeSet;
|
||||||
import org.springframework.data.persistence.ChangeSetPersister;
|
import org.springframework.data.persistence.ChangeSetPersister;
|
||||||
import org.springframework.data.persistence.ChangeSetPersister.NotFoundException;
|
import org.springframework.data.persistence.ChangeSetPersister.NotFoundException;
|
||||||
@@ -130,7 +130,7 @@ public aspect MongoDocumentBacking {
|
|||||||
entity.setChangeSet(new HashMapChangeSet());
|
entity.setChangeSet(new HashMapChangeSet());
|
||||||
entity.itdChangeSetPersister = changeSetPersister;
|
entity.itdChangeSetPersister = changeSetPersister;
|
||||||
entity.itdTransactionSynchronization =
|
entity.itdTransactionSynchronization =
|
||||||
new DocumentBackedTransactionSynchronization(changeSetPersister, entity);
|
new ChangeSetBackedTransactionSynchronization(changeSetPersister, entity);
|
||||||
//registerTransactionSynchronization(entity);
|
//registerTransactionSynchronization(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public aspect MongoDocumentBacking {
|
|||||||
|
|
||||||
@Transient private ChangeSetPersister<?> DocumentBacked.itdChangeSetPersister;
|
@Transient private ChangeSetPersister<?> DocumentBacked.itdChangeSetPersister;
|
||||||
|
|
||||||
@Transient private DocumentBackedTransactionSynchronization DocumentBacked.itdTransactionSynchronization;
|
@Transient private ChangeSetBackedTransactionSynchronization DocumentBacked.itdTransactionSynchronization;
|
||||||
|
|
||||||
public void DocumentBacked.setChangeSet(ChangeSet cs) {
|
public void DocumentBacked.setChangeSet(ChangeSet cs) {
|
||||||
this.changeSet = cs;
|
this.changeSet = cs;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.data.persistence.document;
|
package org.springframework.data.persistence.mongodb;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -3,7 +3,7 @@ package org.springframework.data.document.persistence.test;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.springframework.data.persistence.document.RelatedDocument;
|
import org.springframework.data.persistence.mongodb.RelatedDocument;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Person {
|
public class Person {
|
||||||
|
|||||||
@@ -38,12 +38,12 @@
|
|||||||
<bean class="org.springframework.data.mongodb.core.MongoExceptionTranslator"/>
|
<bean class="org.springframework.data.mongodb.core.MongoExceptionTranslator"/>
|
||||||
|
|
||||||
<!-- Mongo aspect config -->
|
<!-- Mongo aspect config -->
|
||||||
<bean class="org.springframework.data.persistence.document.mongodb.MongoDocumentBacking"
|
<bean class="org.springframework.data.persistence.mongodb.MongoDocumentBacking"
|
||||||
factory-method="aspectOf">
|
factory-method="aspectOf">
|
||||||
<property name="changeSetPersister" ref="mongoChangeSetPersister"/>
|
<property name="changeSetPersister" ref="mongoChangeSetPersister"/>
|
||||||
</bean>
|
</bean>
|
||||||
<bean id="mongoChangeSetPersister"
|
<bean id="mongoChangeSetPersister"
|
||||||
class="org.springframework.data.persistence.document.mongodb.MongoChangeSetPersister">
|
class="org.springframework.data.persistence.mongodb.MongoChangeSetPersister">
|
||||||
<property name="mongoTemplate" ref="mongoTemplate"/>
|
<property name="mongoTemplate" ref="mongoTemplate"/>
|
||||||
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
<property name="entityManagerFactory" ref="entityManagerFactory"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|||||||
Reference in New Issue
Block a user