1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.integration.cdi.extension;
17
18 import java.io.Serializable;
19 import java.lang.annotation.Annotation;
20 import java.lang.reflect.Type;
21 import java.util.Collections;
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import javax.enterprise.context.RequestScoped;
26 import javax.enterprise.context.spi.CreationalContext;
27 import javax.enterprise.inject.spi.Bean;
28 import javax.enterprise.inject.spi.BeanManager;
29 import javax.enterprise.inject.spi.InjectionPoint;
30
31 import de.smartics.properties.api.config.app.ConfigurationPropertiesFactory;
32
33
34
35
36 public class ConfigurationPropertiesFactoryCdiBean implements Bean<Object>,
37 Serializable
38 {
39
40
41
42
43
44
45
46
47 private static final long serialVersionUID = 1L;
48
49
50
51
52 private final Class<?> type;
53
54
55
56
57 private final BeanManager beanManager;
58
59
60
61
62 private final ConfigurationPropertiesFactory factory;
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78 public ConfigurationPropertiesFactoryCdiBean(final Class<?> type,
79 final BeanManager beanManager,
80 final ConfigurationPropertiesFactory factory)
81 {
82 this.type = type;
83 this.beanManager = beanManager;
84 this.factory = factory;
85 }
86
87
88
89
90
91
92
93
94
95
96
97 @Override
98 public Class<?> getBeanClass()
99 {
100 return type;
101 }
102
103 @Override
104 public Set<InjectionPoint> getInjectionPoints()
105 {
106 return Collections.emptySet();
107 }
108
109 @Override
110 public String getName()
111 {
112 final StringBuilder beanName = new StringBuilder();
113 beanName.append(type.getName());
114 return beanName.toString();
115 }
116
117 @Override
118 public Set<Annotation> getQualifiers()
119 {
120 final Set<Annotation> qualifiers = new HashSet<Annotation>();
121 return qualifiers;
122 }
123
124 @Override
125 public Class<? extends Annotation> getScope()
126 {
127 return RequestScoped.class;
128 }
129
130 @Override
131 public Set<Class<? extends Annotation>> getStereotypes()
132 {
133 return Collections.emptySet();
134 }
135
136 @Override
137 public Set<Type> getTypes()
138 {
139 final Set<Type> types = new HashSet<Type>();
140 types.add(type);
141 return types;
142 }
143
144 @Override
145 public boolean isAlternative()
146 {
147 return false;
148 }
149
150 @Override
151 public boolean isNullable()
152 {
153 return false;
154 }
155
156 @Override
157 public Object create(final CreationalContext<Object> ctx)
158 {
159 return factory;
160 }
161
162 @Override
163 public void destroy(final Object instance, final CreationalContext<Object> ctx)
164 {
165
166 }
167
168
169 }