private static <T> void processClass(AnnotatedTypeBuilder<T> builder, String name ) { builder.addToClass(new AnnotationLiteral<ApplicationScoped>(){private static final long serialVersionUID = 1L;}); builder.addToClass(EJbQualifierLiteral.INSTANCE); if(!name.isEmpty() ) { builder.addToClass(new EJbNameLiteral(name)); } else { builder.addToClass(DefaultLiteral.INSTANCE); } } }
private static <T> void processClass(AnnotatedTypeBuilder<T> builder, String name ) { builder.addToClass(new AnnotationLiteral<ApplicationScoped>(){private static final long serialVersionUID = 1L;}); builder.addToClass(EJbQualifierLiteral.INSTANCE); if(!name.isEmpty() ) { builder.addToClass(new EJbNameLiteral(name)); } else { builder.addToClass(DefaultLiteral.INSTANCE); } } }
private <T> void processClass(AnnotatedTypeBuilder<T> builder, String name, boolean isSingleton, boolean scopeIsPresent) { logger.trace("processing class: {} singleton: {} scopeIsPresent: {}", name, isSingleton, scopeIsPresent); if (!scopeIsPresent) { if (!isSingleton || builder.getJavaClass().getFields().length > 0) { builder.addToClass(createDependentAnnotation()); } else { builder.addToClass(createApplicationScopedAnnotation()); // For Singleton normally only ApplicationScoped } } builder.addToClass(createDefaultAnnotation()); if (!name.isEmpty()) { builder.addToClass(new EjbName.EjbNameLiteral(name)); } else { builder.addToClass(DefaultLiteral.INSTANCE); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
public AnnotatedType<T> invoke() { if (ReflectionsUtils.isPossibleCdiBean(delegate.getJavaClass())) { final AnnotatedTypeBuilder<T> typeBuilder = new AnnotatedTypeBuilder<>(); typeBuilder.readFromType(delegate); for (Map.Entry<Class<? extends Annotation>, Annotation> replacement : replacementMap.entrySet()) { final Class<? extends Annotation> toReplace = replacement.getKey(); if (delegate.isAnnotationPresent(toReplace)) { typeBuilder.addToClass(replacement.getValue()); } } return typeBuilder.create(); } else { return delegate; } } }
private <X> void copyAnnotation(final ProcessAnnotatedType<X> annotatedType, final Class<?> anInterface, final Method method, final Class<? extends Annotation> annotation) { final Annotation methodAnnotation = method.getAnnotation(annotation); final Annotation typeAnnotation = anInterface.getAnnotation(annotation); if (methodAnnotation != null || typeAnnotation != null) { AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(annotatedType.getAnnotatedType()); if (typeAnnotation != null) { builder = builder.addToClass(typeAnnotation); } if (methodAnnotation != null) { builder = builder.addToMethod(getMethod(annotatedType, method.getName()), methodAnnotation); } annotatedType.setAnnotatedType(builder.create()); } }
private <X> void createEJBWrapper(ProcessAnnotatedType<X> pat, final AnnotatedType<X> at) { EjbAsynchronous ejbAsynchronous = AnnotationInstanceProvider.of(EjbAsynchronous.class); EjbTransactional transactionalAnnotation = AnnotationInstanceProvider.of(EjbTransactional.class); AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(at); builder.addToClass(transactionalAnnotation); if (possiblyAsynchronous(at)) { builder.addToClass(ejbAsynchronous); } // by annotating let CDI set Wrapper to this Bean pat.setAnnotatedType(builder.create()); }
@SuppressWarnings("serial") public <T> void processAnnotatedType( @Observes @WithAnnotations(Path.class) ProcessAnnotatedType<T> processAnnotatedType) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>() .readFromType(processAnnotatedType.getAnnotatedType()) .addToClass(new AnnotationLiteral<Exceptionable>() {}); processAnnotatedType.setAnnotatedType(builder.create()); }
public <T> void processAuthenticationServiceTypes(@Observes final ProcessAnnotatedType<T> processedAnnotatedType) { final Class<T> type = processedAnnotatedType.getAnnotatedType().getJavaClass(); if (isNonKeycloakAuthenticationService(type)) { processedAnnotatedType.setAnnotatedType(new AnnotatedTypeBuilder<T>() .readFromType(processedAnnotatedType.getAnnotatedType()).removeFromClass(Default.class) .addToClass(wrapped).create()); } }
private void guessReplacableTypes() { builder.removeFromClass(ActivatableTestImplementation.class); final ImmutableActivatableTestImplementation.Builder anntationBuilder = ImmutableActivatableTestImplementation.builder(); this.builder.addToClass(anntationBuilder.value(determineUniqueSuperclass()).build()); }
void invoke() { ActivatableTestImplementation implementation = type.getAnnotation(ActivatableTestImplementation.class); if (implementation.value().length == 0) { guessReplacableTypes(); } builder.addToClass(new TypedLiteral() { @Override public Class<?>[] value() { return new Class[]{javaClass}; } }); pat.setAnnotatedType(builder.create()); }
public <T> void onAnnotatedType(@Observes @WithAnnotations(Transactional.class) ProcessAnnotatedType<T> annotatedType) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>() .readFromType(annotatedType.getAnnotatedType()) .addToClass(AnnotationInstanceProvider.of(org.apache.deltaspike.jpa.api.transaction.Transactional.class)); annotatedType.setAnnotatedType(builder.create()); }
/** * Add an annotation to the class represented by pat. * * @param pat ProcessAnnotatedType for bean. * @param annotation annotation literal to add to the type. * @param <X> any type. */ public static <X> void addClassAnnotation(ProcessAnnotatedType<X> pat, Annotation annotation) { AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<>(); builder.readFromType(pat.getAnnotatedType()); pat.setAnnotatedType(builder.addToClass(annotation).create()); } }
@Test public void testCtWithMultipleParams() { final AnnotatedTypeBuilder<TypeWithParamsInCt> builder = new AnnotatedTypeBuilder<TypeWithParamsInCt>(); builder.readFromType(TypeWithParamsInCt.class); builder.addToClass(new AnnotationLiteral<Default>() {}); AnnotatedType<TypeWithParamsInCt> newAt = builder.create(); assertNotNull(newAt); }
@Test public void testAdditionOfAnnotation() { final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>(); builder.readFromType(Cat.class, true); builder.addToClass(new TypedLiteral()); final AnnotatedType<Cat> catAnnotatedType = builder.create(); assertThat(catAnnotatedType.isAnnotationPresent(Typed.class), is(true)); }
@Test public void testEnumWithParam() { final AnnotatedTypeBuilder<EnumWithParams> builder = new AnnotatedTypeBuilder<EnumWithParams>(); builder.readFromType(EnumWithParams.class); builder.addToClass(new AnnotationLiteral<Default>() {}); AnnotatedType<EnumWithParams> newAt = builder.create(); assertNotNull(newAt); }
private <T> void beanRegisterer(Class<T> clazz, Annotation qual, Class<? extends Annotation> scope, AfterBeanDiscovery abd, BeanManager beanManager, Type... types) { AnnotatedTypeBuilder<T> atb = new AnnotatedTypeBuilder<T>() .readFromType(clazz) .addToClass(qual) .setJavaClass(clazz); applyQualifier(qual, atb); BeanBuilder<T> providerBuilder = new BeanBuilder<T>(beanManager) .readFromType(atb.create()) .passivationCapable(true) .addTypes(types); if (scope != null) { providerBuilder.scope(scope); } Bean<T> newBean = providerBuilder.create(); abd.addBean(newBean); }