private boolean isInterceptionCandidate() { return !isInterceptor() && !isDecorator() && !Modifier.isAbstract(getType().getJavaClass().getModifiers()); }
private boolean isInterceptor() { return (getBean() instanceof Interceptor<?>) || getType().isAnnotationPresent(javax.interceptor.Interceptor.class); }
Class<? super T> superclass = annotatedType.getJavaClass().getSuperclass(); if (superclass == null) { this.superclass = null; } else { this.superclass = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId()); Class<T> javaClass = annotatedType.getJavaClass(); for (AnnotatedField<? super T> field : annotatedType.getFields()) { if (field.getJavaMember().getDeclaringClass().equals(javaClass)) { EnhancedAnnotatedField<?, ? super T> annotatedField = EnhancedAnnotatedFieldImpl.of(field, this, classTransformer); Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>> annotatedFields = new ListMultimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>>(); fieldsTemp = new HashSet<EnhancedAnnotatedField<?, ? super T>>(); for (AnnotatedField<? super T> annotatedField : annotatedType.getFields()) { EnhancedAnnotatedField<?, ? super T> weldField = EnhancedAnnotatedFieldImpl.of(annotatedField, this, classTransformer); fieldsTemp.add(weldField); for (AnnotatedConstructor<T> constructor : annotatedType.getConstructors()) { EnhancedAnnotatedConstructor<T> weldConstructor = EnhancedAnnotatedConstructorImpl.of(constructor, this, classTransformer); this.constructors.add(weldConstructor); if (discovered) { if (!(javaClass.equals(Object.class))) { for (AnnotatedMethod<? super T> method : annotatedType.getMethods()) { if (method.getJavaMember().getDeclaringClass().equals(javaClass)) { EnhancedAnnotatedMethod<?, ? super T> weldMethod = EnhancedAnnotatedMethodImpl.of(method, this, classTransformer); EnhancedAnnotatedType<?> interfaceType = classTransformer.getEnhancedAnnotatedType(interfaceClazz, slim.getIdentifier().getBdaId());
Class<? super T> superclass = annotatedType.getJavaClass().getSuperclass(); if (superclass == null) { this.superclass = null; } else { this.superclass = classTransformer.getEnhancedAnnotatedType(superclass, slim.getIdentifier().getBdaId()); Class<T> javaClass = annotatedType.getJavaClass(); for (AnnotatedField<? super T> field : annotatedType.getFields()) { if (field.getJavaMember().getDeclaringClass().equals(javaClass)) { EnhancedAnnotatedField<?, ? super T> annotatedField = EnhancedAnnotatedFieldImpl.of(field, this, classTransformer); Multimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>> annotatedFields = new ListMultimap<Class<? extends Annotation>, EnhancedAnnotatedField<?, ?>>(); fieldsTemp = new HashSet<EnhancedAnnotatedField<?, ? super T>>(); for (AnnotatedField<? super T> annotatedField : annotatedType.getFields()) { EnhancedAnnotatedField<?, ? super T> weldField = EnhancedAnnotatedFieldImpl.of(annotatedField, this, classTransformer); fieldsTemp.add(weldField); for (AnnotatedConstructor<T> constructor : annotatedType.getConstructors()) { EnhancedAnnotatedConstructor<T> weldConstructor = EnhancedAnnotatedConstructorImpl.of(constructor, this, classTransformer); this.constructors.add(weldConstructor); if (discovered) { if (!(javaClass.equals(Object.class))) { for (AnnotatedMethod<? super T> method : annotatedType.getMethods()) { if (method.getJavaMember().getDeclaringClass().equals(javaClass)) { EnhancedAnnotatedMethod<?, ? super T> weldMethod = EnhancedAnnotatedMethodImpl.of(method, this, classTransformer); EnhancedAnnotatedType<?> interfaceType = classTransformer.getEnhancedAnnotatedType(interfaceClazz, slim.getIdentifier().getBdaId());
public static String forProducerMethod(EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (declaringBean.getEnhancedAnnotated().isDiscovered()) { return forProducerMethod(declaringBean.getAnnotated().getIdentifier(), DeclaredMemberIndexer.getIndexForMethod(method.getJavaMember())); } return getPrefix(ProducerMethod.class).append(method.getDeclaringType().slim().getIdentifier()).append(AnnotatedTypes.createCallableId(method)).toString(); }
public static String forProducerField(EnhancedAnnotatedField<?, ?> field, AbstractClassBean<?> declaringBean) { StringBuilder sb = getPrefix(ProducerField.class).append(declaringBean.getAnnotated().getIdentifier().asString()) .append(BEAN_ID_SEPARATOR); if (declaringBean.getEnhancedAnnotated().isDiscovered()) { sb.append(field.getName()); } else { sb.append(AnnotatedTypes.createFieldId(field)); } return sb.toString(); }
protected void createClassBean(SlimAnnotatedType<?> annotatedType, SetMultimap<Class<?>, SlimAnnotatedType<?>> otherWeldClasses) { boolean managedBeanOrDecorator = !ejbSupport.isEjb(annotatedType.getJavaClass()) && Beans.isTypeManagedBeanOrDecoratorOrInterceptor(annotatedType); if (managedBeanOrDecorator) { containerLifecycleEvents.preloadProcessInjectionTarget(annotatedType.getJavaClass()); containerLifecycleEvents.preloadProcessBeanAttributes(annotatedType.getJavaClass()); EnhancedAnnotatedType<?> weldClass = classTransformer.getEnhancedAnnotatedType(annotatedType); if (weldClass.isAnnotationPresent(Decorator.class)) { containerLifecycleEvents.preloadProcessBean(ProcessBean.class, annotatedType.getJavaClass()); validateDecorator(weldClass); createDecorator(weldClass); } else if (weldClass.isAnnotationPresent(Interceptor.class)) { containerLifecycleEvents.preloadProcessBean(ProcessBean.class, annotatedType.getJavaClass()); validateInterceptor(weldClass); createInterceptor(weldClass); } else if (!weldClass.isAbstract()) { containerLifecycleEvents.preloadProcessBean(ProcessManagedBean.class, annotatedType.getJavaClass()); createManagedBean(weldClass); } } else { if (Beans.isDecoratorDeclaringInAppropriateConstructor(annotatedType)) { BootstrapLogger.LOG.decoratorWithNonCdiConstructor(annotatedType.getJavaClass().getName()); } Class<? extends Annotation> scopeClass = Beans.getBeanDefiningAnnotationScope(annotatedType); if (scopeClass != null && !Beans.hasSimpleCdiConstructor(annotatedType)) { BootstrapLogger.LOG.annotatedTypeNotRegisteredAsBeanDueToMissingAppropriateConstructor(annotatedType.getJavaClass().getName(), scopeClass.getSimpleName()); } otherWeldClasses.put(annotatedType.getJavaClass(), annotatedType); } }
public static String forSessionBean(EnhancedAnnotatedType<?> type, EjbDescriptor<?> descriptor) { StringBuilder builder = getPrefix(SessionBean.class); appendEjbNameAndClass(builder, descriptor); if (!type.isDiscovered()) { builder.append(BEAN_ID_SEPARATOR).append(type.slim().getIdentifier().asString()); } return builder.toString(); }
protected void processMetaAnnotations(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, ClassTransformer classTransformer, boolean declared) { // WELD-1310 Include synthetic annotations SlimAnnotatedType<?> syntheticAnnotationAnnotatedType = classTransformer.getSyntheticAnnotationAnnotatedType(annotation.annotationType()); if (syntheticAnnotationAnnotatedType != null) { addMetaAnnotations(metaAnnotationMap, annotation, syntheticAnnotationAnnotatedType.getAnnotations(), declared); } else { addMetaAnnotations(metaAnnotationMap, annotation, classTransformer.getReflectionCache().getAnnotations(annotation.annotationType()), declared); ReflectionCache.AnnotationClass<?> annotationClass = classTransformer.getReflectionCache().getAnnotationClass(annotation.annotationType()); if (annotationClass.isRepeatableAnnotationContainer()) { processMetaAnnotations(metaAnnotationMap, annotationClass.getRepeatableAnnotations(annotation), classTransformer, declared); } } addMetaAnnotations(metaAnnotationMap, annotation, classTransformer.getTypeStore().get(annotation.annotationType()), declared); }
/** * Constructor * <p/> * Initializes the superclass with the built annotation map * * @param annotationType The annotation type */ protected EnhancedAnnotationImpl(SlimAnnotatedType<T> annotatedType, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer) { super(annotatedType, annotationMap, declaredAnnotationMap, classTransformer); this.clazz = annotatedType.getJavaClass(); members = new HashSet<EnhancedAnnotatedMethod<?, ?>>(); annotatedMembers = SetMultimap.newSetMultimap(); for (AnnotatedMethod<? super T> annotatedMethod : annotatedType.getMethods()) { EnhancedAnnotatedMethod<?, ? super T> enhancedAnnotatedMethod = EnhancedAnnotatedMethodImpl.of(annotatedMethod, this, classTransformer); members.add(enhancedAnnotatedMethod); for (Annotation annotation : enhancedAnnotatedMethod.getAnnotations()) { annotatedMembers.put(annotation.annotationType(), enhancedAnnotatedMethod); } } }
protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) { ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId()); return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass); }
public static <A extends Annotation> EnhancedAnnotation<A> create(SlimAnnotatedType<A> annotatedType, ClassTransformer classTransformer) { Class<A> annotationType = annotatedType.getJavaClass(); Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>(); annotationMap.putAll(buildAnnotationMap(annotatedType.getAnnotations())); annotationMap.putAll(buildAnnotationMap(classTransformer.getTypeStore().get(annotationType))); // Annotations and declared annotations are the same for annotation type return new EnhancedAnnotationImpl<A>(annotatedType, annotationMap, annotationMap, classTransformer); }
public static <T> EnhancedAnnotatedType<T> of(SlimAnnotatedType<T> annotatedType, ClassTransformer classTransformer) { if (annotatedType instanceof BackedAnnotatedType<?>) { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(classTransformer.getReflectionCache().getDeclaredAnnotations(annotatedType.getJavaClass())), classTransformer); } else { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(annotatedType.getAnnotations()), classTransformer); } }
SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap = SetMultimap.newSetMultimap(); for (Annotation annotation : annotationMap.values()) { .getSyntheticAnnotationAnnotatedType(annotation.annotationType()); if (syntheticAnnotationAnnotatedType == null) { addMetaAnnotations(metaAnnotationMap, annotation, classTransformer.getReflectionCache().getAnnotations(annotation.annotationType()), false); } else { addMetaAnnotations(metaAnnotationMap, annotation, syntheticAnnotationAnnotatedType.getAnnotations(), false); addMetaAnnotations(metaAnnotationMap, annotation, classTransformer.getTypeStore().get(annotation.annotationType()), false);
private ProcessSessionBeanImpl(BeanManagerImpl beanManager, SessionBean<Object> bean) { super(beanManager, ProcessSessionBean.class, new Type[]{bean.getAnnotated().getBaseType()}, bean); }
protected String createTypeId(RIBean<?> declaringBean) { String typeId = null; if (declaringBean instanceof AbstractClassBean<?>) { AbstractClassBean<?> classBean = (AbstractClassBean<?>) declaringBean; typeId = classBean.getAnnotated().getIdentifier().asString(); } else { typeId = declaringBean.getBeanClass().getName(); } return typeId; }
public boolean isSessionBeanWithContainerManagedTransactions(Bean<?> bean) { if (bean instanceof SessionBean<?>) { SessionBean<?> sessionBean = (SessionBean<?>) bean; Annotation transactionManagementAnnotation = sessionBean.getAnnotated().getAnnotation(TRANSACTION_MANAGEMENT); if (transactionManagementAnnotation == null || transactionManagementAnnotation instanceof DummyAnnotation) { return true; } Object value; try { Method method = transactionManagementAnnotation.annotationType().getMethod("value"); value = method.invoke(transactionManagementAnnotation); } catch (NoSuchMethodException e) { return true; } catch (Exception e) { throw new WeldException(e); } return CONTAINER_MANAGED_TRANSACTION_MANAGEMENT_ENUM_VALUE.equals(value); } return false; }
@Override public Set<Type> getTypes() { return annotatedType.getTypeClosure(); }
@Override protected void preSpecialize() { super.preSpecialize(); Class<?> superclass = getAnnotated().getJavaClass().getSuperclass(); if (superclass == null || superclass.equals(Object.class)) { throw BeanLogger.LOG.specializingBeanMustExtendABean(this); } }
private int getPriority(Handler<?> handler) { Bean<?> bean = handler.getBean(); if (bean instanceof AbstractClassBean) { AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean; Object priority = classBean.getAnnotated().getAnnotation(annotationApi.PRIORITY_ANNOTATION_CLASS); if (priority != null) { return annotationApi.getPriority(priority); } } return 0; }