Search in sources :

Example 1 with AnnotatedType

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);
}
Also used : CreationalContext(jakarta.enterprise.context.spi.CreationalContext) Type(java.lang.reflect.Type) AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType) ForwardingInjectionPoint(org.jboss.weld.injection.ForwardingInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) ForwardingInjectionPoint(org.jboss.weld.injection.ForwardingInjectionPoint) Annotation(java.lang.annotation.Annotation)

Example 2 with AnnotatedType

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());
}
Also used : AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType)

Example 3 with AnnotatedType

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());
}
Also used : AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType)

Example 4 with AnnotatedType

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();
    }
}
Also used : CreationalContext(jakarta.enterprise.context.spi.CreationalContext) AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType) InjectionTarget(jakarta.enterprise.inject.spi.InjectionTarget)

Example 5 with AnnotatedType

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;
}
Also used : AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType) InjectionTarget(jakarta.enterprise.inject.spi.InjectionTarget)

Aggregations

AnnotatedType (jakarta.enterprise.inject.spi.AnnotatedType)18 AnnotatedMethod (jakarta.enterprise.inject.spi.AnnotatedMethod)5 InjectionTarget (jakarta.enterprise.inject.spi.InjectionTarget)4 Test (org.junit.Test)4 CreationalContext (jakarta.enterprise.context.spi.CreationalContext)3 Type (java.lang.reflect.Type)3 EnhancedAnnotatedType (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType)3 ForwardingAnnotatedType (org.jboss.weld.util.annotated.ForwardingAnnotatedType)3 Annotation (java.lang.annotation.Annotation)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 InProcessGrpcChannel (io.helidon.microprofile.grpc.core.InProcessGrpcChannel)1 Dependent (jakarta.enterprise.context.Dependent)1 Observes (jakarta.enterprise.event.Observes)1 AfterBeanDiscovery (jakarta.enterprise.inject.spi.AfterBeanDiscovery)1 Annotated (jakarta.enterprise.inject.spi.Annotated)1 AnnotatedCallable (jakarta.enterprise.inject.spi.AnnotatedCallable)1 AnnotatedConstructor (jakarta.enterprise.inject.spi.AnnotatedConstructor)1 AnnotatedField (jakarta.enterprise.inject.spi.AnnotatedField)1 AnnotatedParameter (jakarta.enterprise.inject.spi.AnnotatedParameter)1