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;
}
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());
}
}
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;
}
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();
}
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);
}
Aggregations