Class MethodInvocationStrategy

java.lang.Object
org.jboss.weld.injection.MethodInvocationStrategy

public abstract class MethodInvocationStrategy extends Object
Encapsulates various strategies for invoking a method injection point. The default implementation supports all the possible scenarios including dependency injection to parameters. In addition, there are optimized implementations for commonly used scenarios such as:
  • an observer method with event parameter only
  • an observer method with event parameter and a BeanManager injection point (common in extensions)
  • an observer method with event parameter and an EventMetadata injection point
Author:
Jozef Hartinger, Martin Kouba
  • Field Details

  • Method Details

    • forDisposer

      public static MethodInvocationStrategy forDisposer(MethodInjectionPoint<?,?> method, BeanManagerImpl manager)
    • forObserver

      public static MethodInvocationStrategy forObserver(MethodInjectionPoint<?,?> method, BeanManagerImpl manager)
    • invoke

      public abstract <T> void invoke(Object receiver, MethodInjectionPoint<?,?> method, T instance, BeanManagerImpl manager, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext)
    • startInterceptionContextIfNeeded

      protected boolean startInterceptionContextIfNeeded(Object receiver, MethodInjectionPoint<?,?> method)
      This method ensures that final observers on proxied beans cannot trigger interception when referencing otherwise intercepted method in observer body - e.g. so that they recognize self-invocation. This is similar to what we do in InterceptedSubclassFactory#invokeMethodHandler() but requires special handling here since observers can be private and final and we cannot override them on proxies. All implementations of invoke(Object, MethodInjectionPoint, Object, BeanManagerImpl, CreationalContext) should call this method prior to invoking observer itself in order to start the interception context and if this method returns true, endInterceptionContext() should be invoked right after observer method invocation to tear down the context from stack.
      Returns:
      true if this method started interception context, false otherwise
    • endInterceptionContext

      protected void endInterceptionContext()