Search in sources :

Example 21 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project spring-data-commons by spring-projects.

the class SortHandlerMethodArgumentResolver method getSortParameter.

/**
 * Returns the sort parameter to be looked up from the request. Potentially applies qualifiers to it.
 *
 * @param parameter can be {@literal null}.
 * @return
 */
protected String getSortParameter(@Nullable MethodParameter parameter) {
    StringBuilder builder = new StringBuilder();
    Qualifier qualifier = parameter != null ? parameter.getParameterAnnotation(Qualifier.class) : null;
    if (qualifier != null) {
        builder.append(qualifier.value()).append(qualifierDelimiter);
    }
    return builder.append(sortParameter).toString();
}
Also used : Qualifier(org.springframework.beans.factory.annotation.Qualifier)

Example 22 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project spring-data-commons by spring-projects.

the class SpringDataAnnotationUtils method assertQualifiersFor.

/**
 * Asserts that every {@link Pageable} parameter of the given parameters carries an {@link Qualifier} annotation to
 * distinguish them from each other.
 *
 * @param parameterTypes must not be {@literal null}.
 * @param annotations must not be {@literal null}.
 */
public static void assertQualifiersFor(Class<?>[] parameterTypes, Annotation[][] annotations) {
    Set<String> values = new HashSet<>();
    for (int i = 0; i < annotations.length; i++) {
        if (Pageable.class.equals(parameterTypes[i])) {
            Qualifier qualifier = findAnnotation(annotations[i]);
            if (null == qualifier) {
                throw new IllegalStateException("Ambiguous Pageable arguments in handler method. If you use multiple parameters of type Pageable you need to qualify them with @Qualifier");
            }
            if (values.contains(qualifier.value())) {
                throw new IllegalStateException("Values of the user Qualifiers must be unique!");
            }
            values.add(qualifier.value());
        }
    }
}
Also used : Qualifier(org.springframework.beans.factory.annotation.Qualifier) HashSet(java.util.HashSet)

Example 23 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project cas by apereo.

the class HazelcastTicketRegistryConfiguration method casTicketRegistryHazelcastInstance.

@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean(name = "casTicketRegistryHazelcastInstance")
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public HazelcastInstance casTicketRegistryHazelcastInstance(@Qualifier(TicketCatalog.BEAN_NAME) final TicketCatalog ticketCatalog, final CasConfigurationProperties casProperties) {
    val hz = casProperties.getTicket().getRegistry().getHazelcast();
    LOGGER.debug("Creating Hazelcast instance for members [{}]", hz.getCluster().getNetwork().getMembers());
    val hazelcastInstance = HazelcastInstanceFactory.getOrCreateHazelcastInstance(HazelcastConfigurationFactory.build(hz));
    ticketCatalog.findAll().stream().map(TicketDefinition::getProperties).peek(p -> LOGGER.debug("Created Hazelcast map configuration for [{}]", p)).map(p -> HazelcastConfigurationFactory.buildMapConfig(hz, p.getStorageName(), p.getStorageTimeout())).forEach(map -> HazelcastConfigurationFactory.setConfigMap(map, hazelcastInstance.getConfig()));
    return hazelcastInstance;
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) TicketRegistryCleaner(org.apereo.cas.ticket.registry.TicketRegistryCleaner) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) HazelcastInstanceFactory(com.hazelcast.instance.impl.HazelcastInstanceFactory) lombok.val(lombok.val) ScopedProxyMode(org.springframework.context.annotation.ScopedProxyMode) HazelcastConfigurationFactory(org.apereo.cas.hz.HazelcastConfigurationFactory) CoreTicketUtils(org.apereo.cas.util.CoreTicketUtils) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) NoOpTicketRegistryCleaner(org.apereo.cas.ticket.registry.NoOpTicketRegistryCleaner) Configuration(org.springframework.context.annotation.Configuration) TicketDefinition(org.apereo.cas.ticket.TicketDefinition) Slf4j(lombok.extern.slf4j.Slf4j) TicketRegistry(org.apereo.cas.ticket.registry.TicketRegistry) HazelcastTicketRegistry(org.apereo.cas.ticket.registry.HazelcastTicketRegistry) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean) TicketCatalog(org.apereo.cas.ticket.TicketCatalog) 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)

Example 24 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project cas by apereo.

the class CasSamlServiceProvidersConfiguration method coreSamlServiceProvidersInitializingBean.

@Bean
public InitializingBean coreSamlServiceProvidersInitializingBean(@Qualifier(ServicesManager.BEAN_NAME) final ServicesManager servicesManager, final CasConfigurationProperties casProperties, @Qualifier(SamlRegisteredServiceCachingMetadataResolver.DEFAULT_BEAN_NAME) final SamlRegisteredServiceCachingMetadataResolver samlRegisteredServiceCachingMetadataResolver) {
    return () -> {
        val preloadMetadata = (Function<SamlRegisteredService, Void>) service -> {
            LOGGER.info("Launching background thread to load the metadata. This might take a while...");
            new Thread(() -> {
                LOGGER.debug("Loading metadata at [{}]...", service.getMetadataLocation());
                samlRegisteredServiceCachingMetadataResolver.resolve(service, new CriteriaSet());
            }, getClass().getSimpleName()).start();
            return null;
        };
        val samlSp = casProperties.getSamlSp();
        processSamlServiceProvider(samlSp.getAcademicHealthPlans(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAcademicWorks(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAdobeCloud(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAmazon(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAppDynamics(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getArcGIS(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getArmsSoftware(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getAsana(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBenefitFocus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBlackBaud(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBox(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getBynder(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCccco(), servicesManager, samlRegisteredServiceCachingMetadataResolver, preloadMetadata);
        processSamlServiceProvider(samlSp.getCherWell(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getConcurSolutions(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getConfluence(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCraniumCafe(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getCrashPlan(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getDocuSign(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getDropbox(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEasyIep(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEgnyte(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEmma(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEverBridge(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getEvernote(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getFamis(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGartner(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGitlab(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getGiveCampus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getInCommon(), servicesManager, samlRegisteredServiceCachingMetadataResolver, preloadMetadata);
        processSamlServiceProvider(samlSp.getInfiniteCampus(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getJira(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNeoGov(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNetPartner(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getNewRelic(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getOffice365(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getOpenAthens(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getPagerDuty(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getPollEverywhere(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getQualtrics(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getRocketChat(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSafariOnline(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSalesforce(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSaManage(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSansSth(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getServiceNow(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSlack(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getTopHat(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSserca(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getSymplicity(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getTableau(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWarpWire(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWebAdvisor(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWebex(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getWorkday(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getYuja(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZendesk(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZimbra(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
        processSamlServiceProvider(samlSp.getZoom(), servicesManager, samlRegisteredServiceCachingMetadataResolver);
    };
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) SamlRegisteredServiceCachingMetadataResolver(org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver) lombok.val(lombok.val) SamlSPUtils(org.apereo.cas.util.SamlSPUtils) Function(java.util.function.Function) InitializingBean(org.springframework.beans.factory.InitializingBean) Configuration(org.springframework.context.annotation.Configuration) Slf4j(lombok.extern.slf4j.Slf4j) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) AbstractSamlSPProperties(org.apereo.cas.configuration.model.support.saml.sps.AbstractSamlSPProperties) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) Bean(org.springframework.context.annotation.Bean) ServicesManager(org.apereo.cas.services.ServicesManager) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) InitializingBean(org.springframework.beans.factory.InitializingBean) Bean(org.springframework.context.annotation.Bean)

Example 25 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project cas by apereo.

the class MongoDbMonitoringConfiguration method mongoHealthIndicator.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnEnabledHealthIndicator("mongoHealthIndicator")
@ConditionalOnMissingBean(name = "mongoHealthIndicator")
public HealthIndicator mongoHealthIndicator(final CasConfigurationProperties casProperties, @Qualifier("mongoHealthIndicatorTemplate") final BeanContainer<CasMongoOperations> mongoHealthIndicatorTemplate) {
    val warn = casProperties.getMonitor().getWarn();
    val results = mongoHealthIndicatorTemplate.toList().stream().map(template -> new MongoDbHealthIndicator(template, warn.getEvictionThreshold(), warn.getThreshold())).collect(Collectors.toList());
    return new CompositeHealthIndicator(results);
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) ConditionalOnEnabledHealthIndicator(org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MongoDbHealthIndicator(org.apereo.cas.monitor.MongoDbHealthIndicator) MongoDbConnectionFactory(org.apereo.cas.mongo.MongoDbConnectionFactory) lombok.val(lombok.val) ScopedProxyMode(org.springframework.context.annotation.ScopedProxyMode) CasMongoOperations(org.apereo.cas.mongo.CasMongoOperations) HealthIndicator(org.springframework.boot.actuate.health.HealthIndicator) Collectors(java.util.stream.Collectors) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Configuration(org.springframework.context.annotation.Configuration) BeanContainer(org.apereo.cas.util.spring.beans.BeanContainer) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) CasSSLContext(org.apereo.cas.authentication.CasSSLContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CompositeHealthIndicator(org.apereo.cas.monitor.CompositeHealthIndicator) Bean(org.springframework.context.annotation.Bean) CompositeHealthIndicator(org.apereo.cas.monitor.CompositeHealthIndicator) MongoDbHealthIndicator(org.apereo.cas.monitor.MongoDbHealthIndicator) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnEnabledHealthIndicator(org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Qualifier (org.springframework.beans.factory.annotation.Qualifier)66 Bean (org.springframework.context.annotation.Bean)59 RmiProxyFactoryBean (org.springframework.remoting.rmi.RmiProxyFactoryBean)18 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)12 Configuration (org.springframework.context.annotation.Configuration)7 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)6 lombok.val (lombok.val)5 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)5 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)5 RequestResponseClientConfigProperties (org.eclipse.hono.client.RequestResponseClientConfigProperties)4 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)4 ScopedProxyMode (org.springframework.context.annotation.ScopedProxyMode)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 ClientFactoryBuilder (com.linecorp.armeria.client.ClientFactoryBuilder)2 IdMCacheConfiguration (eu.bcvsolutions.idm.core.api.config.cache.IdMCacheConfiguration)2 Supplier (java.util.function.Supplier)2