Search in sources :

Example 1 with RepositoryImplConfig

use of org.eclipse.rdf4j.repository.config.RepositoryImplConfig in project rdf4j by eclipse.

the class LocalRepositoryManager method createRepositoryStack.

/**
 * Creates the stack of Repository objects for the repository represented by the specified
 * {@link org.eclipse.rdf4j.repository.config.RepositoryImplConfig}. Uses a
 * {@link org.eclipse.rdf4j.repository.config.RepositoryFactory} to create the repository and initialize
 * it.
 *
 * @param config
 *        The node representing the to-be-created repository in the configuration.
 * @return The created repository, or <tt>null</tt> if no such repository exists.
 * @throws RepositoryConfigException
 *         If no repository could be created due to invalid or incomplete configuration data.
 */
private Repository createRepositoryStack(RepositoryImplConfig config) throws RepositoryConfigException {
    RepositoryFactory factory = RepositoryRegistry.getInstance().get(config.getType()).orElseThrow(() -> new RepositoryConfigException("Unsupported repository type: " + config.getType()));
    Repository repository = factory.getRepository(config);
    if (repository instanceof RepositoryResolverClient) {
        ((RepositoryResolverClient) repository).setRepositoryResolver(this);
    }
    if (repository instanceof FederatedServiceResolverClient) {
        ((FederatedServiceResolverClient) repository).setFederatedServiceResolver(getFederatedServiceResolver());
    }
    if (repository instanceof SessionManagerDependent) {
        ((SessionManagerDependent) repository).setHttpClientSessionManager(client);
    } else if (repository instanceof HttpClientDependent) {
        ((HttpClientDependent) repository).setHttpClient(getHttpClient());
    }
    if (config instanceof DelegatingRepositoryImplConfig) {
        RepositoryImplConfig delegateConfig = ((DelegatingRepositoryImplConfig) config).getDelegate();
        Repository delegate = createRepositoryStack(delegateConfig);
        try {
            ((DelegatingRepository) repository).setDelegate(delegate);
        } catch (ClassCastException e) {
            throw new RepositoryConfigException("Delegate specified for repository that is not a DelegatingRepository: " + delegate.getClass(), e);
        }
    }
    return repository;
}
Also used : Repository(org.eclipse.rdf4j.repository.Repository) DelegatingRepository(org.eclipse.rdf4j.repository.DelegatingRepository) RepositoryImplConfig(org.eclipse.rdf4j.repository.config.RepositoryImplConfig) DelegatingRepositoryImplConfig(org.eclipse.rdf4j.repository.config.DelegatingRepositoryImplConfig) DelegatingRepositoryImplConfig(org.eclipse.rdf4j.repository.config.DelegatingRepositoryImplConfig) RepositoryFactory(org.eclipse.rdf4j.repository.config.RepositoryFactory) FederatedServiceResolverClient(org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient) SessionManagerDependent(org.eclipse.rdf4j.http.client.SessionManagerDependent) DelegatingRepository(org.eclipse.rdf4j.repository.DelegatingRepository) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException) RepositoryResolverClient(org.eclipse.rdf4j.repository.RepositoryResolverClient) HttpClientDependent(org.eclipse.rdf4j.http.client.HttpClientDependent)

Example 2 with RepositoryImplConfig

use of org.eclipse.rdf4j.repository.config.RepositoryImplConfig in project rdf4j by eclipse.

the class SystemRepository method createDelegate.

/*---------*
	 * Methods *
	 *---------*/
private Repository createDelegate() {
    RepositoryConfig repoConfig = getSystemConfig();
    if (repoConfig == null) {
        throw new RepositoryConfigException("Could not find SYSTEM configuration");
    }
    repoConfig.validate();
    RepositoryImplConfig config = repoConfig.getRepositoryImplConfig();
    RepositoryFactory factory = RepositoryRegistry.getInstance().get(config.getType()).orElseThrow(() -> new RepositoryConfigException("Repository type not in classpath: " + config.getType()));
    return factory.getRepository(config);
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryImplConfig(org.eclipse.rdf4j.repository.config.RepositoryImplConfig) RepositoryFactory(org.eclipse.rdf4j.repository.config.RepositoryFactory) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Aggregations

RepositoryConfigException (org.eclipse.rdf4j.repository.config.RepositoryConfigException)2 RepositoryFactory (org.eclipse.rdf4j.repository.config.RepositoryFactory)2 RepositoryImplConfig (org.eclipse.rdf4j.repository.config.RepositoryImplConfig)2 HttpClientDependent (org.eclipse.rdf4j.http.client.HttpClientDependent)1 SessionManagerDependent (org.eclipse.rdf4j.http.client.SessionManagerDependent)1 FederatedServiceResolverClient (org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient)1 DelegatingRepository (org.eclipse.rdf4j.repository.DelegatingRepository)1 Repository (org.eclipse.rdf4j.repository.Repository)1 RepositoryResolverClient (org.eclipse.rdf4j.repository.RepositoryResolverClient)1 DelegatingRepositoryImplConfig (org.eclipse.rdf4j.repository.config.DelegatingRepositoryImplConfig)1 RepositoryConfig (org.eclipse.rdf4j.repository.config.RepositoryConfig)1