Helpers that tell whether an object is an AOP proxy and find the bean behind it.
Code that needs the real object rather than its proxy uses them: a test that checks advice was applied, code that compares a bean's runtime class, or a library that inspects beans. Proxying is invisible to most application code, which never needs this.
// In a test: the Calculator bean is advised, and this is its target.
final calculator = context.getBean<Calculator>();
AopUtils.isAopProxy(calculator); // true
AopUtils.getTarget(calculator); // the SimpleCalculator
Spring (Java):
Calculator calculator = context.getBean(Calculator.class);
AopUtils.isAopProxy(calculator);
AopProxyUtils.getSingletonTarget(calculator);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getTarget(
Object object) → Object -
The object behind
object, unwrapping nested proxies;objectitself when it is not a proxy or is a subclass proxy (its own target). -
isAopProxy(
Object? object) → bool -
Whether
objectis an AOP proxy: a wrapper around another object, or a generated subclass proxy with advice attached. A subclass proxy no advice matched is not one.