use of org.springframework.beans.factory.annotation.Qualifier in project uPortal by Jasig.
the class PersonDirectoryConfiguration method getPersonAttributeDao.
/**
* Overrides DAO acts as the root, it handles incorporating attributes from the attribute
* swapper utility, wraps the caching DAO
*/
@Bean(name = "personAttributeDao")
@Qualifier("personAttributeDao")
public IPersonAttributeDao getPersonAttributeDao() {
final PortalRootPersonAttributeDao rslt = new PortalRootPersonAttributeDao();
rslt.setDelegatePersonAttributeDao(getRequestAttributeMergingDao());
rslt.setAttributeOverridesMap(getSessionAttributesOverridesMap());
return rslt;
}
use of org.springframework.beans.factory.annotation.Qualifier in project uPortal by Jasig.
the class PersonDirectoryConfiguration method getUPortalAccountUserSource.
/**
* Looks in the local person-directory data. This is only used for portal-local users such as
* fragment owners All attributes are searchable via this configuration, results are cached by
* the underlying DAO.
*/
@Bean(name = "uPortalAccountUserSource")
@Qualifier("uPortalInternal")
public IPersonAttributeDao getUPortalAccountUserSource() {
final LocalAccountPersonAttributeDao rslt = new LocalAccountPersonAttributeDao();
rslt.setLocalAccountDao(localAccountDao);
rslt.setUsernameAttributeProvider(getUsernameAttributeProvider());
final Map<String, String> queryAttributeMapping = new HashMap<>();
queryAttributeMapping.put(USERNAME_ATTRIBUTE, USERNAME_ATTRIBUTE);
queryAttributeMapping.put(GIVEN_NAME_ATTRIBUTE, GIVEN_NAME_ATTRIBUTE);
queryAttributeMapping.put(SIR_NAME_ATTRIBUTE, SIR_NAME_ATTRIBUTE);
rslt.setQueryAttributeMapping(queryAttributeMapping);
final Map<String, Set<String>> resultAttributeMapping = new HashMap<>();
resultAttributeMapping.put(USERNAME_ATTRIBUTE, Stream.of(USERNAME_ATTRIBUTE, UID_ATTRIBUTE, USER_LOGIN_ID_ATTRIBUTE).collect(Collectors.toSet()));
rslt.setResultAttributeMapping(resultAttributeMapping);
return rslt;
}
use of org.springframework.beans.factory.annotation.Qualifier in project uPortal by Jasig.
the class PersonDirectoryConfiguration method getMergingPersonAttributeDao.
@Bean(name = "mergingPersonAttributeDao")
@Qualifier("uPortalInternal")
public IPersonAttributeDao getMergingPersonAttributeDao() {
final MergingPersonAttributeDaoImpl rslt = new MergingPersonAttributeDaoImpl();
rslt.setUsernameAttributeProvider(getUsernameAttributeProvider());
/*
* This is a "first one wins" strategy. I.e. the first value found for any given result
* attribute will be assigned to the user. Different values found in subsequently queried
* attribute sources will be ignored. Suitable if uP-local attributes should always take
* precedence.
*
* Other options (all in the same package):
* - MultivaluedAttributeMerger - Collects values from all DAOs into lists (does not
* filter out duplicate values, though)
* - ReplacingAttributeAdder - "Last one wins" strategy. I.e. the opposite of
* NoncollidingAttributeAdder.
*/
rslt.setMerger(new NoncollidingAttributeAdder());
return rslt;
}
use of org.springframework.beans.factory.annotation.Qualifier in project CzechIdMng by bcvsolutions.
the class ClusteredEhCacheConfiguration method ehCacheManager.
/**
* Defines clustered {@link CacheManager} using Terracotta server.
*
* @param terracotaUrl a list of IP addresses with ports (IP_ADDR:PORT)
* @param terracotaResourceName name of server resource to connect
* @param terracotaResourcePoolName name od server resource pool name
* @param terracotaResourcePoolSize size of server resource pool in MB
* @param idMCacheConfigurations a list of {@link IdMCacheConfiguration} defined in container
* @return CacheManager with distributed capabilities
*/
@Bean
@Qualifier("jCacheManager")
@ConditionalOnProperty(value = TERRACOTA_URL_PROPERTY)
@ConditionalOnMissingBean
public CacheManager ehCacheManager(@Value("${" + TERRACOTA_URL_PROPERTY + "}") String terracotaUrl, @Value("${" + TERRACOTA_RESOURCE_NAME_PROPERTY + "}") String terracotaResourceName, @Value("${" + TERRACOTA_RESOURCE_POOL_NAME_PROPERTY + "}") String terracotaResourcePoolName, @Value("${" + TERRACOTA_RESOURCE_POOL_SIZE_PROPERTY + "}") int terracotaResourcePoolSize, @Autowired List<IdMCacheConfiguration> idMCacheConfigurations) {
CacheManagerBuilder<PersistentCacheManager> clusteredCacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder().with(ClusteringServiceConfigurationBuilder.cluster(parseServerAddresses(terracotaUrl), "default").autoCreate(server -> server.defaultServerResource(terracotaResourceName).resourcePool(terracotaResourcePoolName, terracotaResourcePoolSize, MemoryUnit.MB, terracotaResourceName))).withSerializer(CacheObjectWrapper.class, CacheWrapperSerializer.class).withSerializer(SerializableCacheObjectWrapper.class, SerializableCacheWrapperSerializer.class);
PersistentCacheManager cacheManager = clusteredCacheManagerBuilder.build(true);
// create caches using IdMCacheConfiguration instances
if (!CollectionUtils.isEmpty(idMCacheConfigurations)) {
for (IdMCacheConfiguration config : idMCacheConfigurations) {
cacheManager.createCache(config.getCacheName(), toConcreteConfiguration(config, terracotaResourcePoolName));
}
}
// get CacheManager (Jcache) with above updated configuration
final EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
return ehcacheCachingProvider.getCacheManager(ehcacheCachingProvider.getDefaultURI(), cacheManager.getRuntimeConfiguration());
}
use of org.springframework.beans.factory.annotation.Qualifier in project CzechIdMng by bcvsolutions.
the class InMemoryEhCacheConfiguration method ehCacheManager.
/**
* Defines in-memory cache manager.
*
* @param idMCacheConfigurations {@link List} of {@link IdMCacheConfiguration} defined in container
* @return CacheManager with on-heap capabilities
*/
@Bean
@Qualifier("jCacheManager")
@ConditionalOnMissingBean
public CacheManager ehCacheManager(@Autowired List<IdMCacheConfiguration> idMCacheConfigurations) {
CacheManagerBuilder<?> localCacheManagerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
if (!CollectionUtils.isEmpty(idMCacheConfigurations)) {
for (IdMCacheConfiguration config : idMCacheConfigurations) {
localCacheManagerBuilder = localCacheManagerBuilder.withCache(config.getCacheName(), toConcreteConfiguration(config));
}
}
// get CacheManager (Jcache) with above updated configuration
final EhcacheCachingProvider ehcacheCachingProvider = (EhcacheCachingProvider) Caching.getCachingProvider();
return ehcacheCachingProvider.getCacheManager(ehcacheCachingProvider.getDefaultURI(), localCacheManagerBuilder.build(true).getRuntimeConfiguration());
}
Aggregations