use of jakarta.enterprise.inject.spi.AnnotatedType in project core by weld.
the class GlueDecoratorExtension method registerDecorator.
void registerDecorator(@Observes AfterBeanDiscovery event, BeanManager manager) {
AnnotatedType<GlueDecorator> annotatedType = manager.createAnnotatedType(GlueDecorator.class);
final BeanAttributes<GlueDecorator> attributes = manager.createBeanAttributes(annotatedType);
final InjectionPoint delegateInjectionPoint = manager.createInjectionPoint(annotatedType.getConstructors().iterator().next().getParameters().get(0));
Decorator<GlueDecorator> decorator = new DecoratorImpl<GlueDecorator>() {
@Override
public Type getDelegateType() {
return Glue.class;
}
@Override
public Set<Annotation> getDelegateQualifiers() {
return Collections.<Annotation>singleton(Any.Literal.INSTANCE);
}
@Override
public Set<Type> getDecoratedTypes() {
return Collections.emptySet();
}
@Override
public Class<?> getBeanClass() {
return GlueDecorator.class;
}
@Override
public Set<InjectionPoint> getInjectionPoints() {
final Decorator<GlueDecorator> decorator = this;
InjectionPoint wrappedInjectionPoint = new ForwardingInjectionPoint() {
@Override
public Bean<?> getBean() {
return decorator;
}
@Override
protected InjectionPoint delegate() {
return delegateInjectionPoint;
}
};
return Collections.singleton(wrappedInjectionPoint);
}
@Override
public GlueDecorator create(CreationalContext<GlueDecorator> creationalContext) {
return new GlueDecorator(null);
}
@Override
public void destroy(GlueDecorator instance, CreationalContext<GlueDecorator> creationalContext) {
creationalContext.release();
}
@Override
protected BeanAttributes<GlueDecorator> attributes() {
return attributes;
}
};
event.addBean(decorator);
}
use of jakarta.enterprise.inject.spi.AnnotatedType in project myfaces by apache.
the class FacesConfigExtension method beforeBeanDiscovery.
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager beanManager) {
AnnotatedType beanHolder = beanManager.createAnnotatedType(FacesConfigBeanHolder.class);
event.addAnnotatedType(beanHolder, beanHolder.getJavaClass().getName());
}
use of jakarta.enterprise.inject.spi.AnnotatedType in project myfaces by apache.
the class FacesDataModelExtension method beforeBeanDiscovery.
void beforeBeanDiscovery(@Observes final BeforeBeanDiscovery event, BeanManager beanManager) {
AnnotatedType beanHolder = beanManager.createAnnotatedType(FacesDataModelManager.class);
event.addAnnotatedType(beanHolder, beanHolder.getJavaClass().getName());
}
use of jakarta.enterprise.inject.spi.AnnotatedType in project myfaces by apache.
the class CDIInjectionProviderImpl method preDestroy.
@Override
public void preDestroy(Object instance, Object creationMetaData) throws InjectionProviderException {
if (creationMetaData instanceof CreationalContext) {
AnnotatedType annoType = beanManager.createAnnotatedType(instance.getClass());
InjectionTarget target = beanManager.createInjectionTarget(annoType);
target.preDestroy(instance);
((CreationalContext) creationMetaData).release();
}
}
use of jakarta.enterprise.inject.spi.AnnotatedType in project myfaces by apache.
the class CDIInjectionProviderImpl method inject.
@Override
public Object inject(Object instance) throws InjectionProviderException {
AnnotatedType annoType = beanManager.createAnnotatedType(instance.getClass());
InjectionTarget target = beanManager.createInjectionTarget(annoType);
CreationalContext<?> creationalContext = beanManager.createCreationalContext(null);
target.inject(instance, creationalContext);
return creationalContext;
}
Aggregations