Search in sources :

Example 1 with Reception

use of jakarta.enterprise.event.Reception in project core by weld.

the class ObserverMethodConfiguratorImpl method read.

@Override
public ObserverMethodConfigurator<T> read(AnnotatedMethod<?> method) {
    checkArgumentNotNull(method);
    Set<AnnotatedParameter<?>> eventParameters = method.getParameters().stream().filter((p) -> p.isAnnotationPresent(Observes.class) || p.isAnnotationPresent(ObservesAsync.class)).collect(Collectors.toSet());
    checkEventParams(eventParameters, method.getJavaMember());
    AnnotatedParameter<?> eventParameter = eventParameters.iterator().next();
    Observes observesAnnotation = eventParameter.getAnnotation(Observes.class);
    if (observesAnnotation != null) {
        reception(observesAnnotation.notifyObserver());
        transactionPhase(observesAnnotation.during());
        async(false);
    } else {
        reception(eventParameter.getAnnotation(ObservesAsync.class).notifyObserver());
        async(true);
    }
    Priority priority = method.getAnnotation(Priority.class);
    if (priority != null) {
        priority(priority.value());
    }
    beanClass(eventParameter.getDeclaringCallable().getDeclaringType().getJavaClass());
    observedType(eventParameter.getBaseType());
    qualifiers(Configurators.getQualifiers(eventParameter));
    return this;
}
Also used : EventLogger(org.jboss.weld.logging.EventLogger) Observes(jakarta.enterprise.event.Observes) ObserverMethodConfigurator(jakarta.enterprise.inject.spi.configurator.ObserverMethodConfigurator) Preconditions.checkArgumentNotNull(org.jboss.weld.util.Preconditions.checkArgumentNotNull) Reception(jakarta.enterprise.event.Reception) ObservesAsync(jakarta.enterprise.event.ObservesAsync) HashSet(java.util.HashSet) AnnotatedMethod(jakarta.enterprise.inject.spi.AnnotatedMethod) Extension(jakarta.enterprise.inject.spi.Extension) AnnotatedParameter(jakarta.enterprise.inject.spi.AnnotatedParameter) Parameter(java.lang.reflect.Parameter) ObserverException(jakarta.enterprise.event.ObserverException) Formats(org.jboss.weld.util.reflection.Formats) Priority(jakarta.annotation.Priority) Method(java.lang.reflect.Method) TransactionPhase(jakarta.enterprise.event.TransactionPhase) SyntheticObserverMethod(org.jboss.weld.event.SyntheticObserverMethod) CovariantTypes(org.jboss.weld.resolution.CovariantTypes) ImmutableSet(org.jboss.weld.util.collections.ImmutableSet) Set(java.util.Set) ObserverMethod(jakarta.enterprise.inject.spi.ObserverMethod) Collectors(java.util.stream.Collectors) EventContext(jakarta.enterprise.inject.spi.EventContext) Type(java.lang.reflect.Type) Annotation(java.lang.annotation.Annotation) Collections(java.util.Collections) ObservesAsync(jakarta.enterprise.event.ObservesAsync) AnnotatedParameter(jakarta.enterprise.inject.spi.AnnotatedParameter) Observes(jakarta.enterprise.event.Observes) Priority(jakarta.annotation.Priority)

Aggregations

Priority (jakarta.annotation.Priority)1 ObserverException (jakarta.enterprise.event.ObserverException)1 Observes (jakarta.enterprise.event.Observes)1 ObservesAsync (jakarta.enterprise.event.ObservesAsync)1 Reception (jakarta.enterprise.event.Reception)1 TransactionPhase (jakarta.enterprise.event.TransactionPhase)1 AnnotatedMethod (jakarta.enterprise.inject.spi.AnnotatedMethod)1 AnnotatedParameter (jakarta.enterprise.inject.spi.AnnotatedParameter)1 EventContext (jakarta.enterprise.inject.spi.EventContext)1 Extension (jakarta.enterprise.inject.spi.Extension)1 ObserverMethod (jakarta.enterprise.inject.spi.ObserverMethod)1 ObserverMethodConfigurator (jakarta.enterprise.inject.spi.configurator.ObserverMethodConfigurator)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 Parameter (java.lang.reflect.Parameter)1 Type (java.lang.reflect.Type)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1