Search in sources :

Example 1 with GitServiceRegistry

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();
}
Also used : lombok.val(lombok.val) TypeAwareGitRepositoryRegisteredServiceLocator(org.apereo.cas.services.locator.TypeAwareGitRepositoryRegisteredServiceLocator) GitServiceRegistry(org.apereo.cas.services.GitServiceRegistry) RegisteredServiceJsonSerializer(org.apereo.cas.services.util.RegisteredServiceJsonSerializer) ArrayList(java.util.ArrayList) RegisteredServiceYamlSerializer(org.apereo.cas.services.util.RegisteredServiceYamlSerializer) DefaultGitRepositoryRegisteredServiceLocator(org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ArrayList (java.util.ArrayList)1 lombok.val (lombok.val)1 GitServiceRegistry (org.apereo.cas.services.GitServiceRegistry)1 DefaultGitRepositoryRegisteredServiceLocator (org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator)1 TypeAwareGitRepositoryRegisteredServiceLocator (org.apereo.cas.services.locator.TypeAwareGitRepositoryRegisteredServiceLocator)1 RegisteredServiceJsonSerializer (org.apereo.cas.services.util.RegisteredServiceJsonSerializer)1 RegisteredServiceYamlSerializer (org.apereo.cas.services.util.RegisteredServiceYamlSerializer)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1