Package io.micronaut.aop
Enum Class Around.ProxyTargetConstructorMode
java.lang.Object
java.lang.Enum<Around.ProxyTargetConstructorMode>
io.micronaut.aop.Around.ProxyTargetConstructorMode
- All Implemented Interfaces:
Serializable
,Comparable<Around.ProxyTargetConstructorMode>
,Constable
- Enclosing class:
- Around
public static enum Around.ProxyTargetConstructorMode
extends Enum<Around.ProxyTargetConstructorMode>
When using
Around.proxyTarget()
on a Factory
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.
For example if the type accepts an argument of type String
then there is no way
for Micronaut to know what to inject as a value for the argument and injecting null
is inherently unsafe.
The Around.ProxyTargetConstructorMode
allows the developer decide if they wish to allow
proxies to be constructed and if a proxy is allowed then Micronaut will either inject a bean if it is found or null
if is not. For primitive types Micronaut will inject true
for booleans and 0
for number types
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the enum constant of this class with the specified name.static Around.ProxyTargetConstructorMode[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ERROR
Do not allow types with constructor arguments to be proxied. This is the default behaviour and compilation will fail. -
WARN
Allow types to be proxied but print a warning when this feature is used.In this case if a constructor parameter cannot be injected Micronaut will inject
null
for objects orfalse
for boolean or0
for any other primitive. -
ALLOW
Allow types to be proxied and don't print any warnings.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-