public static ProcessAnnotatedTypeEventResolvable forProcessAnnotatedType(SlimAnnotatedType<?> annotatedType, RequiredAnnotationDiscovery discovery) { ParameterizedType type = new ParameterizedTypeImpl(ProcessAnnotatedType.class, new Type[] { annotatedType.getJavaClass() }, null); return new ProcessAnnotatedTypeEventResolvable(Sets.<Type> newHashSet(Object.class, type), annotatedType, discovery); }
protected boolean containsAnnotation(UnbackedAnnotatedType<?> annotatedType, Collection<Class<? extends Annotation>> requiredAnnotations) { for (final Class<? extends Annotation> requiredAnnotation : requiredAnnotations) { if (apply(annotatedType, requiredAnnotation)) { return true; } } return false; }
/** * Returns true if and only if the underlying {@link AnnotatedType} contains any of the given annotation types. */ public boolean containsRequiredAnnotations(Collection<Class<? extends Annotation>> requiredAnnotations) { if (annotatedType instanceof BackedAnnotatedType<?>) { return containsAnnotation((BackedAnnotatedType<?>) annotatedType, requiredAnnotations); } else if (annotatedType instanceof UnbackedAnnotatedType<?>) { return containsAnnotation((UnbackedAnnotatedType<?>) annotatedType, requiredAnnotations); } else { throw new IllegalArgumentException("Unknown SlimAnnotatedType implementation: " + annotatedType.getClass().toString()); } }
public static ProcessAnnotatedTypeEventResolvable of(ProcessAnnotatedTypeImpl<?> event, RequiredAnnotationDiscovery discovery) { if (event instanceof ProcessSyntheticAnnotatedType) { return forProcessSyntheticAnnotatedType(event.getOriginalAnnotatedType(), discovery); } else { return forProcessAnnotatedType(event.getOriginalAnnotatedType(), discovery); } }
private <T> void addContainerLifecycleEvent(T event, Object info, BeanManagerImpl beanManagerImpl) { ResolvedObservers<?> resolvedObservers = null; Type eventType = null; if (event instanceof AbstractContainerEvent) { AbstractContainerEvent containerEvent = (AbstractContainerEvent) event; eventType = containerEvent.getEventType(); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods(eventType); } else if (event instanceof ProcessAnnotatedTypeImpl) { ProcessAnnotatedTypeImpl<?> processAnnotatedTypeEvent = (ProcessAnnotatedTypeImpl<?>) event; eventType = ProcessAnnotatedType.class; info = Formats.formatType(processAnnotatedTypeEvent.getOriginalAnnotatedType().getBaseType(), false); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods( ProcessAnnotatedTypeEventResolvable.of(processAnnotatedTypeEvent, beanManagerImpl.getServices().get(RequiredAnnotationDiscovery.class))); } if (resolvedObservers != null && eventType != null) { probe.addEvent(new EventInfo(eventType, Collections.emptySet(), info, null, Reflections.cast(resolvedObservers.getAllObservers()), true, System.currentTimeMillis(), false)); } }
/** * Fires a {@link ProcessAnnotatedType} or {@link ProcessSyntheticAnnotatedType} using the default event mechanism. */ private void fireProcessAnnotatedType(ProcessAnnotatedTypeImpl<?> event, BeanManagerImpl beanManager) { final Resolvable resolvable = ProcessAnnotatedTypeEventResolvable.of(event, discovery); try { beanManager.getGlobalLenientObserverNotifier().fireEvent(event, resolvable); } catch (Exception e) { throw new DefinitionException(e); } }
@Override protected boolean matches(Resolvable resolvable, ObserverMethod<?> observer) { if (!rules.matches(observer.getObservedType(), resolvable.getTypes())) { return false; } if (!Beans.containsAllQualifiers(QualifierInstance.of(observer.getObservedQualifiers(), metaAnnotationStore), resolvable.getQualifiers())) { return false; } if (observer instanceof ContainerLifecycleEventObserverMethod) { ContainerLifecycleEventObserverMethod<?> lifecycleObserver = (ContainerLifecycleEventObserverMethod<?>) observer; if (resolvable instanceof ProcessAnnotatedTypeEventResolvable && !lifecycleObserver.getRequiredAnnotations().isEmpty()) { // this is a ProcessAnnotatedType observer method with @WithAnnotations and a resolvable for ProcessAnnotatedType ProcessAnnotatedTypeEventResolvable patResolvable = (ProcessAnnotatedTypeEventResolvable) resolvable; return patResolvable.containsRequiredAnnotations(lifecycleObserver.getRequiredAnnotations()); } } else { return !isContainerLifecycleEvent(resolvable); // container lifecycle events are only delivered to extensions } return true; }
if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true;
private <T> void addContainerLifecycleEvent(T event, Object info, BeanManagerImpl beanManagerImpl) { ResolvedObservers<?> resolvedObservers = null; Type eventType = null; if (event instanceof AbstractContainerEvent) { AbstractContainerEvent containerEvent = (AbstractContainerEvent) event; eventType = containerEvent.getEventType(); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods(eventType); } else if (event instanceof ProcessAnnotatedTypeImpl) { ProcessAnnotatedTypeImpl<?> processAnnotatedTypeEvent = (ProcessAnnotatedTypeImpl<?>) event; eventType = ProcessAnnotatedType.class; info = Formats.formatType(processAnnotatedTypeEvent.getOriginalAnnotatedType().getBaseType(), false); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods( ProcessAnnotatedTypeEventResolvable.of(processAnnotatedTypeEvent, beanManagerImpl.getServices().get(RequiredAnnotationDiscovery.class))); } if (resolvedObservers != null && eventType != null) { Iterable<ObserverMethod<?>> observerMethods = Reflections.cast(resolvedObservers.getAllObservers()); probe.addEvent(new EventInfo(eventType, Collections.<Annotation> emptySet(), info, null, observerMethods, true, System.currentTimeMillis(), false)); } }
/** * Fires a {@link ProcessAnnotatedType} or {@link ProcessSyntheticAnnotatedType} using the default event mechanism. */ private void fireProcessAnnotatedType(ProcessAnnotatedTypeImpl<?> event, BeanManagerImpl beanManager) { final Resolvable resolvable = ProcessAnnotatedTypeEventResolvable.of(event, discovery); try { beanManager.getGlobalLenientObserverNotifier().fireEvent(event, resolvable); } catch (Exception e) { throw new DefinitionException(e); } }
public static ProcessAnnotatedTypeEventResolvable of(ProcessAnnotatedTypeImpl<?> event, RequiredAnnotationDiscovery discovery) { if (event instanceof ProcessSyntheticAnnotatedType) { return forProcessSyntheticAnnotatedType(event.getOriginalAnnotatedType(), discovery); } else { return forProcessAnnotatedType(event.getOriginalAnnotatedType(), discovery); } }
@Override protected boolean matches(Resolvable resolvable, ObserverMethod<?> observer) { if (!rules.matches(observer.getObservedType(), resolvable.getTypes())) { return false; } if (!Beans.containsAllQualifiers(QualifierInstance.of(observer.getObservedQualifiers(), metaAnnotationStore), resolvable.getQualifiers())) { return false; } if (observer instanceof ContainerLifecycleEventObserverMethod) { ContainerLifecycleEventObserverMethod<?> lifecycleObserver = (ContainerLifecycleEventObserverMethod<?>) observer; if (resolvable instanceof ProcessAnnotatedTypeEventResolvable && !lifecycleObserver.getRequiredAnnotations().isEmpty()) { // this is a ProcessAnnotatedType observer method with @WithAnnotations and a resolvable for ProcessAnnotatedType ProcessAnnotatedTypeEventResolvable patResolvable = (ProcessAnnotatedTypeEventResolvable) resolvable; return patResolvable.containsRequiredAnnotations(lifecycleObserver.getRequiredAnnotations()); } } else { return !isContainerLifecycleEvent(resolvable); // container lifecycle events are only delivered to extensions } return true; }
if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true; if (isEqualOrAnnotated(requiredAnnotation, annotation)) { return true;
private <T> void addContainerLifecycleEvent(T event, Object info, BeanManagerImpl beanManagerImpl) { ResolvedObservers<?> resolvedObservers = null; Type eventType = null; if (event instanceof AbstractContainerEvent) { AbstractContainerEvent containerEvent = (AbstractContainerEvent) event; eventType = containerEvent.getEventType(); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods(eventType); } else if (event instanceof ProcessAnnotatedTypeImpl) { ProcessAnnotatedTypeImpl<?> processAnnotatedTypeEvent = (ProcessAnnotatedTypeImpl<?>) event; eventType = ProcessAnnotatedType.class; info = Formats.formatType(processAnnotatedTypeEvent.getOriginalAnnotatedType().getBaseType(), false); resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods( ProcessAnnotatedTypeEventResolvable.of(processAnnotatedTypeEvent, beanManagerImpl.getServices().get(RequiredAnnotationDiscovery.class))); } if (resolvedObservers != null && eventType != null) { probe.addEvent(new EventInfo(eventType, Collections.emptySet(), info, null, Reflections.cast(resolvedObservers.getAllObservers()), true, System.currentTimeMillis(), false)); } }
public static ProcessAnnotatedTypeEventResolvable forProcessSyntheticAnnotatedType(SlimAnnotatedType<?> annotatedType, RequiredAnnotationDiscovery discovery) { ParameterizedType type1 = new ParameterizedTypeImpl(ProcessAnnotatedType.class, new Type[] { annotatedType.getJavaClass() }, null); ParameterizedType type2 = new ParameterizedTypeImpl(ProcessSyntheticAnnotatedType.class, new Type[] { annotatedType.getJavaClass() }, null); return new ProcessAnnotatedTypeEventResolvable(Sets.<Type> newHashSet(Object.class, type1, type2), annotatedType, discovery); }
/** * Fires a {@link ProcessAnnotatedType} or {@link ProcessSyntheticAnnotatedType} using the default event mechanism. */ private void fireProcessAnnotatedType(ProcessAnnotatedTypeImpl<?> event, BeanManagerImpl beanManager) { final Resolvable resolvable = ProcessAnnotatedTypeEventResolvable.of(event, discovery); try { beanManager.getGlobalLenientObserverNotifier().fireEvent(event, resolvable); } catch (Exception e) { throw new DefinitionException(e); } }
public static ProcessAnnotatedTypeEventResolvable of(ProcessAnnotatedTypeImpl<?> event, RequiredAnnotationDiscovery discovery) { if (event instanceof ProcessSyntheticAnnotatedType) { return forProcessSyntheticAnnotatedType(event.getOriginalAnnotatedType(), discovery); } else { return forProcessAnnotatedType(event.getOriginalAnnotatedType(), discovery); } }
protected boolean containsAnnotation(UnbackedAnnotatedType<?> annotatedType, Collection<Class<? extends Annotation>> requiredAnnotations) { for (final Class<? extends Annotation> requiredAnnotation : requiredAnnotations) { if (apply(annotatedType, requiredAnnotation)) { return true; } } return false; }
/** * Returns true if and only if the underlying {@link AnnotatedType} contains any of the given annotation types. */ public boolean containsRequiredAnnotations(Collection<Class<? extends Annotation>> requiredAnnotations) { if (annotatedType instanceof BackedAnnotatedType<?>) { return containsAnnotation((BackedAnnotatedType<?>) annotatedType, requiredAnnotations); } else if (annotatedType instanceof UnbackedAnnotatedType<?>) { return containsAnnotation((UnbackedAnnotatedType<?>) annotatedType, requiredAnnotations); } else { throw new IllegalArgumentException("Unknown SlimAnnotatedType implementation: " + annotatedType.getClass().toString()); } }
@Override protected boolean matches(Resolvable resolvable, ObserverMethod<?> observer) { if (!rules.matches(observer.getObservedType(), resolvable.getTypes())) { return false; } if (!Beans.containsAllQualifiers(QualifierInstance.of(observer.getObservedQualifiers(), metaAnnotationStore), resolvable.getQualifiers())) { return false; } if (observer instanceof ContainerLifecycleEventObserverMethod) { ContainerLifecycleEventObserverMethod<?> lifecycleObserver = (ContainerLifecycleEventObserverMethod<?>) observer; if (resolvable instanceof ProcessAnnotatedTypeEventResolvable && !lifecycleObserver.getRequiredAnnotations().isEmpty()) { // this is a ProcessAnnotatedType observer method with @WithAnnotations and a resolvable for ProcessAnnotatedType ProcessAnnotatedTypeEventResolvable patResolvable = (ProcessAnnotatedTypeEventResolvable) resolvable; return patResolvable.containsRequiredAnnotations(lifecycleObserver.getRequiredAnnotations()); } } else { return !isContainerLifecycleEvent(resolvable); // container lifecycle events are only delivered to extensions } return true; }