com.scalar.db.sql.SqlTransactionProvider Maven / Gradle / Ivy
package com.scalar.db.sql;
import java.util.Properties;
import javax.annotation.Nullable;
/**
* An interface that creates {@link SqlTransactionManager} and {@link
* SqlTwoPhaseCommitTransactionManager} instances. Each connection mode should implement this
* interface. The implementation is assumed to be loaded by {@link java.util.ServiceLoader}.
*/
public interface SqlTransactionProvider {
/**
* Returns the name of the connection mode. This is for the configuration {@link
* SqlConfig#CONNECTION_MODE}.
*
* @return the name of the connection mode
*/
String getName();
/**
* Creates an instance of {@link SqlTransactionManager} for the connection mode.
*
* @param properties properties for the configuration
* @return an instance of {@link SqlTransactionManager} for the connection mode
*/
SqlTransactionManager createSqlTransactionManager(Properties properties);
/**
* Creates an instance of {@link SqlTwoPhaseCommitTransactionManager} for the connection mode.
*
* @param properties properties for the configuration
* @return an instance of {@link SqlTwoPhaseCommitTransactionManager} for the connection mode. If
* the transaction manager does not support the two-phase commit interface, returns {@code
* null}.
*/
@Nullable
SqlTwoPhaseCommitTransactionManager createSqlTwoPhaseCommitTransactionManager(
Properties properties);
}