use of com.microsoft.azure.gradle.functions.bindings.BaseBinding in project azure-gradle-plugins by lenala.
the class AnnotationHandlerImpl method patchStorageBinding.
private void patchStorageBinding(final Method method, final List<BaseBinding> bindings) {
final Optional<Annotation> storageAccount = Arrays.stream(method.getAnnotations()).filter(a -> a instanceof StorageAccount).findFirst();
if (storageAccount.isPresent()) {
logger.quiet("StorageAccount annotation found.");
final String connectionString = ((StorageAccount) storageAccount.get()).value();
bindings.stream().forEach(b -> {
if (b instanceof StorageBaseBinding) {
final StorageBaseBinding sb = (StorageBaseBinding) b;
// Override storage bindings with empty connection
if (StringUtils.isEmpty(sb.getConnection())) {
sb.setConnection(connectionString);
}
}
});
} else {
logger.quiet("No StorageAccount annotation found.");
}
}
use of com.microsoft.azure.gradle.functions.bindings.BaseBinding in project azure-gradle-plugins by lenala.
the class AnnotationHandlerImpl method generateConfiguration.
@Override
public FunctionConfiguration generateConfiguration(final Method method) {
final FunctionConfiguration config = new FunctionConfiguration();
final List<BaseBinding> bindings = config.getBindings();
processParameterAnnotations(method, bindings);
processMethodAnnotations(method, bindings);
patchStorageBinding(method, bindings);
config.setEntryPoint(method.getDeclaringClass().getCanonicalName() + "." + method.getName());
return config;
}
use of com.microsoft.azure.gradle.functions.bindings.BaseBinding in project azure-gradle-plugins by lenala.
the class AnnotationHandlerImpl method parseAnnotations.
private List<BaseBinding> parseAnnotations(Supplier<Annotation[]> annotationProvider, Function<Annotation, BaseBinding> annotationParser) {
final List<BaseBinding> bindings = new ArrayList<>();
for (final Annotation annotation : annotationProvider.get()) {
final BaseBinding binding = annotationParser.apply(annotation);
if (binding != null) {
logger.quiet("Adding binding: " + binding.toString());
bindings.add(binding);
}
}
return bindings;
}
Aggregations