Package jakarta.enterprise.inject.spi
Interface ProducerFactory<X>
-
- Type Parameters:
X
- type of the bean containing the producer
public interface ProducerFactory<X>
An
ProducerFactory
can create anProducer
for a given bean.The
ProducerFactory
obtained fromBeanManager.getProducerFactory(AnnotatedMethod, Bean)
orBeanManager.getProducerFactory(AnnotatedField, Bean)
is capable of providing container created producers. This factory can be wrapped to add behavior to container created producers.For example:
BeanAttributes<MyBean> myBeanAttributes = beanManager.createBeanAttributes(myBeanAnnotatedFieldField); beanManager.createBean(myBeanAttributes, MyBean.class, new ProducerFactory() { public <T> Producer<T> createProducer(Bean<T> bean) { return new WrappingProducer<T>(beanManager.getProducerFactory(myBeanAnnotatedField).createProducer(bean)); } });
CDI Lite implementations are not required to provide support for
ProducerFactory
.- Since:
- 1.1
- Author:
- Pete Muir
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> Producer<T>
createProducer(Bean<T> bean)
Create a new producer for a bean.
-