Class JDBCPairwiseIdStore.ConnectionWithLock
- java.lang.Object
-
- net.shibboleth.idp.attribute.impl.JDBCPairwiseIdStore.ConnectionWithLock
-
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- JDBCPairwiseIdStore
protected class JDBCPairwiseIdStore.ConnectionWithLock extends Object implements AutoCloseable
A Class to encapsulate aConnectionprotected by an optional read/write lock. Because the class implementsAutoCloseablethe unlock can "just happen"
-
-
Field Summary
Fields Modifier and Type Field Description private ConnectionconnectionThe connection we set up.private LockthreadLockThe lock we may or may not have set up.
-
Constructor Summary
Constructors Constructor Description ConnectionWithLock(boolean autoCommit, boolean writeLock)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcommit()Delegated operation to the encapsulatedConnection.PreparedStatementprepareStatement(String sql)Delegated operation to the encapsulatedConnection.
-
-
-
Field Detail
-
connection
@Nonnull private final Connection connection
The connection we set up.
-
threadLock
@Nullable private final Lock threadLock
The lock we may or may not have set up.
-
-
Constructor Detail
-
ConnectionWithLock
public ConnectionWithLock(boolean autoCommit, boolean writeLock) throws SQLExceptionConstructor.- Parameters:
autoCommit-writeLock-- Throws:
SQLException
-
-
Method Detail
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
Delegated operation to the encapsulatedConnection.- Parameters:
sql- what to prepare- Returns:
- what the encapsulated
Connectionreturns - Throws:
SQLException- if encapsulatedConnectiondoes
-
commit
public void commit() throws SQLExceptionDelegated operation to the encapsulatedConnection.- Throws:
SQLException- if encapsulatedConnectiondoes
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-