use of org.apereo.cas.services.GitServiceRegistry in project cas by apereo.
the class GitServiceRegistryConfiguration method gitServiceRegistry.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "gitServiceRegistry")
public ServiceRegistry gitServiceRegistry(final CasConfigurationProperties casProperties, final ObjectProvider<List<ServiceRegistryListener>> serviceRegistryListeners, final ConfigurableApplicationContext applicationContext, @Qualifier("gitServiceRegistryRepositoryInstance") final GitRepository gitServiceRegistryRepositoryInstance, @Qualifier("registeredServiceResourceNamingStrategy") final RegisteredServiceResourceNamingStrategy resourceNamingStrategy) {
return BeanSupplier.of(ServiceRegistry.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
val properties = casProperties.getServiceRegistry().getGit();
val locators = new ArrayList<GitRepositoryRegisteredServiceLocator>();
if (properties.isGroupByType()) {
locators.add(new TypeAwareGitRepositoryRegisteredServiceLocator(resourceNamingStrategy, gitServiceRegistryRepositoryInstance.getRepositoryDirectory(), properties));
}
locators.add(new DefaultGitRepositoryRegisteredServiceLocator(resourceNamingStrategy, gitServiceRegistryRepositoryInstance.getRepositoryDirectory(), properties));
return new GitServiceRegistry(applicationContext, gitServiceRegistryRepositoryInstance, CollectionUtils.wrapList(new RegisteredServiceJsonSerializer(), new RegisteredServiceYamlSerializer()), properties.isPushChanges(), properties.getRootDirectory(), Optional.ofNullable(serviceRegistryListeners.getIfAvailable()).orElseGet(ArrayList::new), locators);
}).otherwiseProxy().get();
}
Aggregations