org.openrdf.repository.manager
Class RepositoryManager

java.lang.Object
  extended by org.openrdf.repository.manager.RepositoryManager
Direct Known Subclasses:
LocalRepositoryManager, RemoteRepositoryManager, TypeFilteringRepositoryManager

public abstract class RepositoryManager
extends Object

A manager for Repositorys. Every RepositoryManager has one SYSTEM repository and zero or more "user repositories". The SYSTEM repository contains data that describes the configuration of the other repositories (their IDs, which implementations of the Repository API to use, access rights, etc.). The other repositories are instantiated based on this configuration data.

Author:
Arjohn Kampman

Field Summary
protected  Logger logger
           
 
Constructor Summary
RepositoryManager()
          Creates a new RepositoryManager that operates on the specfified base directory.
 
Method Summary
 void addRepositoryConfig(RepositoryConfig config)
          Adds or updates the configuration of a repository to the manager's system repository.
protected abstract  void cleanUpRepository(String repositoryID)
          Clean up a removed repository.
protected abstract  Repository createRepository(String id)
          Creates and initializes the repository with the specified ID.
protected abstract  Repository createSystemRepository()
           
 Collection<Repository> getAllRepositories()
          Returns all configured repositories.
 Collection<RepositoryInfo> getAllRepositoryInfos()
           
abstract  Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo)
           
 Collection<RepositoryInfo> getAllUserRepositoryInfos()
           
 Collection<Repository> getInitializedRepositories()
          Returns all inititalized repositories.
 Set<String> getInitializedRepositoryIDs()
          Returns all inititalized repositories.
 String getNewRepositoryID(String baseName)
          Generates an ID for a new repository based on the specified base name.
 Repository getRepository(String id)
          Gets the repository that is known by the specified ID from this manager.
 RepositoryConfig getRepositoryConfig(String repositoryID)
           
 Set<String> getRepositoryIDs()
           
abstract  RepositoryInfo getRepositoryInfo(String id)
          Gets the repository that is known by the specified ID from this manager.
 Repository getSystemRepository()
          Gets the SYSTEM repository.
 boolean hasRepositoryConfig(String repositoryID)
           
 void initialize()
          Initializes the repository manager.
 void refresh()
          Shuts down all initialized user repositories.
 boolean removeRepositoryConfig(String repositoryID)
          Removes the configuration for the specified repository from the manager's system repository if such a configuration is present.
 void shutDown()
          Shuts down all initialized repositories, including the SYSTEM repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Logger logger
Constructor Detail

RepositoryManager

public RepositoryManager()
Creates a new RepositoryManager that operates on the specfified base directory.

Parameters:
baseDir - The base directory where data for repositories can be stored, among other things.
Method Detail

initialize

public void initialize()
                throws RepositoryException
Initializes the repository manager.

Throws:
RepositoryException - If the manager failed to initialize the SYSTEM repository.

createSystemRepository

protected abstract Repository createSystemRepository()
                                              throws RepositoryException
Throws:
RepositoryException

getSystemRepository

public Repository getSystemRepository()
Gets the SYSTEM repository.


getNewRepositoryID

public String getNewRepositoryID(String baseName)
                          throws RepositoryException,
                                 RepositoryConfigException
Generates an ID for a new repository based on the specified base name. The base name may for example be a repository name entered by the user. The generated ID will contain a variant of this name that does not occur as a repository ID in this manager yet and is suitable for use as a file name (e.g. for the repository's data directory).

Parameters:
baseName - The String on which the returned ID should be based, must not be null.
Returns:
A new repository ID derived from the specified base name.
Throws:
RepositoryException
RepositoryConfigException

getRepositoryIDs

public Set<String> getRepositoryIDs()
                             throws RepositoryException
Throws:
RepositoryException

hasRepositoryConfig

public boolean hasRepositoryConfig(String repositoryID)
                            throws RepositoryException,
                                   RepositoryConfigException
Throws:
RepositoryException
RepositoryConfigException

getRepositoryConfig

public RepositoryConfig getRepositoryConfig(String repositoryID)
                                     throws RepositoryConfigException,
                                            RepositoryException
Throws:
RepositoryConfigException
RepositoryException

addRepositoryConfig

public void addRepositoryConfig(RepositoryConfig config)
                         throws RepositoryException,
                                RepositoryConfigException
Adds or updates the configuration of a repository to the manager's system repository. The system repository may already contain a configuration for a repository with the same ID as specified by config, in which case all previous configuration data for that repository will be cleared before the new configuration is added.

Parameters:
config - The repository configuration that should be added to or updated in the system repository.
Throws:
RepositoryException - If the manager failed to update it's system repository.
RepositoryConfigException - If the manager doesn't know how to update a configuration due to inconsistent configuration data in the system repository. For example, this happens when there are multiple existing configurations with the concerning ID.

removeRepositoryConfig

public boolean removeRepositoryConfig(String repositoryID)
                               throws RepositoryException,
                                      RepositoryConfigException
Removes the configuration for the specified repository from the manager's system repository if such a configuration is present. Returns true if the system repository actually contained the specified repository configuration.

Parameters:
repositoryID - The ID of the repository whose configuration needs to be removed.
Throws:
RepositoryException - If the manager failed to update it's system repository.
RepositoryConfigException - If the manager doesn't know how to remove a configuration due to inconsistent configuration data in the system repository. For example, this happens when there are multiple existing configurations with the concerning ID.

getRepository

public Repository getRepository(String id)
                         throws RepositoryConfigException,
                                RepositoryException
Gets the repository that is known by the specified ID from this manager.

Parameters:
id - A repository ID.
Returns:
A Repository object, or null if no repository was known for the specified ID.
Throws:
RepositoryConfigException - If no repository could be created due to invalid or incomplete configuration data.
RepositoryException

getInitializedRepositoryIDs

public Set<String> getInitializedRepositoryIDs()
Returns all inititalized repositories. This method returns fast as no lazy creation of repositories takes place.

Returns:
a collection containing the IDs of all initialized repositories.
See Also:
getRepositoryIDs()

getInitializedRepositories

public Collection<Repository> getInitializedRepositories()
Returns all inititalized repositories. This method returns fast as no lazy creation of repositories takes place.

Returns:
a set containing the initialized repositories.
See Also:
getAllRepositories()

getAllRepositories

public Collection<Repository> getAllRepositories()
                                          throws RepositoryConfigException,
                                                 RepositoryException
Returns all configured repositories. This may be an expensive operation as it initializes repositories that have not been initialized yet.

Returns:
The Set of all Repositories defined in the SystemRepository.
Throws:
RepositoryConfigException
RepositoryException
See Also:
getInitializedRepositories()

createRepository

protected abstract Repository createRepository(String id)
                                        throws RepositoryConfigException,
                                               RepositoryException
Creates and initializes the repository with the specified ID.

Parameters:
id - A repository ID.
Returns:
The created repository, or null if no such repository exists.
Throws:
RepositoryConfigException - If no repository could be created due to invalid or incomplete configuration data.
RepositoryException

getRepositoryInfo

public abstract RepositoryInfo getRepositoryInfo(String id)
                                          throws RepositoryException
Gets the repository that is known by the specified ID from this manager.

Parameters:
id - A repository ID.
Returns:
A Repository object, or null if no repository was known for the specified ID.
Throws:
RepositoryException - When not able to retrieve existing configurations

getAllRepositoryInfos

public Collection<RepositoryInfo> getAllRepositoryInfos()
                                                 throws RepositoryException
Throws:
RepositoryException

getAllUserRepositoryInfos

public Collection<RepositoryInfo> getAllUserRepositoryInfos()
                                                     throws RepositoryException
Throws:
RepositoryException

getAllRepositoryInfos

public abstract Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo)
                                                          throws RepositoryException
Parameters:
skipSystemRepo -
Throws:
RepositoryException - When not able to retrieve existing configurations

refresh

public void refresh()
Shuts down all initialized user repositories.

See Also:
shutDown()

shutDown

public void shutDown()
Shuts down all initialized repositories, including the SYSTEM repository.

See Also:
refresh()

cleanUpRepository

protected abstract void cleanUpRepository(String repositoryID)
                                   throws IOException
Clean up a removed repository. Note that the configuration for this repository is no longer present in the system repository.

Parameters:
repositoryID - the ID of the repository to clean up
Throws:
IOException


Copyright © 2001-2008 Aduna. All Rights Reserved.