Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method invokers #639

Merged
merged 2 commits into from
Oct 13, 2023
Merged

Method invokers #639

merged 2 commits into from
Oct 13, 2023

Commits on Oct 11, 2023

  1. Initial proposal for method invokers: introduce core concepts

    _`Invoker`_ is an indirect way of invoking a bean method. It is a simple
    functional interface:
    
    ```java
    interface Invoker<T, R> {
        R invoke(T instance, Object[] arguments);
    }
    ```
    
    Invokers are built using an _`InvokerBuilder`_. They must be thread-safe,
    so frameworks can build an invoker for each relevant method once and then
    reuse it to invoke that method whenever necessary.
    
    An invoker may be built for a method that:
    
    1. is not `private`;
    2. is not a constructor;
    3. is declared on a bean class of a managed bean (class-based bean),
       with the exception of interceptors and decorators, or inherited
       from its supertypes.
    
    If an invocation of a method is intercepted, an equivalent invocation
    through an invoker is also intercepted.
    
    Portable extensions may obtain an `InvokerBuilder` in an observer
    of the `ProcessManagedBean` type. The `InvokerBuilder` in this case
    produces `Invoker` objects directly.
    
    Build compatible extensions may obtain an `InvokerBuilder` during
    `@Registration` from the `BeanInfo` object. The `InvokerBuilder` in
    this case produces `InvokerInfo` objects. `InvokerInfo` is an opaque
    token that can only be used to materialize an `Invoker` in synthetic
    components.
    Ladicek committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    0e2c99b View commit details
    Browse the repository at this point in the history
  2. Initial proposal for method invokers: invoker builder features

    This commit introduces actual interesting features to the `InvokerBuilder`:
    
    - automatic lookup of the target instance and arguments
    - transformation of the target instance and arguments before invocation
    - transformation of the return value and thrown exception after invocation
    - wrapping the invoker into a custom piece of code for maximum flexibility
    Ladicek committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    ff9d0e3 View commit details
    Browse the repository at this point in the history