Package org.infinispan.cdi.common.util
Class InjectableMethod<X>
- java.lang.Object
-
- org.infinispan.cdi.common.util.InjectableMethod<X>
-
- Type Parameters:
X- the declaring type
public class InjectableMethod<X> extends Object
Allows an
AnnotatedMethodto be injected using the CDI type safe resolution rules.ParameterValueRedefinerallows the default value to be overridden by the caller ofinvoke(Object, CreationalContext, ParameterValueRedefiner).- Author:
- Pete Muir
-
-
Constructor Summary
Constructors Constructor Description InjectableMethod(javax.enterprise.inject.spi.AnnotatedMethod<X> method, Collection<javax.enterprise.inject.spi.InjectionPoint> parameters, javax.enterprise.inject.spi.BeanManager beanManager)Instantiate a newInjectableMethod.InjectableMethod(javax.enterprise.inject.spi.AnnotatedMethod<X> method, javax.enterprise.inject.spi.Bean<?> declaringBean, javax.enterprise.inject.spi.BeanManager beanManager)Instantiate a newInjectableMethod.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.enterprise.inject.spi.BeanManagergetBeanManager()Get the bean manager used by this injectable method.protected List<javax.enterprise.inject.spi.InjectionPoint>getParameters()Get the injectable parameters of this method.<T> Tinvoke(Object receiver, javax.enterprise.context.spi.CreationalContext<T> creationalContext)Invoke the method, causing all parameters to be injected according to the CDI type safe resolution rules.<T> Tinvoke(Object receiver, javax.enterprise.context.spi.CreationalContext<T> creationalContext, ParameterValueRedefiner redefinition)Invoke the method, calling the parameter redefiner for each parameter, allowing the caller to override the default value obtained via the CDI type safe resolver.
-
-
-
Constructor Detail
-
InjectableMethod
public InjectableMethod(javax.enterprise.inject.spi.AnnotatedMethod<X> method, javax.enterprise.inject.spi.Bean<?> declaringBean, javax.enterprise.inject.spi.BeanManager beanManager)
Instantiate a newInjectableMethod.- Parameters:
method- the method which will be injected upon a call toinvoke(Object, CreationalContext)bean- the bean which defines the injectable methodbeanManager- theBeanManagerto use to obtain the parameter values
-
InjectableMethod
public InjectableMethod(javax.enterprise.inject.spi.AnnotatedMethod<X> method, Collection<javax.enterprise.inject.spi.InjectionPoint> parameters, javax.enterprise.inject.spi.BeanManager beanManager)
Instantiate a newInjectableMethod.- Parameters:
method- the method which will be injected upon a call toinvoke(Object, CreationalContext)parameters- a collection of injection points representing the parameters of the methodbeanManager- theBeanManagerto use to obtain the parameter values
-
-
Method Detail
-
getBeanManager
protected javax.enterprise.inject.spi.BeanManager getBeanManager()
Get the bean manager used by this injectable method.- Returns:
- the bean manager in use
-
getParameters
protected List<javax.enterprise.inject.spi.InjectionPoint> getParameters()
Get the injectable parameters of this method.- Returns:
- a collection of injection points representing the parameters of this method
-
invoke
public <T> T invoke(Object receiver, javax.enterprise.context.spi.CreationalContext<T> creationalContext)
Invoke the method, causing all parameters to be injected according to the CDI type safe resolution rules.- Type Parameters:
T- the return type of the method- Parameters:
receiver- the instance upon which to call the methodcreationalContext- the creational context to use to obtain injectable references for each parameter- Returns:
- the result of invoking the method or null if the method's return type is void
- Throws:
RuntimeException- if thisMethodobject enforces Java language access control and the underlying method is inaccessible or if the underlying method throws an exception or if the initialization provoked by this method fails.IllegalArgumentException- if the method is an instance method and the specifiedreceiverargument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.NullPointerException- if the specifiedreceiveris null and the method is an instance method.ExceptionInInitializerError- if the initialization provoked by this method fails.
-
invoke
public <T> T invoke(Object receiver, javax.enterprise.context.spi.CreationalContext<T> creationalContext, ParameterValueRedefiner redefinition)
Invoke the method, calling the parameter redefiner for each parameter, allowing the caller to override the default value obtained via the CDI type safe resolver.- Type Parameters:
T- the return type of the method- Parameters:
receiver- the instance upon which to call the methodcreationalContext- the creational context to use to obtain injectable references for each parameter- Returns:
- the result of invoking the method or null if the method's return type is void
- Throws:
RuntimeException- if thisMethodobject enforces Java language access control and the underlying method is inaccessible or if the underlying method throws an exception or if the initialization provoked by this method fails.IllegalArgumentException- if the method is an instance method and the specifiedreceiverargument is not an instance of the class or interface declaring the underlying method (or of a subclass or implementor thereof); if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion.NullPointerException- if the specifiedreceiveris null and the method is an instance method.ExceptionInInitializerError- if the initialization provoked by this method fails.
-
-