Class RDF4JRepositoryUtils

java.lang.Object
it.uniroma2.art.semanticturkey.tx.RDF4JRepositoryUtils

public class RDF4JRepositoryUtils extends Object
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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static org.eclipse.rdf4j.common.transaction.IsolationLevel
    convertSpringIsolationLevel(int isolationLevel)
    Converters the isolation levels defined by Spring (see constants ISOLATION_... defined in TransactionDefinition).
    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 a connection the the given data 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 interfaces DelegatingRepositoryConnection.
    static org.eclipse.rdf4j.repository.RepositoryConnection
    wrapReadOnlyConnection(org.eclipse.rdf4j.repository.RepositoryConnection connection)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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. by RDF4JRepositoryTransactionManager.
      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 a connection the the given data 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 interfaces DelegatingRepositoryConnection. 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 repository
      conn - a connection
      readOnly - 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 constants ISOLATION_... defined in TransactionDefinition).
      Returns:
      the corresponding isolation level in RDF4J. Please, note that null represents the default isolation level
      Throws:
      IllegalArgumentException - if isolationLevel does not correspond to an isolation level