Skip to content

Commit ba8e784

Browse files
committed
Updated architecture diagram (README.md)
1 parent c4708a5 commit ba8e784

File tree

2 files changed

+77
-18
lines changed

2 files changed

+77
-18
lines changed

README.md

Lines changed: 76 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,84 @@ title: Python annotations flow
8888
---
8989
9090
classDiagram
91-
PythonBefores --> PythonAnnotationEvaluator
92-
PythonBefore --> PythonAnnotationEvaluator
93-
PythonAfters --> PythonAnnotationEvaluator
94-
PythonAfter --> PythonAnnotationEvaluator
95-
PythonAnnotationEvaluator --> PythonAnnotationValueCompounder
96-
PythonAnnotationEvaluator <-- PythonAnnotationValueCompounder
97-
PythonAnnotationEvaluator --> ProfileChecker
98-
PythonAnnotationEvaluator <-- ProfileChecker
99-
PythonAnnotationEvaluator --> PythonArgumentsExtractor
100-
PythonAnnotationEvaluator <-- PythonArgumentsExtractor
101-
PythonAnnotationEvaluator --> PythonProcessor
102-
PythonAnnotationValueCompounder --> PythonAnnotationValueExtractor
103-
PythonAnnotationValueCompounder <-- PythonAnnotationValueExtractor
104-
PythonAnnotationValueExtractor --> PythonMethodExtractor
105-
PythonAnnotationValueExtractor <-- PythonMethodExtractor
106-
PythonArgumentsExtractor --> PythonMethodExtractor
107-
PythonArgumentsExtractor <-- PythonMethodExtractor
91+
PythonBefores --> PythonAnnotationEvaluator: An annotation container that holds multiple @PythonBefore annotations is passed to the evaluator
92+
PythonBefore --> PythonAnnotationEvaluator: A single @PythonBefore annotation is passed to the evaluator with script and profiles info
93+
PythonAfters --> PythonAnnotationEvaluator: An annotation container that holds multiple @PythonAfter annotations is passed to the evaluator
94+
PythonAfter --> PythonAnnotationEvaluator: A single @PythonAfter annotation is passed to the evaluator with script and profiles info
95+
PythonAnnotationEvaluator --> PythonAnnotationValueCompounder: The evaluator requests the compounder to merge annotation values into a unified structure
96+
PythonAnnotationEvaluator <-- PythonAnnotationValueCompounder: Returns a merged map of Python code and active profiles
97+
PythonAnnotationEvaluator --> ProfileChecker: The evaluator checks if the annotation’s activeProfiles match the current application profiles
98+
PythonAnnotationEvaluator <-- ProfileChecker: Executes a callback if profiles match
99+
PythonAnnotationEvaluator --> PythonArgumentsExtractor: Extracts method arguments from the JoinPoint
100+
PythonAnnotationEvaluator <-- PythonArgumentsExtractor: Returns a map of argument names to their values
101+
PythonAnnotationEvaluator --> PythonProcessor: Finally, executes the Python script using the provided arguments
102+
PythonAnnotationValueCompounder --> PythonAnnotationValueExtractor: The compounder delegates to the several extractors to get raw values from annotations
103+
PythonAnnotationValueCompounder <-- PythonAnnotationValueExtractor: Returns the raw annotation values
104+
PythonAnnotationValueExtractor --> PythonMethodExtractor: The extractor gets method metadata from the JoinPoint
105+
PythonAnnotationValueExtractor <-- PythonMethodExtractor: Returns the method object
106+
PythonArgumentsExtractor --> PythonMethodExtractor: The arguments extractor retrieves method parameters from the JoinPoint
107+
PythonArgumentsExtractor <-- PythonMethodExtractor: Returns a map of parameter names to their values
108108
109+
class PythonBefores {
110+
+PythonBefore[] value()
111+
}
112+
113+
class PythonBefore {
114+
+String value()
115+
+String script()
116+
+String[] activeProfiles()
117+
}
118+
119+
class PythonAfters {
120+
+PythonAfter[] value()
121+
}
122+
123+
class PythonAfter {
124+
+String value()
125+
+String script()
126+
+String[] activeProfiles()
127+
}
128+
129+
class PythonAnnotationEvaluator {
130+
<<interface>>
131+
+<A extends Annotation> void evaluate(JoinPoint joinPoint, Class<? extends A> annotationClass);
132+
+<A extends Annotation> void evaluate(JoinPoint joinPoint, Class<? extends A> annotationClass, Map<String, Object> additionalArguments);
133+
}
134+
135+
class PythonAnnotationValueCompounder {
136+
<<interface>>
137+
+<A extends Annotation> Map<String, String[]> compound(JoinPoint joinPoint, Class<? extends A> annotationClass);
138+
}
109139
140+
class ProfileChecker {
141+
<<interface>>
142+
+void doOnProfiles(String[] profiles, Runnable action);
143+
}
144+
145+
class PythonArgumentsExtractor {
146+
<<interface>>
147+
+Map<String, Object> getArguments(JoinPoint joinPoint)
148+
+Map<String, Object> getArguments(JoinPoint joinPoint, Map<String, Object> additionalArguments)
149+
}
150+
151+
class PythonProcessor {
152+
<<interface>>
153+
+void process(String script)
154+
+void process(String script, Map<String, Object> arguments)
155+
+R process(String script, Class<? extends R> resultClass)
156+
+R process(String script, Class<? extends R> resultClass, Map<String, Object> arguments)
157+
}
158+
159+
class PythonAnnotationValueExtractor {
160+
<<interface>>
161+
+<A extends Annotation> Map<String, String[]> getValue(JoinPoint joinPoint, Class<? extends A> annotationClass);
162+
}
163+
164+
class PythonMethodExtractor {
165+
<<interface>>
166+
+Method getMethod(JoinPoint joinPoint);
167+
+Map<String, Object> getMethodParameters(JoinPoint joinPoint);
168+
}
110169
```
111170

112171
Also, you can use only PythonProcessor object to execute Python code:

spring-boot-python-executor-core/src/main/java/io/w4t3rcs/python/aspect/PythonAnnotationEvaluator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public interface PythonAnnotationEvaluator {
3939
* @param annotationClass the {@link Class} object of the annotation to evaluate, must not be {@code null}
4040
*/
4141
default <A extends Annotation> void evaluate(JoinPoint joinPoint, Class<? extends A> annotationClass) {
42-
evaluate(joinPoint, annotationClass, Map.of());
42+
this.evaluate(joinPoint, annotationClass, Map.of());
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)