Class SqlLeaseContextBuilder
- java.lang.Object
-
- org.eclipse.dataspaceconnector.sql.lease.SqlLeaseContextBuilder
-
public class SqlLeaseContextBuilder extends java.lang.ObjectUtility class to assemble aSqlLeaseContextand execute operations on it using aConnection. The intended use is to create the SqlLeaseContextBuilder once and set the connection many times://in ctor: lc = SqlLeaseContextconfiguration.with( .... ); //in method 1 void method1(){ var connection = ...; lc.withConnection(connection).acquireLease(...); //or lc.withConnection(connection).breakLease(...); }Please do NOT keep references to the
SqlLeaseContext, as this would keep the underlying connection open!
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlLeaseContextBuilderby(java.lang.String leaseHolder)Sets the name which is used when acquiring a lease.SqlLeaseContextBuilderforTime(java.time.Duration duration)configures the duration for which the lease is acquired.static SqlLeaseContextBuilderwith(org.eclipse.dataspaceconnector.spi.transaction.TransactionContext trxContext, java.lang.String leaseHolder, LeaseStatements statements)SqlLeaseContextwithConnection(java.sql.Connection connection)sets the Connection on which the next DB statement is executed.
-
-
-
Method Detail
-
with
public static SqlLeaseContextBuilder with(org.eclipse.dataspaceconnector.spi.transaction.TransactionContext trxContext, java.lang.String leaseHolder, LeaseStatements statements)
-
by
public SqlLeaseContextBuilder by(java.lang.String leaseHolder)
Sets the name which is used when acquiring a lease.
-
forTime
public SqlLeaseContextBuilder forTime(java.time.Duration duration)
configures the duration for which the lease is acquired. Has no effect when breaking or getting the lease
-
withConnection
public SqlLeaseContext withConnection(java.sql.Connection connection)
sets the Connection on which the next DB statement is executed.Storing references to the
SqlLeaseContextis strongly discouraged, as this would keep the databaseConnectionopen!
-
-