Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticObserver.java

raw
1 /*
2 * Copyright (c) 2021 Red Hat and others
3 *
4 * This program and the accompanying materials are made available under the
5 * Apache Software License 2.0 which is available at:
6 * https://www.apache.org/licenses/LICENSE-2.0.
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11 package jakarta.enterprise.inject.build.compatible.spi;
12
13 import jakarta.enterprise.event.ObserverException;
14 import jakarta.enterprise.inject.spi.EventContext;
15
16 /**
17 * The event notification function for a synthetic observer defined by {@link SyntheticObserverBuilder}.
18 * CDI container will create an instance of the event notification function every time when it needs
19 * to notify the synthetic observer. Implementations must be {@code public} classes with a {@code public}
20 * zero-parameter constructor; they must not be beans.
21 *
22 * @param <T> the observed event type of the synthetic observer
23 * @since 4.0
24 */
25 public interface SyntheticObserver<T> {
26 /**
27 * Consumes an event. The {@link EventContext} provides access to the event payload,
28 * as well as the {@link jakarta.enterprise.inject.spi.EventMetadata EventMetadata}.
29 * <p>
30 * The parameter map contains the same values that were passed to
31 * the {@link SyntheticObserverBuilder} that defined the synthetic observer.
32 *
33 * @param event the event context, never {@code null}
34 * @param params the parameter map, never {@code null}
35 * @throws Exception checked exception will be wrapped and rethrown as an {@link ObserverException}
36 */
37 void observe(EventContext<T> event, Parameters params) throws Exception;
38 }