/
MergedStereotypes.java
92 lines (79 loc) · 2.71 KB
/
MergedStereotypes.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
package org.jboss.webbeans.bean;
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.model.StereotypeModel;
/**
* Meta model for the merged stereotype for a bean
* @author pmuir
*
*/
public class MergedStereotypes<T, E>
{
private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
private Set<Annotation> possibleScopeTypes;
private boolean beanNameDefaulted;
private Set<Class<?>> requiredTypes;
private Set<Class<? extends Annotation>> supportedScopes;
public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
{
possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
possibleScopeTypes = new HashSet<Annotation>();
requiredTypes = new HashSet<Class<?>>();
supportedScopes = new HashSet<Class<? extends Annotation>>();
merge(stereotypeAnnotations, manager);
}
protected void merge(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
{
for (Annotation stereotypeAnnotation : stereotypeAnnotations)
{
// Retrieve and merge all metadata from stereotypes
StereotypeModel<?> stereotype = manager.getMetaDataCache().getStereotype(stereotypeAnnotation.annotationType());
if (stereotype == null)
{
throw new IllegalStateException("Stereotype " + stereotypeAnnotation + " not registered with container");
}
if (stereotype.getDefaultDeploymentType() != null)
{
possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
}
if (stereotype.getDefaultScopeType() != null)
{
possibleScopeTypes.add(stereotype.getDefaultScopeType());
}
requiredTypes.addAll(stereotype.getRequiredTypes());
supportedScopes.addAll(stereotype.getSupportedScopes());
if (stereotype.isBeanNameDefaulted())
{
beanNameDefaulted = true;
}
}
}
public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
{
return possibleDeploymentTypes;
}
public Set<Annotation> getPossibleScopeTypes()
{
return possibleScopeTypes;
}
public boolean isBeanNameDefaulted()
{
return beanNameDefaulted;
}
public Set<Class<?>> getRequiredTypes()
{
return requiredTypes;
}
public Set<Class<? extends Annotation>> getSupportedScopes()
{
return supportedScopes;
}
public boolean isDeclaredInXml()
{
return false;
}
}