Class ReflectiveELMethodExecutor
java.lang.Object
io.micronaut.el.interpreter.reflection.ReflectiveELMethodExecutor
- All Implemented Interfaces:
io.micronaut.core.order.Ordered, ELMethodExecutor
Resolves interpreter methods through the public Java reflection API.
This executor is registered as a service and is intentionally kept in a separate artifact. Applications that need arbitrary Java method execution can add this module; applications that provide generated or otherwise direct executors can omit it.
- Since:
- 1.1
- Author:
- Denis Stepanov
-
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetOrder()Returns the executor order.booleanWhether the executor reaches the methods it resolves reflectively, rather than through what was generated or registered while the application compiled.@Nullable ELMethodresolve(jakarta.el.ELContext context, @Nullable Object base, @Nullable Object method, io.micronaut.core.type.Argument<?> @Nullable [] argumentTypes, Object @Nullable [] arguments) Resolves an instance or static method, or a constructor represented by<init>.@Nullable ELMethodresolveFunction(jakarta.el.ELContext context, String prefix, String localName) Resolves a function bound by the expression context.
-
Constructor Details
-
ReflectiveELMethodExecutor
public ReflectiveELMethodExecutor()
-
-
Method Details
-
getOrder
public int getOrder()Description copied from interface:ELMethodExecutorReturns the executor order. Lower values run first, following the MicronautOrderedcontract, so direct/generated implementations can take precedence over a general fallback such as reflection.- Specified by:
getOrderin interfaceELMethodExecutor- Specified by:
getOrderin interfaceio.micronaut.core.order.Ordered- Returns:
- The order, zero by default
-
isReflective
public boolean isReflective()Description copied from interface:ELMethodExecutorWhether the executor reaches the methods it resolves reflectively, rather than through what was generated or registered while the application compiled. TheELSandboxof an expression parsed at runtime is consulted for the methods such an executor resolves, and only for them.- Specified by:
isReflectivein interfaceELMethodExecutor- Returns:
- Whether the executor reflects,
falseby default
-
resolve
public @Nullable ELMethod resolve(jakarta.el.ELContext context, @Nullable Object base, @Nullable Object method, io.micronaut.core.type.Argument<?> @Nullable [] argumentTypes, Object @Nullable [] arguments) Description copied from interface:ELMethodExecutorResolves an instance or static method, or a constructor represented by<init>.- Specified by:
resolvein interfaceELMethodExecutor- Parameters:
context- The EL contextbase- The instance, or anELClassfor a static method or constructormethod- The method nameargumentTypes- The parameter types supplied when the method expression was created, ornullarguments- The evaluated arguments, ornull- Returns:
- The resolved method, or
nullwhen this executor does not handle it
-
resolveFunction
public @Nullable ELMethod resolveFunction(jakarta.el.ELContext context, String prefix, String localName) Description copied from interface:ELMethodExecutorResolves a function bound by the expression context.The default implementation does not contribute functions. A reflection-backed implementation can use the Jakarta
FunctionMapperhere, while a generated implementation can provide functions without exposing reflective methods.- Specified by:
resolveFunctionin interfaceELMethodExecutor- Parameters:
context- The EL contextprefix- The function prefixlocalName- The function name- Returns:
- The resolved function, or
nullwhen this executor does not handle it
-