Top Description Methods
javax.enterprise.inject.spi

public Interface ProcessProducer<T, X>

Type Parameters
<T>
The bean class of the bean that declares the producer method or field
<X>
The return type of the producer method or the type of the producer field
Imports
javax.enterprise.inject.spi.configurator.ProducerConfigurator

The container fires an event of this type for each producer method or field of each enabled bean, including resources.

Any observer of this event is permitted to wrap and/or replace the Producer by calling either setProducer(Producer) or configureProducer(). If both methods are called within an observer notification an IllegalStateException is thrown. The container must use the final value of this property, after all observers have been called, whenever it calls the producer or disposer.

For example, this observer decorates the Producer for the all producer methods and field of type EntityManager.

void decorateEntityManager(@Observes ProcessProducer<?, EntityManager> pp) {
    pit.setProducer(decorate(pp.getProducer()));
}

If any observer method of a ProcessProducer event throws an exception, the exception is treated as a definition error by the container.

Author
David Allen
See Also
Producer

Method Summary

Modifier and TypeMethod and Description
public void
addDefinitionError(Throwable
The definition error to register as a java.lang.Throwable
t
)

Registers a definition error with the container, causing the container to abort deployment after bean discovery is complete.

public ProducerConfigurator<X>

Returns:

a non reusable ProducerConfigurator to configure the original javax.enterprise.inject.spi.Producer.
configureProducer
()

Returns a ProducerConfigurator initialized with the Producer processed by this event, to configure a new Producer that will replace the original one at the end of the observer invocation.

public AnnotatedMember<T>

Returns:

the javax.enterprise.inject.spi.AnnotatedMember representing the producer
getAnnotatedMember
()

Returns the javax.enterprise.inject.spi.AnnotatedField representing the producer field or the javax.enterprise.inject.spi.AnnotatedMethod representing the producer method.

public Producer<X>

Returns:

the javax.enterprise.inject.spi.Producer invoker object used by the container
getProducer
()

Returns the javax.enterprise.inject.spi.Producer object that will be used by the container to call the producer method or read the producer field.

public void
setProducer(Producer<X> producer)

Replaces the javax.enterprise.inject.spi.Producer object that will be used by the container to call the producer method or read the producer field.

Method Detail

addDefinitionErrorback to summary
public void addDefinitionError(Throwable t)

Registers a definition error with the container, causing the container to abort deployment after bean discovery is complete.

Parameters
t:Throwable

The definition error to register as a java.lang.Throwable

Exceptions
IllegalStateException:
if called outside of the observer method invocation
configureProducerback to summary
public ProducerConfigurator<X> configureProducer()

Returns a ProducerConfigurator initialized with the Producer processed by this event, to configure a new Producer that will replace the original one at the end of the observer invocation.

Each call returns the same configurator instance within an observer notification.

Returns:ProducerConfigurator<X>

a non reusable ProducerConfigurator to configure the original javax.enterprise.inject.spi.Producer.

Exceptions
IllegalStateException:
if called outside of the observer method invocation
Since
2.0
getAnnotatedMemberback to summary
public AnnotatedMember<T> getAnnotatedMember()

Returns the javax.enterprise.inject.spi.AnnotatedField representing the producer field or the javax.enterprise.inject.spi.AnnotatedMethod representing the producer method.

Returns:AnnotatedMember<T>

the javax.enterprise.inject.spi.AnnotatedMember representing the producer

Exceptions
IllegalStateException:
if called outside of the observer method invocation
getProducerback to summary
public Producer<X> getProducer()

Returns the javax.enterprise.inject.spi.Producer object that will be used by the container to call the producer method or read the producer field.

Returns:Producer<X>

the javax.enterprise.inject.spi.Producer invoker object used by the container

Exceptions
IllegalStateException:
if called outside of the observer method invocation
setProducerback to summary
public void setProducer(Producer<X> producer)

Replaces the javax.enterprise.inject.spi.Producer object that will be used by the container to call the producer method or read the producer field.

Parameters
producer:Producer<X>

the new javax.enterprise.inject.spi.Producer object to use

Exceptions
IllegalStateException:
if called outside of the observer method invocation