Class AbstractMemberProducer<X,T>
- java.lang.Object
-
- org.jboss.weld.injection.producer.AbstractProducer<T>
-
- org.jboss.weld.injection.producer.AbstractMemberProducer<X,T>
-
- All Implemented Interfaces:
Producer<T>
- Direct Known Subclasses:
ProducerFieldProducer,ProducerMethodProducer
public abstract class AbstractMemberProducer<X,T> extends AbstractProducer<T>
Common functionality forProducers backing producer fields and producer methods.- Author:
- Jozef Hartinger, Marko Luksa
-
-
Constructor Summary
Constructors Constructor Description AbstractMemberProducer(EnhancedAnnotatedMember<T,? super X,? extends Member> enhancedMember, DisposalMethod<?,?> disposalMethod)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckDeclaringBean()protected voidcheckProducerReturnType(EnhancedAnnotatedMember<T,? super X,? extends Member> enhancedMember)voiddispose(T instance)Destroys the instance.abstract AnnotatedMember<? super X>getAnnotated()abstract Bean<T>getBean()Returns aBeanthis producer is associated with or null if no such bean exists.abstract BeanManagerImplgetBeanManager()abstract Bean<X>getDeclaringBean()DisposalMethod<?,?>getDisposalMethod()protected ObjectgetReceiver(CreationalContext<?> productCreationalContext, CreationalContext<?> receiverCreationalContext)Gets the receiver of the product.protected booleanisTypeSerializable(Object object)protected abstract Tproduce(Object receiver, CreationalContext<T> ctx)Tproduce(CreationalContext<T> ctx)Causes an instance to be produced via theProducer.protected abstract DefinitionExceptionproducerWithInvalidTypeVariable(AnnotatedMember<?> member)protected abstract DefinitionExceptionproducerWithInvalidWildcard(AnnotatedMember<?> member)protected abstract DefinitionExceptionproducerWithParameterizedTypeWithTypeVariableBeanTypeMustBeDependent(AnnotatedMember<?> member)StringtoString()-
Methods inherited from class org.jboss.weld.injection.producer.AbstractProducer
checkDelegateInjectionPoints, equals, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.enterprise.inject.spi.Producer
getInjectionPoints
-
-
-
-
Constructor Detail
-
AbstractMemberProducer
public AbstractMemberProducer(EnhancedAnnotatedMember<T,? super X,? extends Member> enhancedMember, DisposalMethod<?,?> disposalMethod)
-
-
Method Detail
-
checkDeclaringBean
protected void checkDeclaringBean()
-
checkProducerReturnType
protected void checkProducerReturnType(EnhancedAnnotatedMember<T,? super X,? extends Member> enhancedMember)
-
producerWithInvalidTypeVariable
protected abstract DefinitionException producerWithInvalidTypeVariable(AnnotatedMember<?> member)
-
producerWithInvalidWildcard
protected abstract DefinitionException producerWithInvalidWildcard(AnnotatedMember<?> member)
-
producerWithParameterizedTypeWithTypeVariableBeanTypeMustBeDependent
protected abstract DefinitionException producerWithParameterizedTypeWithTypeVariableBeanTypeMustBeDependent(AnnotatedMember<?> member)
-
getReceiver
protected Object getReceiver(CreationalContext<?> productCreationalContext, CreationalContext<?> receiverCreationalContext)
Gets the receiver of the product. The two creational contexts need to be separated because the receiver only serves the product creation (it is not a dependent instance of the created instance).- Parameters:
productCreationalContext- the creational context of the produced instancereceiverCreationalContext- the creational context of the receiver- Returns:
- The receiver
-
dispose
public void dispose(T instance)
Description copied from interface:ProducerDestroys the instance.
If the
Producerrepresents a class, then this operation does nothing.If the
Producerrepresents a producer field or method, this calls the disposer method, if any, on a contextual instance of the bean that declares the disposer method or performs any additional required cleanup, if any, to destroy state associated with a resource.- Parameters:
instance- The instance to dispose
-
produce
public T produce(CreationalContext<T> ctx)
Description copied from interface:ProducerCauses an instance to be produced via the
Producer.If the
Producerrepresents a class, this will invoke the constructor annotatedInjectif it exists, or the constructor with no parameters otherwise. If the class has interceptors, produce() is responsible for building the interceptors and decorators of the instance.If the
Producerrepresents a producer field or method, this will invoke the producer method on, or access the producer field of, a contextual instance of the bean that declares the producer.- Parameters:
ctx- TheCreationalContextto use for the produced object- Returns:
- the instance produced
-
getDisposalMethod
public DisposalMethod<?,?> getDisposalMethod()
-
isTypeSerializable
protected boolean isTypeSerializable(Object object)
-
getBeanManager
public abstract BeanManagerImpl getBeanManager()
-
getBean
public abstract Bean<T> getBean()
Description copied from class:AbstractProducerReturns aBeanthis producer is associated with or null if no such bean exists.- Specified by:
getBeanin classAbstractProducer<T>
-
getAnnotated
public abstract AnnotatedMember<? super X> getAnnotated()
- Specified by:
getAnnotatedin classAbstractProducer<T>
-
produce
protected abstract T produce(Object receiver, CreationalContext<T> ctx)
-
-