Package org.jboss.weld.injection
Class MethodInvocationStrategy
java.lang.Object
org.jboss.weld.injection.MethodInvocationStrategy
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
BeanManagerinjection point (common in extensions) - an observer method with event parameter and an
EventMetadatainjection point
- Author:
- Jozef Hartinger, Martin Kouba
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected voidstatic MethodInvocationStrategyforDisposer(MethodInjectionPoint<?, ?> method, BeanManagerImpl manager) static MethodInvocationStrategyforObserver(MethodInjectionPoint<?, ?> method, BeanManagerImpl manager) abstract <T> voidinvoke(Object receiver, MethodInjectionPoint<?, ?> method, T instance, BeanManagerImpl manager, jakarta.enterprise.context.spi.CreationalContext<?> creationalContext) protected booleanstartInterceptionContextIfNeeded(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.
-
Field Details
-
exceptionTypeToThrow
-
-
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 inInterceptedSubclassFactory#invokeMethodHandler()but requires special handling here since observers can be private and final and we cannot override them on proxies. All implementations ofinvoke(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()
-