Search in sources :

Example 16 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project ariADDna by StnetixDevTeam.

the class JPAConfiguration method entityManager.

@Bean
@Qualifier(value = "entityManager")
public EntityManager entityManager(EntityManagerFactory entityManagerFactory) {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    LOGGER.info("Entity manager was created in entityManager() bean with name: {} ", entityManager.toString());
    return entityManager;
}
Also used : EntityManager(javax.persistence.EntityManager) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 17 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project nakadi by zalando.

the class NakadiConfig method defaultStorage.

@Bean
@Qualifier("default_storage")
public DefaultStorage defaultStorage(final StorageDbRepository storageDbRepository, final Environment environment, final ZooKeeperHolder zooKeeperHolder) throws InternalNakadiException {
    final String storageId = getStorageId(zooKeeperHolder, environment);
    final Optional<Storage> storageOpt = storageDbRepository.getStorage(storageId);
    if (!storageOpt.isPresent()) {
        LOGGER.info("Creating timelines storage `{}` from defaults", storageId);
        final Storage storage = new Storage();
        storage.setId(storageId);
        storage.setType(Storage.Type.KAFKA);
        storage.setConfiguration(new Storage.KafkaConfiguration(environment.getProperty("nakadi.zookeeper.exhibitor.brokers"), Integer.valueOf(environment.getProperty("nakadi.zookeeper.exhibitor.port", "0")), environment.getProperty("nakadi.zookeeper.brokers"), environment.getProperty("nakadi.zookeeper.kafkaNamespace", "")));
        try {
            storageDbRepository.createStorage(storage);
        } catch (final DuplicatedStorageException e) {
            LOGGER.info("Creation of default storage failed: {}", e.getMessage());
        }
        return new DefaultStorage(storage);
    } else {
        return new DefaultStorage(storageOpt.get());
    }
}
Also used : DefaultStorage(org.zalando.nakadi.domain.DefaultStorage) Storage(org.zalando.nakadi.domain.Storage) DefaultStorage(org.zalando.nakadi.domain.DefaultStorage) DuplicatedStorageException(org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Example 18 with Qualifier

use of org.springframework.beans.factory.annotation.Qualifier in project spring-cloud-netflix by spring-cloud.

the class TestArchaiusExternalConfiguration method createDynamicConfiguration.

@Bean
@Qualifier("dynamicConfiguration")
public AbstractConfiguration createDynamicConfiguration() {
    ConcurrentMapConfiguration config = new ConcurrentMapConfiguration();
    config.addProperty("db.property", "this is a db property");
    config.addProperty("db.second.property", "this is another db property");
    return config;
}
Also used : ConcurrentMapConfiguration(com.netflix.config.ConcurrentMapConfiguration) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Bean(org.springframework.context.annotation.Bean)

Example 19 with Qualifier

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

the class PageableHandlerMethodArgumentResolver method getParameterNameToUse.

/**
 * Returns the name of the request parameter to find the {@link Pageable} information in. Inspects the given
 * {@link MethodParameter} for {@link Qualifier} present and prefixes the given source parameter name with it.
 *
 * @param source the basic parameter name.
 * @param parameter the {@link MethodParameter} potentially qualified.
 * @return the name of the request parameter.
 */
protected String getParameterNameToUse(String source, @Nullable MethodParameter parameter) {
    StringBuilder builder = new StringBuilder(prefix);
    Qualifier qualifier = parameter == null ? null : parameter.getParameterAnnotation(Qualifier.class);
    if (qualifier != null) {
        builder.append(qualifier.value());
        builder.append(qualifierDelimiter);
    }
    return builder.append(source).toString();
}
Also used : Qualifier(org.springframework.beans.factory.annotation.Qualifier)

Example 20 with Qualifier

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

the class PagedResourcesAssemblerArgumentResolver method findMatchingPageableParameter.

/**
 * Returns finds the {@link MethodParameter} for a {@link Pageable} instance matching the given
 * {@link MethodParameter} requesting a {@link PagedResourcesAssembler}.
 *
 * @param parameter must not be {@literal null}.
 * @return
 */
@Nullable
private static MethodParameter findMatchingPageableParameter(MethodParameter parameter) {
    MethodParameters parameters = new MethodParameters(parameter.getMethod());
    List<MethodParameter> pageableParameters = parameters.getParametersOfType(Pageable.class);
    Qualifier assemblerQualifier = parameter.getParameterAnnotation(Qualifier.class);
    if (pageableParameters.isEmpty()) {
        return null;
    }
    if (pageableParameters.size() == 1) {
        MethodParameter pageableParameter = pageableParameters.get(0);
        MethodParameter matchingParameter = returnIfQualifiersMatch(pageableParameter, assemblerQualifier);
        if (matchingParameter == null) {
            LOGGER.info(SUPERFLOUS_QUALIFIER, PagedResourcesAssembler.class.getSimpleName(), Pageable.class.getName());
        }
        return pageableParameter;
    }
    if (assemblerQualifier == null) {
        throw new IllegalStateException(PARAMETER_AMBIGUITY);
    }
    for (MethodParameter pageableParameter : pageableParameters) {
        MethodParameter matchingParameter = returnIfQualifiersMatch(pageableParameter, assemblerQualifier);
        if (matchingParameter != null) {
            return matchingParameter;
        }
    }
    throw new IllegalStateException(PARAMETER_AMBIGUITY);
}
Also used : Pageable(org.springframework.data.domain.Pageable) Qualifier(org.springframework.beans.factory.annotation.Qualifier) MethodParameters(org.springframework.hateoas.core.MethodParameters) MethodParameter(org.springframework.core.MethodParameter) Nullable(org.springframework.lang.Nullable)

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