Register a component with an aspect and verify the aspect proxy is transparent.
← Design Patterns and Idioms · Ref: Q1119
A silent aspect is transparent -- calls and returns pass through unchanged:
greeter as Greeter! result <- greeter.greet("World")
The caller cannot tell whether an aspect is present. This is the foundation of AOP in EK9.
See Q1115 for basic aspect. See Q1120 for no-aspect baseline.
Example
defines module qa.designpatterns.aspectordering defines component Greeter as abstract greet() as abstract -> name as String <- rtn as String? SimpleGreeter is Greeter override greet() -> name as String <- rtn as String: `Hello ${name}` defines class TransparentAspect extends Aspect default operator ? defines application AspectOrderApp register SimpleGreeter() as Greeter with aspect of TransparentAspect() defines program AspectOrderingDemo() with application of AspectOrderApp stdout <- Stdout() greeter as Greeter! result <- greeter.greet("World") stdout.println(result)
Common mistakes
E50200 — EK9 has no Java/Spring-style annotations; the '@' prefix is reserved for compiler directives and '@Around' is not a valid one. See ek9 -h E50200 for details.
Incorrect:
TransparentAspect extends Aspect @Around proceed()
Correct:
TransparentAspect extends Aspect default operator ?
Other ways to ask this
- I want to confirm that an aspect does not change the return value of a method
- Show that a silent aspect passes method results through unchanged
- Given two registrations — one with aspect, one without — verify identical results
- Demonstrate aspect transparency by comparing proxied and direct calls
Coming from another language?
Spring AOP: @Around that calls proceed() is transparent. AspectJ: proceed() in around advice. EK9: silent Aspect subclass — transparent by default.
Keywords: aspect, unchanged, transparent, ordering, proxy