org.jbatis.dds.solon.starter.transactional.MongoTransactionalAspect Maven / Gradle / Ivy
package org.jbatis.dds.solon.starter.transactional;
import com.mongodb.ClientSessionOptions;
import com.mongodb.client.ClientSession;
import com.mongodb.client.MongoClient;
import org.jbatis.dds.kernel.annotation.transactional.MongoTransactional;
import org.jbatis.dds.kernel.cache.global.MongoClientCache;
import org.jbatis.dds.kernel.context.MongoTransactionContext;
import org.jbatis.dds.kernel.context.MongoTransactionStatus;
import org.noear.solon.core.aspect.Interceptor;
import org.noear.solon.core.aspect.Invocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
/**
*
**/
public class MongoTransactionalAspect implements Interceptor {
private static final Logger logger = LoggerFactory.getLogger(MongoTransactionalAspect.class);
public MongoTransactionalAspect(MongoClient mongoClient) {
this.mongoClient = mongoClient;
}
private MongoClient mongoClient;
@Override
public Object doIntercept(Invocation inv) throws Throwable {
if (mongoClient == null){
mongoClient = MongoClientCache.mongoClient;
}
AtomicReference