Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SyntheticBeanDisposer.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.inject.Instance;
14
15 /**
16 * Destruction function for a synthetic bean defined by {@link SyntheticBeanBuilder}.
17 * CDI container will create an instance of the destruction function every time when it needs
18 * to destroy an instance of the synthetic bean. Implementations must be {@code public}
19 * classes with a {@code public} zero-parameter constructor; they must not be beans.
20 *
21 * @param <T> the bean class of the synthetic bean
22 * @since 4.0
23 */
24 public interface SyntheticBeanDisposer<T> {
25 /**
26 * Destroys an instance of the synthetic bean.
27 * <p>
28 * The {@link Instance} parameter may be used to simulate disposer method parameter injection.
29 * All {@code @Dependent} bean instances obtained from the {@code Instance} during execution
30 * are destroyed when execution completes.
31 * <p>
32 * Trying to look up {@code InjectionPoint} from the {@code Instance} parameter is invalid.
33 * <p>
34 * The parameter map contains the same values that were passed to the {@link SyntheticBeanBuilder}
35 * that defined the synthetic bean.
36 *
37 * @param instance the synthetic bean instance, never {@code null}
38 * @param lookup an {@link Instance} that can be used to lookup other beans, never {@code null}
39 * @param params the parameter map, never {@code null}
40 */
41 void dispose(T instance, Instance<Object> lookup, Parameters params);
42 }