use of javax.enterprise.event.TransactionPhase 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());
} else {
reception(eventParameter.getAnnotation(ObservesAsync.class).notifyObserver());
}
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;
}
use of javax.enterprise.event.TransactionPhase in project core by weld.
the class TransactionalObserverNotifier method deferNotification.
/**
* Defers an event for processing in a later phase of the current
* transaction.
*
* @param metadata The event object
*/
private <T> void deferNotification(T event, final EventMetadata metadata, final ObserverMethod<? super T> observer, final List<DeferredEventNotification<?>> notifications) {
TransactionPhase transactionPhase = observer.getTransactionPhase();
boolean before = transactionPhase.equals(TransactionPhase.BEFORE_COMPLETION);
Status status = Status.valueOf(transactionPhase);
notifications.add(new DeferredEventNotification<T>(contextId, event, metadata, observer, currentEventMetadata, status, before));
}
Aggregations