Annotation Interface Around
Annotation stereotype to applied to other annotations to indicate the annotation provides Around advice.
Around advice decorates a method invocation such that the method can be intercepted via a MethodInterceptor
For example:
@Around
@Type(ExampleInterceptor.class)
@Documented
@Retention(RUNTIME)
public @interface Example {
}
Note that the annotation MUST be RetentionPolicy.RUNTIME
and the specified Type
must implement MethodInterceptor
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
When usingproxyTarget()
on aFactory
method if the returned bean features constructor arguments this can lead to undefined behaviour since it is expected with factory methods that the developer is responsible for constructing the object. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
If true the proxy cache and reuse the target.boolean
IfproxyTarget()
is set totrue
then one can optionally set the value ofhotswap
to true in which case the proxy will implement theHotSwappableInterceptedProxy
interface.boolean
By default Micronaut will initialize the proxy target eagerly when the proxy is created.boolean
By default Micronaut will compile subclasses of the target class and call super.foo(..) to invoke the original method since this is more efficient and allows proxied methods to work for calls from within the class.Sets theAround.ProxyTargetConstructorMode
.
-
Element Details
-
proxyTarget
boolean proxyTargetBy default Micronaut will compile subclasses of the target class and call super.foo(..) to invoke the original method since this is more efficient and allows proxied methods to work for calls from within the class.
However certain cases it may be useful to be able to to instead proxy all public methods of the original implementation. By setting the value here to
true
theInterceptor
can specify that it requires proxying of the classGenerated subclasses will implement
InterceptedProxy
if this attribute is set to true- Returns:
- True if the original implementation should be proxied. Defaults to false.
- See Also:
- Default:
- false
-
hotswap
boolean hotswapIf
proxyTarget()
is set totrue
then one can optionally set the value ofhotswap
to true in which case the proxy will implement theHotSwappableInterceptedProxy
interface.- Returns:
- True if the proxy should allow hotswap
- See Also:
- Default:
- false
-
lazy
boolean lazyBy default Micronaut will initialize the proxy target eagerly when the proxy is created. This is better for performance, but some use cases may require the bean to be resolved lazily (for example for resolving the bean from a custom scope).
If
proxyTarget()
is set totrue
then one can optionally set the oflazy
to true- Returns:
- True if the proxy target should be resolved lazily
- Default:
- false
-
cacheableLazyTarget
boolean cacheableLazyTargetIf true the proxy cache and reuse the target.- Returns:
- True if the proxy target should be cacheable
- Since:
- 3.1.0
- Default:
- false
-
proxyTargetMode
Around.ProxyTargetConstructorMode proxyTargetModeSets theAround.ProxyTargetConstructorMode
. See the javadoc forAround.ProxyTargetConstructorMode
for more information.- Returns:
- The
Around.ProxyTargetConstructorMode
. - Since:
- 3.0.0
- See Also:
- Default:
- ERROR
-