use of org.jboss.weld.resources.spi.ClassFileInfo in project core by weld.
the class FastProcessAnnotatedTypeResolver method resolveProcessAnnotatedTypeObservers.
/**
* Resolves a set of {@code ProcessAnnotatedType} observer methods for the specified class. If no observer methods are resolved, an
* empty set is returned.
*
* @param className the specified class name
* @return the set of resolved ProcessAnnotatedType observer methods
*/
public Set<ContainerLifecycleEventObserverMethod<?>> resolveProcessAnnotatedTypeObservers(ClassFileServices classFileServices, String className) {
Set<ContainerLifecycleEventObserverMethod<?>> result = new HashSet<ContainerLifecycleEventObserverMethod<?>>();
result.addAll(catchAllObservers);
ClassFileInfo classInfo = classFileServices.getClassFileInfo(className);
for (Map.Entry<ContainerLifecycleEventObserverMethod<?>, Predicate<ClassFileInfo>> entry : observers.entrySet()) {
ContainerLifecycleEventObserverMethod<?> observer = entry.getKey();
if (containsRequiredAnnotation(classInfo, observer) && entry.getValue().test(classInfo)) {
result.add(observer);
}
}
return result;
}
use of org.jboss.weld.resources.spi.ClassFileInfo in project core by weld.
the class FastAnnotatedTypeLoader method loadAnnotatedType.
@Override
public <T> SlimAnnotatedTypeContext<T> loadAnnotatedType(String className, String bdaId) {
try {
final ClassFileInfo classFileInfo = classFileServices.getClassFileInfo(className);
// firstly, check if this class is an annotation
if ((classFileInfo.getModifiers() & BytecodeUtils.ANNOTATION) != 0) {
// This is an annotation - an annotation may not end up as a managed bean nor be observer by PAT observer. Skip it.
return null;
}
if (classFileInfo.isVetoed()) {
return null;
}
// secondly, let's resolve PAT observers for this class
Set<ContainerLifecycleEventObserverMethod<?>> observerMethods = Collections.emptySet();
if (containerLifecycleEvents.isProcessAnnotatedTypeObserved()) {
observerMethods = resolver.resolveProcessAnnotatedTypeObservers(classFileServices, className);
if (!observerMethods.isEmpty()) {
// there are PAT observers for this class, register the class now
return createContext(className, classFileInfo, observerMethods, bdaId);
}
}
if (Beans.isDecoratorDeclaringInAppropriateConstructor(classFileInfo)) {
BootstrapLogger.LOG.decoratorWithNonCdiConstructor(classFileInfo.getClassName());
}
// lastly, check if this class fulfills CDI managed bean requirements - if it does, add the class
if (Beans.isTypeManagedBeanOrDecoratorOrInterceptor(classFileInfo, checkTypeModifiers)) {
return createContext(className, classFileInfo, observerMethods, bdaId);
}
return null;
} catch (ClassFileInfoException e) {
BootstrapLogger.LOG.exceptionLoadingAnnotatedType(e.getMessage());
return fallback.loadAnnotatedType(className, bdaId);
}
}
Aggregations