-
Notifications
You must be signed in to change notification settings - Fork 77
/
BeanInfo.java
175 lines (155 loc) · 6.04 KB
/
BeanInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package jakarta.enterprise.inject.build.compatible.spi;
import jakarta.enterprise.lang.model.AnnotationInfo;
import jakarta.enterprise.lang.model.declarations.ClassInfo;
import jakarta.enterprise.lang.model.declarations.FieldInfo;
import jakarta.enterprise.lang.model.declarations.MethodInfo;
import jakarta.enterprise.lang.model.types.Type;
import java.util.Collection;
/**
* Beans are:
*
* <ul>
* <li>managed beans</li>
* <li>beans defined by producer methods</li>
* <li>beans defined by producer fields</li>
* <li>synthetic beans</li>
* </ul>
*
* Managed beans are also known as class-based beans, while beans defined by producer methods
* and producer fields are together also known as producer-based beans.
* <p>
* Class-based and producer-based beans directly correspond to a declaration in program source code.
* Synthetic beans don't and are instead defined through other mechanisms, such as
* {@linkplain BuildCompatibleExtension extensions}.
*
* @since 4.0
*/
public interface BeanInfo {
/**
* Returns the {@linkplain ScopeInfo scope} of this bean.
*
* @return the {@linkplain ScopeInfo scope} of this bean, never {@code null}
*/
ScopeInfo scope();
/**
* Returns a collection of all {@linkplain Type types} of this bean.
*
* @return immutable collection of bean types, never {@code null}
*/
Collection<Type> types();
/**
* Returns a collection of this bean's qualifiers, represented as {@link AnnotationInfo}.
*
* @return immutable collection of qualifiers, never {@code null}
*/
Collection<AnnotationInfo> qualifiers();
/**
* Returns the class that declares this bean.
* In case of a managed bean, also known as class-based bean, that is the bean class directly.
* In case of a producer method or field, that is the class that declares the producer method or field.
* Returns {@code null} if this bean is synthetic.
*
* @return {@link ClassInfo} for the class that declares this bean, or {@code null} if this bean is synthetic
*/
ClassInfo declaringClass();
/**
* Returns whether this bean is a managed bean, also known as class-based bean.
*
* @return whether this bean is a managed bean
*/
boolean isClassBean();
/**
* Returns whether this bean is defined by a producer method.
*
* @return whether this bean is defined by a producer method
*/
boolean isProducerMethod();
/**
* Returns whether this bean is defined by a producer field.
*
* @return whether this bean is defined by a producer field
*/
boolean isProducerField();
/**
* Returns whether this bean is synthetic. In other words, whether this bean
* does not correspond to a declaration in program source code and was created
* through other means (e.g. using an extension).
*
* @return whether this bean is synthetic
*/
boolean isSynthetic();
/**
* Returns the producer {@linkplain MethodInfo method} that defines this bean.
* Returns {@code null} if this bean is not defined by a producer method.
*
* @return producer method that defines this bean, or {@code null} if this bean is not defined by a producer method
*/
MethodInfo producerMethod();
/**
* Returns the producer {@linkplain FieldInfo field} that defines this bean.
* Returns {@code null} if this bean is not defined by a producer field.
*
* @return producer field that defines this bean, or {@code null} if this bean is not defined by a producer field
*/
FieldInfo producerField();
/**
* Returns whether this bean is an {@linkplain jakarta.enterprise.inject.Alternative alternative}.
*
* @return whether this bean is an {@linkplain jakarta.enterprise.inject.Alternative alternative}
*/
boolean isAlternative();
/**
* Returns the {@linkplain jakarta.annotation.Priority priority} declared on this bean, or {@code null}
* if this bean does not declare a priority. Declaring a priority on an alternative bean makes it an enabled
* alternative. Similarly, declaring a priority on an interceptor makes it an enabled interceptor.
*
* @return the priority of this bean, or {@code null} if this bean does not declare a priority
*/
Integer priority();
/**
* Returns the bean name of this bean. A bean name is usually defined
* using the {@link jakarta.inject.Named @Named} annotation.
* Returns {@code null} if the bean does not have a name.
*
* @return the bean name, or {@code null} if the bean does not have a name
*/
String getName();
/**
* Returns the {@linkplain DisposerInfo disposer} method of this producer-based bean.
* Returns {@code null} if this bean is not a defined by a producer method or a producer field,
* or if this producer-based bean does not have a corresponding disposer method.
*
* @return the {@linkplain DisposerInfo disposer}, or {@code null} if this bean does not have a disposer
*/
DisposerInfo disposer();
/**
* Returns a collection of this bean's {@linkplain StereotypeInfo stereotypes}.
*
* @return immutable collection of stereotypes, never {@code null}
*/
Collection<StereotypeInfo> stereotypes();
/**
* Returns a collection of this bean's {@linkplain InjectionPointInfo injection points}.
*
* @return immutable collection of injection points, never {@code null}
*/
Collection<InjectionPointInfo> injectionPoints();
// ---
/**
* Returns whether this bean is an interceptor.
*
* @return whether this bean is an interceptor
*/
default boolean isInterceptor() {
return false;
}
/**
* Returns this bean as an {@linkplain InterceptorInfo interceptor}.
*
* @return this interceptor, never {@code null}
* @throws IllegalStateException if {@link #isInterceptor()} returns {@code false}
*/
default InterceptorInfo asInterceptor() {
throw new IllegalStateException("Not an interceptor");
}
}