use of org.springframework.beans.factory.annotation.Value in project hub-docker-inspector by blackducksoftware.
the class Config method init.
@PostConstruct
public void init() throws IllegalArgumentException, IllegalAccessException {
final Object configObject = this;
publicOptions = new ArrayList<>();
allKeys = new ArrayList<>();
optionsByKey = new HashMap<>();
optionsByFieldName = new HashMap<>();
for (final Field field : configObject.getClass().getDeclaredFields()) {
final Annotation[] declaredAnnotations = field.getDeclaredAnnotations();
if (declaredAnnotations.length > 0) {
for (final Annotation annotation : declaredAnnotations) {
if (annotation.annotationType().getName().equals(ValueDescription.class.getName())) {
logger.debug(String.format("ValueDescription annotated config object field: %s", field.getName()));
final String propMappingString = field.getAnnotation(Value.class).value();
final String propName = SpringValueUtils.springKeyFromValueAnnotation(propMappingString);
final Object fieldValueObject = field.get(configObject);
if (fieldValueObject == null) {
logger.warn(String.format("propName %s field is null", propName));
continue;
}
final String value = fieldValueObject.toString();
logger.trace(String.format("adding prop key %s [value: %s]", propName, value));
allKeys.add(propName);
final ValueDescription valueDescription = field.getAnnotation(ValueDescription.class);
final DockerInspectorOption opt = new DockerInspectorOption(propName, field.getName(), value, valueDescription.description(), field.getType(), valueDescription.defaultValue(), valueDescription.group(), valueDescription.deprecated());
optionsByKey.put(propName, opt);
logger.trace(String.format("adding field name %s to optionsByFieldName", field.getName()));
optionsByFieldName.put(field.getName(), opt);
if (!Config.GROUP_PRIVATE.equals(valueDescription.group())) {
publicOptions.add(opt);
} else {
logger.debug(String.format("private prop: propName: %s, fieldName: %s, group: %s, description: %s", propName, field.getName(), valueDescription.group(), valueDescription.description()));
}
}
}
}
}
}
use of org.springframework.beans.factory.annotation.Value in project nextprot-api by calipho-sib.
the class PepXServiceImpl method computePeptideUnicityStatus.
/**
* Computes a unicity value for each peptide: UNIQUE, PSEUDO_UNIQUE, NON_UNIQUE
* based on the response returned by pepx (a list of peptide - isoform matches)
* by using the PeptideUnicityService
* @param entries
* @param withVariants
* @return a map with key = peptide sequence, value = unicity value
*/
private Map<String, PeptideUnicity> computePeptideUnicityStatus(List<Entry> entries, boolean withVariants) {
Map<String, Set<String>> pepIsoSetMap = new HashMap<>();
entries.forEach(e -> {
e.getAnnotationsByCategory(AnnotationCategory.PEPX_VIRTUAL_ANNOTATION).stream().filter(a -> a.getVariant() == null || withVariants).forEach(a -> {
String pep = a.getCvTermName();
if (!pepIsoSetMap.containsKey(pep))
pepIsoSetMap.put(pep, new TreeSet<String>());
a.getTargetingIsoformsMap().values().forEach(i -> {
pepIsoSetMap.get(pep).add(i.getIsoformAccession());
});
});
});
Map<String, PeptideUnicity> pepUnicityMap = new HashMap<>();
pepIsoSetMap.entrySet().forEach(e -> {
String pep = e.getKey();
PeptideUnicity pu = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(e.getValue());
pepUnicityMap.put(pep, pu);
});
return pepUnicityMap;
}
use of org.springframework.beans.factory.annotation.Value in project nextprot-api by calipho-sib.
the class InstrumentationAspect method addArgumentsParameters.
private static StringBuilder addArgumentsParameters(StringBuilder sb, Object[] arguments, Annotation[][] annotations) {
for (int i = 0; i < arguments.length; i++) {
Annotation[] annots = annotations[i];
Value v = null;
for (Annotation a : annots) {
if (a.annotationType().equals(Value.class)) {
v = (Value) a;
break;
}
}
if (v == null) {
sb.append("arg" + (i + 1));
} else {
sb.append(v.value());
}
sb.append("=");
Object argument = arguments[i];
if (argument == null) {
sb.append("null");
} else if (argument instanceof KeyValueRepresentation) {
sb.append(((KeyValueRepresentation) argument).toKeyValueString());
} else if (argument instanceof Collection) {
sb.append(((Collection<?>) argument).size());
} else if (argument instanceof String || argument instanceof Long || argument instanceof Short || argument instanceof Integer) {
sb.append(argument);
} else {
sb.append("representation-unknown");
}
sb.append(";");
}
return sb;
}
use of org.springframework.beans.factory.annotation.Value in project alien4cloud by alien4cloud.
the class CsarFileRepository method setRootPath.
@Required
@Value("${directories.alien}/${directories.csar_repository}")
public void setRootPath(String path) {
this.rootPath = Paths.get(path).toAbsolutePath();
if (!Files.isDirectory(rootPath)) {
try {
Files.createDirectories(rootPath);
log.info("Alien Repository folder set to " + rootPath.toAbsolutePath());
} catch (IOException e) {
throw new CSARDirectoryCreationFailureException("Error while trying to create the CSAR repository <" + rootPath.toString() + ">. " + e.getMessage(), e);
}
} else {
log.info("Alien Repository folder already created! " + rootPath.toAbsolutePath());
}
}
use of org.springframework.beans.factory.annotation.Value in project spring-security by spring-projects.
the class OAuth2ResourceServerSpecTests method getWhenUsingCustomAuthenticationManagerInLambdaThenUsesItAccordingly.
@Test
public void getWhenUsingCustomAuthenticationManagerInLambdaThenUsesItAccordingly() {
this.spring.register(CustomAuthenticationManagerInLambdaConfig.class).autowire();
ReactiveAuthenticationManager authenticationManager = this.spring.getContext().getBean(ReactiveAuthenticationManager.class);
given(authenticationManager.authenticate(any(Authentication.class))).willReturn(Mono.error(new OAuth2AuthenticationException(new OAuth2Error("mock-failure"))));
// @formatter:off
this.client.get().headers((headers) -> headers.setBearerAuth(this.messageReadToken)).exchange().expectStatus().isUnauthorized().expectHeader().value(HttpHeaders.WWW_AUTHENTICATE, startsWith("Bearer error=\"mock-failure\""));
// @formatter:on
}
Aggregations