use of org.eclipse.rdf4j.http.client.HttpClientDependent 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;
}
Aggregations