Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2010, Red Hat, Inc., and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,  
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package javax.enterprise.inject.spi;

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. 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.

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
Author(s):
David Allen
See also:
Producer
public interface ProcessProducer<T, X> {
    
Returns the AnnotatedField representing the producer field or the AnnotatedMethod representing the producer method.

Returns:
the AnnotatedMember representing the producer
Throws:
java.lang.IllegalStateException if called outside of the observer method invocation
    public AnnotatedMember<T> getAnnotatedMember();

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

Returns:
the Producer invoker object used by the container
Throws:
java.lang.IllegalStateException if called outside of the observer method invocation
    public Producer<X> getProducer();

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

Parameters:
producer the new Producer object to use
Throws:
java.lang.IllegalStateException if called outside of the observer method invocation
    public void setProducer(Producer<X> producer);

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

Parameters:
t The definition error to register as a java.lang.Throwable
Throws:
java.lang.IllegalStateException if called outside of the observer method invocation
    public void addDefinitionError(Throwable t);
New to GrepCode? Check out our FAQ X