This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"howMany": 200, | |
"millisBetweenNumbers": 1000 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: flow | |
name: producer-consumer | |
input: | |
- name: howMany | |
- name: millisBetweenNumbers | |
output: | |
- name: double-value | |
target: ${consumer.output.output} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: micropipe | |
name: simple-consumer | |
image: "simple-consumer:latest" | |
inputMapping: | |
baseCmd: java -jar /usr/bin/simple-consumer-1.0-SNAPSHOT.jar | |
parameters: | |
- name: source | |
internalName: --source | |
optional: false | |
repeatable: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type: micropipe | |
name: slow-printer | |
image: "slow-printer:latest" | |
inputMapping: | |
baseCmd: java -jar /usr/bin/slow-printer-1.0-SNAPSHOT.jar | |
parameters: | |
- name: howMany | |
internalName: --howMany | |
- name: millisBetweenNumbers | |
internalName: --millisBetweenNumbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyFramework framework = MyFramework.builder() | |
// initialization code here | |
.build(); | |
framework.init(Executors.newFixedThreadPool(20)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a reference to the "handle" method | |
Method handle = handlerType.getDeclaredMethod("handle", | |
new Class<?>[] { | |
ScanContext.class, FrameworkAnnotationContext.class | |
}); | |
// Create a FrameworkAnnotationContext instance by passing the annotation to process, | |
// the instance being scanned and the method where the annotation is placed | |
FrameworkAnnotationContext<Annotation> annotationContext = new FrameworkAnnotationContext<>(annotation, instance, m); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the handler type from the @Handler annotation | |
Class<? extends AnnotationHandler> handlerType = annotation.annotationType().getAnnotation(Handler.class).value(); | |
// Get and invoke the only constructor (which needs to be an empty one, unless you need a more complex behavior) | |
AnnotationHandler handler = (AnnotationHandler) Stream.of(handlerType.getConstructors()) | |
.findFirst() | |
.get() | |
.newInstance(new Object[0]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Annotation> annotations = Stream.of(m.getDeclaredAnnotations()) | |
.filter(annotation -> annotation.annotationType().isAnnotationPresent(Handler.class)) | |
.collect(Collectors.toList()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetMappingHandler implements AnnotationHandler<GetMapping> { | |
@Override | |
public void handle(ScanContext scanContext, FrameworkAnnotationContext<GetMapping> annotationContext) { | |
String endpoint = annotationContext.getAnnotation().value(); | |
Method m = (Method) annotationContext.getAnnotatedElement(); | |
Object o = annotationContext.getInstance(); | |
scanContext.createMapping(endpoint, m, o); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyAnnotationHandler implements AnnotationHandler<MyAnnotation> { | |
@Override | |
public void handle(ScanContext scanContext, FrameworkAnnotationContext<MyAnnotation> annotationContext) { | |
System.out.println("Foo is " + annotationContext.getAnnotation().foo()); | |
System.out.println("Bar is " + annotationContext.getAnnotation().bar()); | |
} | |
} |
NewerOlder