Class RDF4JRepositoryUtils
java.lang.Object
it.uniroma2.art.semanticturkey.tx.RDF4JRepositoryUtils
Utility class that provides static methods for obtaining connections from Sesame Repositories. It includes
support for transactional connections managed by
RDF4JRepositoryTransactionManager
. This class is
inspired by org.springframework.jdbc.datasource.DataSourceUtils
.
Manuel Fiorelli-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.rdf4j.common.transaction.IsolationLevel
computeIsolationLevel
(Optional<STRepositoryInfo> repositoryInfo, org.eclipse.rdf4j.repository.RepositoryConnection conn, boolean readOnly) Computes the appropriate level for a connection.static org.eclipse.rdf4j.common.transaction.IsolationLevel
convertSpringIsolationLevel
(int isolationLevel) Converters the isolation levels defined by Spring (see constantsISOLATION_...
defined inTransactionDefinition
).static org.eclipse.rdf4j.repository.RepositoryConnection
getConnection
(org.eclipse.rdf4j.repository.Repository repository) Returns a connection to a RDF4J Repository.static org.eclipse.rdf4j.repository.RepositoryConnection
getConnection
(org.eclipse.rdf4j.repository.Repository repository, boolean canCreate) static void
releaseConnection
(org.eclipse.rdf4j.repository.RepositoryConnection repoConn, org.eclipse.rdf4j.repository.Repository repository) Closes aconnection
the the givendata source
, if the connection is not externally managed.static org.eclipse.rdf4j.repository.RepositoryConnection
wrapConnection
(org.eclipse.rdf4j.repository.RepositoryConnection connection) Wraps the given repository connections with appropriate wrappers implementing the interfacesDelegatingRepositoryConnection
.static org.eclipse.rdf4j.repository.RepositoryConnection
wrapReadOnlyConnection
(org.eclipse.rdf4j.repository.RepositoryConnection connection)
-
Constructor Details
-
RDF4JRepositoryUtils
public RDF4JRepositoryUtils()
-
-
Method Details
-
getConnection
public static org.eclipse.rdf4j.repository.RepositoryConnection getConnection(org.eclipse.rdf4j.repository.Repository repository) Returns a connection to a RDF4J Repository. This method is aware of a connection already bound to the thread, e.g. byRDF4JRepositoryTransactionManager
.- Parameters:
repository
-- Returns:
-
getConnection
public static org.eclipse.rdf4j.repository.RepositoryConnection getConnection(org.eclipse.rdf4j.repository.Repository repository, boolean canCreate) -
releaseConnection
public static void releaseConnection(org.eclipse.rdf4j.repository.RepositoryConnection repoConn, org.eclipse.rdf4j.repository.Repository repository) Closes aconnection
the the givendata source
, if the connection is not externally managed.- Parameters:
repoConn
-repository
-
-
wrapConnection
public static org.eclipse.rdf4j.repository.RepositoryConnection wrapConnection(org.eclipse.rdf4j.repository.RepositoryConnection connection) Wraps the given repository connections with appropriate wrappers implementing the interfacesDelegatingRepositoryConnection
. Currently, the only supported wrapper enforces that during a read-only transaction it is not possible to invoke mutation operations on a connection.- Parameters:
connection
-- Returns:
-
wrapReadOnlyConnection
public static org.eclipse.rdf4j.repository.RepositoryConnection wrapReadOnlyConnection(org.eclipse.rdf4j.repository.RepositoryConnection connection) -
computeIsolationLevel
public static org.eclipse.rdf4j.common.transaction.IsolationLevel computeIsolationLevel(Optional<STRepositoryInfo> repositoryInfo, org.eclipse.rdf4j.repository.RepositoryConnection conn, boolean readOnly) Computes the appropriate level for a connection.- Parameters:
repositoryInfo
- information object about a repositoryconn
- a connectionreadOnly
- whether the connection will be used in read-only mode or not- Returns:
- the desired isolation level, or
null
to indicate the default isolation level
-
convertSpringIsolationLevel
public static org.eclipse.rdf4j.common.transaction.IsolationLevel convertSpringIsolationLevel(int isolationLevel) throws IllegalArgumentException Converters the isolation levels defined by Spring (see constantsISOLATION_...
defined inTransactionDefinition
).- Returns:
- the corresponding isolation level in RDF4J. Please, note that
null
represents the default isolation level - Throws:
IllegalArgumentException
- ifisolationLevel
does not correspond to an isolation level
-