Search in sources :

Example 1 with ForwardingAnnotatedType

use of org.jboss.weld.util.annotated.ForwardingAnnotatedType in project core by weld.

the class ModifyingExtension method registerAdditionalFooAnnotatedType.

public void registerAdditionalFooAnnotatedType(@Observes BeforeBeanDiscovery event, BeanManager manager) {
    final AnnotatedType<Foo> anotherFoo = manager.createAnnotatedType(Foo.class);
    AnnotatedType<Foo> modifiedAnotherFoo = new ForwardingAnnotatedType<Foo>() {

        private final NamedLiteral qualifierInstance = new NamedLiteral("anotherFoo");

        @Override
        public AnnotatedType<Foo> delegate() {
            return anotherFoo;
        }

        @Override
        public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
            if (Named.class.equals(annotationType)) {
                return cast(qualifierInstance);
            }
            return null;
        }

        @Override
        public Set<Annotation> getAnnotations() {
            return Collections.<Annotation>singleton(qualifierInstance);
        }

        @Override
        public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
            return Named.class.equals(annotationType);
        }
    };
    event.addAnnotatedType(modifiedAnotherFoo);
}
Also used : ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) NamedLiteral(org.jboss.weld.literal.NamedLiteral) Annotation(java.lang.annotation.Annotation)

Example 2 with ForwardingAnnotatedType

use of org.jboss.weld.util.annotated.ForwardingAnnotatedType in project core by weld.

the class WeldClassTest method testMemberClassWithGenericTypes.

/*
    * description = "WELD-216"
    */
@Test
public void testMemberClassWithGenericTypes() {
    final AnnotatedType<?> at = transformer.getEnhancedAnnotatedType(new Kangaroo().procreate().getClass(), AnnotatedTypeIdentifier.NULL_BDA_ID);
    transformer.getEnhancedAnnotatedType(new ForwardingAnnotatedType() {

        @Override
        public AnnotatedType delegate() {
            return at;
        }
    }, AnnotatedTypeIdentifier.NULL_BDA_ID);
}
Also used : ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) EnhancedAnnotatedType(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType) ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) Test(org.junit.Test)

Example 3 with ForwardingAnnotatedType

use of org.jboss.weld.util.annotated.ForwardingAnnotatedType in project core by weld.

the class WeldClassTest method testLocalClassWithGenericTypes.

/*
    * description = "WELD-216"
    */
@Test
public /*
    *  Not isolated, depends on someone else initializing Containers.
    *
    *  getUnproxyableClassException() catch(NoSuchMethodException)
    *           InstantiatorFactory.useInstantiators() <-- Needs Containers
    */
void testLocalClassWithGenericTypes() {
    final AnnotatedType<?> at = transformer.getEnhancedAnnotatedType(new Koala().procreate().getClass(), AnnotatedTypeIdentifier.NULL_BDA_ID);
    transformer.getEnhancedAnnotatedType(new ForwardingAnnotatedType() {

        @Override
        public AnnotatedType delegate() {
            return at;
        }
    }, AnnotatedTypeIdentifier.NULL_BDA_ID);
}
Also used : ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) EnhancedAnnotatedType(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType) ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) Test(org.junit.Test)

Example 4 with ForwardingAnnotatedType

use of org.jboss.weld.util.annotated.ForwardingAnnotatedType in project core by weld.

the class WeldClassTest method testAnonymousClassWithGenericTypes.

/*
    * description = "WELD-216"
    */
@Test
public /*
    *  Not isolated, depends on someone else initializing Containers.
    *
    *  getUnproxyableClassException() catch(NoSuchMethodException)
    *           InstantiatorFactory.useInstantiators() <-- Needs Containers
    */
void testAnonymousClassWithGenericTypes() {
    final AnnotatedType<?> at = transformer.getEnhancedAnnotatedType(new Possum().procreate().getClass(), AnnotatedTypeIdentifier.NULL_BDA_ID);
    transformer.getEnhancedAnnotatedType(new ForwardingAnnotatedType() {

        @Override
        public AnnotatedType delegate() {
            return at;
        }
    }, AnnotatedTypeIdentifier.NULL_BDA_ID);
}
Also used : ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) EnhancedAnnotatedType(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType) ForwardingAnnotatedType(org.jboss.weld.util.annotated.ForwardingAnnotatedType) Test(org.junit.Test)

Aggregations

ForwardingAnnotatedType (org.jboss.weld.util.annotated.ForwardingAnnotatedType)4 AnnotatedType (javax.enterprise.inject.spi.AnnotatedType)3 EnhancedAnnotatedType (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType)3 Test (org.junit.Test)3 Annotation (java.lang.annotation.Annotation)1 NamedLiteral (org.jboss.weld.literal.NamedLiteral)1