Class RepositoryProvider
- java.lang.Object
-
- org.eclipse.rdf4j.repository.manager.RepositoryProvider
-
public class RepositoryProvider extends java.lang.Object
A static access point to manageRepositoryManager
s andRepositories
. RepositoryProvider ensures that all managers and repositories obtained through it are automatically shutdown when the JVM exits.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RepositoryProvider.SynchronizedManager
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.Map<java.lang.String,RepositoryProvider.SynchronizedManager>
managers
private static java.lang.String
REPOSITORIES
-
Constructor Summary
Constructors Constructor Description RepositoryProvider()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.io.File
asLocalFile(java.lang.String url)
(package private) static RepositoryManager
createRepositoryManager(java.lang.String url)
static Repository
getRepository(java.lang.String url)
Retrieves a (new or existing) Repository object for the supplied repository URL.static java.lang.String
getRepositoryIdOfRepository(java.lang.String url)
Retrieves the Repository ID that will be passed to a RepositoryManager for the given repository URL.static LocalRepositoryManager
getRepositoryManager(java.io.File dir)
Creates aLocalRepositoryManager
, if not already created, that will be shutdown when the JVM exits cleanly.static RepositoryManager
getRepositoryManager(java.lang.String url)
Creates aRepositoryManager
, if not already created, that will be shutdown when the JVM exits cleanly.static RepositoryManager
getRepositoryManagerOfRepository(java.lang.String url)
Retrieves theRepositoryManager
that will be used for the given repository URL.private static java.lang.String
normalizeDirectory(java.lang.String url)
-
-
-
Field Detail
-
REPOSITORIES
private static final java.lang.String REPOSITORIES
- See Also:
- Constant Field Values
-
managers
static final java.util.Map<java.lang.String,RepositoryProvider.SynchronizedManager> managers
-
-
Method Detail
-
getRepositoryManager
public static RepositoryManager getRepositoryManager(java.lang.String url) throws RepositoryConfigException, RepositoryException
Creates aRepositoryManager
, if not already created, that will be shutdown when the JVM exits cleanly.- Parameters:
url
- location of the data directory for the RepositoryManager. This should be a URL of the form http://host:port/path/ (for a RemoteRepositoryManager) or file:///path/ (for a LocalRepositoryManager).- Returns:
- a (new or existing)
RepositoryManager
using the supplied url as its data dir. - Throws:
RepositoryConfigException
RepositoryException
-
getRepositoryManager
public static LocalRepositoryManager getRepositoryManager(java.io.File dir) throws RepositoryConfigException, RepositoryException
Creates aLocalRepositoryManager
, if not already created, that will be shutdown when the JVM exits cleanly.- Parameters:
dir
- the data directory for the repository manager.- Returns:
- a (new or existing)
LocalRepositoryManager
. - Throws:
RepositoryConfigException
RepositoryException
-
getRepositoryManagerOfRepository
public static RepositoryManager getRepositoryManagerOfRepository(java.lang.String url) throws RepositoryConfigException, RepositoryException
Retrieves theRepositoryManager
that will be used for the given repository URL. Creates aRepositoryManager
, if not already created, that will be shutdown when the JVM exits cleanly.- Parameters:
url
- the location of the repository for which to retrieve the corresponding RepositoryManager. The parameter must be a URL of the form http://host:port/path/repositories/id or file:///path/repositories/id.- Returns:
- the
RepositoryManager
that manages the repository identified by the URL. - Throws:
java.lang.IllegalArgumentException
- if the supplied URL is not a repository URL.RepositoryConfigException
RepositoryException
-
getRepositoryIdOfRepository
public static java.lang.String getRepositoryIdOfRepository(java.lang.String url)
Retrieves the Repository ID that will be passed to a RepositoryManager for the given repository URL.- Parameters:
url
- the location URL for the repository. The parameter must be a URL of the form http://host:port/path/repositories/id or file:///path/repositories/id.- Returns:
- the repository identifier string for the given repository URL.
- Throws:
java.lang.IllegalArgumentException
- if the supplied URL is not a repository URL.
-
getRepository
public static Repository getRepository(java.lang.String url) throws RepositoryException, RepositoryConfigException
Retrieves a (new or existing) Repository object for the supplied repository URL. The Repository will be shutdown when the JVM exits cleanly.- Parameters:
url
- the repository URL. The parameter must be a URL of the form http://host:port/path/repositories/id or file:///path/repositories/id.- Returns:
- Repository from a RepositoryManager or null if repository is not defined
- Throws:
RepositoryException
RepositoryConfigException
-
createRepositoryManager
static RepositoryManager createRepositoryManager(java.lang.String url) throws RepositoryConfigException
- Throws:
RepositoryConfigException
-
asLocalFile
private static java.io.File asLocalFile(java.lang.String url) throws RepositoryConfigException
- Throws:
RepositoryConfigException
-
normalizeDirectory
private static java.lang.String normalizeDirectory(java.lang.String url) throws java.lang.IllegalArgumentException
- Throws:
java.lang.IllegalArgumentException
-
-