org.infinispan.cdi.util.defaultbean.DefaultProducerField Maven / Gradle / Ivy
package org.infinispan.cdi.util.defaultbean;
import org.infinispan.cdi.util.Reflections;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
// TODO Make this passivation capable
class DefaultProducerField extends AbstractDefaultProducerBean {
private final AnnotatedField field;
static DefaultProducerField of(Bean originalBean, Type declaringBeanType, Set beanTypes, Set qualifiers, Set declaringBeanQualifiers, AnnotatedField field, BeanManager beanManager) {
return new DefaultProducerField(originalBean, declaringBeanType, beanTypes, qualifiers, declaringBeanQualifiers, field, beanManager);
}
DefaultProducerField(Bean originalBean, Type declaringBeanType, Set beanTypes, Set qualifiers, Set declaringBeanQualifiers, AnnotatedField field, BeanManager beanManager) {
super(originalBean, declaringBeanType, beanTypes, qualifiers, declaringBeanQualifiers, beanManager);
this.field = field;
if (!field.getJavaMember().isAccessible()) {
field.getJavaMember().setAccessible(true);
}
}
@Override
protected T getValue(Object receiver, CreationalContext creationalContext) {
return Reflections.getFieldValue(field.getJavaMember(), receiver, Reflections.getRawType(field.getBaseType()));
}
@Override
public void destroy(T instance, CreationalContext creationalContext) {
// TODO: disposers
creationalContext.release();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy