Refine search
private void validateManagedBean(AnnotatedType<Farm> type) { assert type.getBaseType().equals(Farm.class); assert typeSetMatches(type.getTypeClosure(), Farm.class, Object.class); assert type.getFields().size() == 1; assert type.getFields().iterator().next().isAnnotationPresent(Produces.class); assert type.getMethods().size() == 1; assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class); }
private void validateManagedBean(AnnotatedType<Farm> type) { assert type.getBaseType().equals(Farm.class); assert rawTypeSetMatches(type.getTypeClosure(), Farm.class, Object.class); assert type.getFields().size() == 1; assert type.getFields().iterator().next().isAnnotationPresent(Produces.class); assert type.getMethods().size() == 1; assert type.getMethods().iterator().next().isAnnotationPresent(Produces.class); }
private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) { assertEquals(type.getBaseType(), TagLibraryListener.class); assertTrue(typeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class, EventListener.class, Object.class)); assertEquals(type.getFields().size(), 2); assertEquals(type.getConstructors().size(), 1); assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized"))); }
private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) { assertEquals(type.getBaseType(), TestFilter.class); assertTrue(typeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class)); assertEquals(type.getFields().size(), 12); assertEquals(type.getConstructors().size(), 1); assertTrue(type.getConstructors().iterator().next().getParameters().isEmpty()); assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("doFilter"))); }
private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type) { assert type.getBaseType().equals(SheepInterceptor.class); assert rawTypeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class); assert type.getAnnotations().size() == 0; assert type.getFields().size() == 0; assert type.getMethods().size() == 1; }
private void validateTagLibraryListenerAnnotatedType(AnnotatedType<TagLibraryListener> type) { assert type.getBaseType().equals(TagLibraryListener.class); assert rawTypeSetMatches(type.getTypeClosure(), TagLibraryListener.class, ServletContextListener.class, EventListener.class, Object.class); assert type.getFields().size() == 2; assert type.getConstructors().size() == 1; assert type.getMethods().size() == 3; }
private void validateServletListenerAnnotatedType(AnnotatedType<TestListener> type) { assertEquals(type.getBaseType(), TestListener.class); assertTrue(type.getAnnotations().isEmpty()); assertEquals(type.getFields().size(), 2); assertTrue(type.getMethods().stream().anyMatch(m -> m.getJavaMember().getName().equals("contextInitialized"))); int initializers = 0; for (AnnotatedMethod<?> method : type.getMethods()) { assertEquals(method.getParameters().size(), 1); assertEquals(method.getBaseType(), void.class); if (method.isAnnotationPresent(Inject.class)) { initializers++; } } assertEquals(initializers, 1); }
private void validateSessionBeanInterceptor(AnnotatedType<SheepInterceptor> type) { assert type.getBaseType().equals(SheepInterceptor.class); assert typeSetMatches(type.getTypeClosure(), SheepInterceptor.class, Object.class); assert type.getAnnotations().size() == 0; assert type.getFields().size() == 0; assert type.getMethods().size() == 1; }
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) { super(annotatedType); this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector()); this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector()); this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector()); }
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) { super(annotatedType); this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector()); this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector()); this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector()); }
/** * Generates a unique signature for an annotated type. Members without * annotations are omitted to reduce the length of the signature * * @param <X> * @param annotatedType * @return */ public static <X> String createTypeId(AnnotatedType<X> annotatedType) { return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors()); }
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) { super(annotatedType); this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector()); this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector()); this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector()); }
private void validateFilterAnnotatedType(AnnotatedType<TestFilter> type) { assert type.getBaseType().equals(TestFilter.class); assert rawTypeSetMatches(type.getTypeClosure(), TestFilter.class, Filter.class, Object.class); assert type.getFields().size() == 4; assert type.getConstructors().size() == 1; assert type.getConstructors().iterator().next().getParameters().isEmpty(); assert type.getMethods().size() == 4; }
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) { super(annotatedType); this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector()); this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector()); this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector()); }
public AnnotatedTypeConfiguratorImpl(AnnotatedType<T> annotatedType) { super(annotatedType); this.constructors = annotatedType.getConstructors().stream().map(c -> AnnotatedConstructorConfiguratorImpl.from(c)).collect(ImmutableSet.collector()); this.methods = annotatedType.getMethods().stream().map(m -> AnnotatedMethodConfiguratorImpl.from(m)).collect(ImmutableSet.collector()); this.fields = annotatedType.getFields().stream().map(f -> AnnotatedFieldConfiguratorImpl.from(f)).collect(ImmutableSet.collector()); }
@Test @SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_ANNOTATEDTYPE, id = "a") }) public void testObtainingAnnotatedType() { AnnotatedType<?> annotatedType = getCurrentManager().createAnnotatedType(DerivedBean.class); assertTrue(annotatedType.isAnnotationPresent(Specializes.class)); assertTrue(annotatedType.isAnnotationPresent(Tame.class)); assertEquals(1, annotatedType.getFields().size()); assertTrue(annotatedType.getMethods().isEmpty()); assertEquals(3, annotatedType.getTypeClosure().size()); }
@SuppressWarnings("unchecked") private <X, A extends AnnotatedMember<? super X>> A getAnnotatedMember(Class<X> javaClass, String memberName) { AnnotatedType<X> type = getCurrentManager().createAnnotatedType(javaClass); for (AnnotatedField<? super X> field : type.getFields()) { if (field.getJavaMember().getName().equals(memberName)) { return (A) field; } } for (AnnotatedMethod<? super X> method : type.getMethods()) { if (method.getJavaMember().getName().equals(memberName)) { return (A) method; } } throw new IllegalArgumentException("Member " + memberName + " not found on " + javaClass); }
/** * Generates a deterministic signature for an {@link AnnotatedType}. Two <code>AnnotatedType</code>s that have the * same annotations and underlying type will generate the same signature. * <p/> * This can be used to create a unique bean id for a passivation capable bean that is added directly through the SPI. * * @param annotatedType The type to generate a signature for * @return A string representation of the annotated type */ public static <X> String createTypeId(AnnotatedType<X> annotatedType) { return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors()); }
/** * Generates a deterministic signature for an {@link AnnotatedType}. Two * <code>AnnotatedType</code>s that have the same annotations and underlying * type will generate the same signature. * <p/> * This can be used to create a unique bean id for a passivation capable bean * that is added directly through the SPI. * * @param annotatedType The type to generate a signature for * @return A string representation of the annotated type */ public static <X> String createTypeId(AnnotatedType<X> annotatedType) { return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors()); }
/** * Generates a deterministic signature for an {@link AnnotatedType}. Two <code>AnnotatedType</code>s that have the * same annotations and underlying type will generate the same signature. * <p/> * This can be used to create a unique bean id for a passivation capable bean that is added directly through the SPI. * * @param annotatedType The type to generate a signature for * @return A string representation of the annotated type */ public static <X> String createTypeId(AnnotatedType<X> annotatedType) { return createTypeId(annotatedType.getJavaClass(), annotatedType.getAnnotations(), annotatedType.getMethods(), annotatedType.getFields(), annotatedType.getConstructors()); }