use of org.jboss.weld.event.ContainerLifecycleEventObserverMethod in project core by weld.
the class JsonObjects method isUnrestrictedProcessAnnotatedTypeObserver.
private static boolean isUnrestrictedProcessAnnotatedTypeObserver(ObserverMethod<?> observerMethod) {
if (observerMethod instanceof ContainerLifecycleEventObserverMethod) {
ContainerLifecycleEventObserverMethod<?> containerLifecycleObserverMethod = (ContainerLifecycleEventObserverMethod<?>) observerMethod;
Class<?> rawObserverType = Reflections.getRawType(containerLifecycleObserverMethod.getObservedType());
if ((rawObserverType.equals(ProcessAnnotatedType.class) || rawObserverType.equals(ProcessSyntheticAnnotatedType.class)) && containerLifecycleObserverMethod.getRequiredAnnotations().isEmpty()) {
Type eventType = containerLifecycleObserverMethod.getObservedType();
Type[] typeArguments;
if (eventType instanceof ParameterizedType) {
typeArguments = ((ParameterizedType) eventType).getActualTypeArguments();
} else {
typeArguments = Arrays2.EMPTY_TYPE_ARRAY;
}
if (typeArguments.length == 0 || Reflections.isUnboundedWildcard(typeArguments[0]) || Reflections.isUnboundedTypeVariable(typeArguments[0])) {
return true;
}
}
}
return false;
}
use of org.jboss.weld.event.ContainerLifecycleEventObserverMethod 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.event.ContainerLifecycleEventObserverMethod 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