Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/InterceptorInfo.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.spi.InterceptionType;
14 import jakarta.enterprise.lang.model.AnnotationInfo;
15
16 import java.util.Collection;
17
18 /**
19 * Interceptors are managed beans annotated {@link jakarta.interceptor.Interceptor @Interceptor}.
20 * An interceptor declares a set of {@linkplain jakarta.interceptor.InterceptorBinding interceptor binding annotations},
21 * used to associate the interceptor with target beans. It also declares at most one interceptor method
22 * for each interception type. Interception types are:
23 * <ul>
24 * <li>{@link jakarta.interceptor.AroundInvoke @AroundInvoke}: intercept business method invocations,</li>
25 * <li>{@link jakarta.interceptor.AroundConstruct @AroundConstruct}: intercept constructor invocations,</li>
26 * <li>{@link jakarta.annotation.PostConstruct @PostConstruct}: called after the container creates the target instance
27 * and completes dependency injection,</li>
28 * <li>{@link jakarta.annotation.PreDestroy @PreDestroy}: called before the container destroys the target instance.</li>
29 * </ul>
30 * Finally, an interceptor also needs to declare a {@link jakarta.annotation.Priority @Priority} to become enabled.
31 * <p>
32 * Note that this description applies to CDI Lite. There are more ways to declare an interceptor,
33 * but those are only present in CDI Full.
34 *
35 * @since 4.0
36 */
37 public interface InterceptorInfo extends BeanInfo {
38 /**
39 * Returns the set of {@linkplain jakarta.interceptor.InterceptorBinding interceptor binding annotations}
40 * declared on this interceptor.
41 *
42 * @return immutable set of interceptor binding annotations, never {@code null}
43 */
44 Collection<AnnotationInfo> interceptorBindings();
45
46 /**
47 * Returns whether this interceptor declares an interceptor method for given
48 * {@linkplain InterceptionType interception type}.
49 *
50 * @param interceptionType the type of interception
51 * @return whether this interceptor declares an interceptor method for given interception type
52 */
53 boolean intercepts(InterceptionType interceptionType);
54
55 // ---
56
57 @Override
58 default boolean isInterceptor() {
59 return true;
60 }
61
62 @Override
63 default InterceptorInfo asInterceptor() {
64 return this;
65 }
66 }