1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.jboss.extension.resources;
17
18 import org.jboss.as.controller.PathElement;
19 import org.jboss.as.controller.ReloadRequiredRemoveStepHandler;
20 import org.jboss.as.controller.SimpleAttributeDefinition;
21 import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
22 import org.jboss.as.controller.SimpleResourceDefinition;
23 import org.jboss.as.controller.registry.AttributeAccess;
24 import org.jboss.as.controller.registry.ManagementResourceRegistration;
25 import org.jboss.dmr.ModelNode;
26 import org.jboss.dmr.ModelType;
27
28 import de.smartics.properties.jboss.extension.resources.components.CacheComponent;
29 import de.smartics.properties.jboss.extension.resources.components.DataSourceComponent;
30 import de.smartics.properties.jboss.extension.resources.components.AdminResourceComponent;
31 import de.smartics.properties.jboss.extension.resources.components.FactoriesComponent;
32 import de.smartics.properties.jboss.extension.resources.components.SecurityComponent;
33 import de.smartics.properties.spi.config.config.PropertiesConfiguration;
34
35
36
37
38 public class PropertiesConfigurationResourceDefinition extends
39 SimpleResourceDefinition
40 {
41
42
43
44
45
46
47
48 public static final String CONFIGS_ELEMENT_NAME = "configurations";
49
50
51
52
53
54
55
56 public static final String AN_NAME = "name";
57
58
59
60
61 public static final String CONFIG_ELEMENT_NAME = "configuration";
62
63
64
65
66 public static final PathElement CONFIG_PATH = PathElement
67 .pathElement(CONFIGS_ELEMENT_NAME);
68
69
70
71
72 public static final PathElement NAME_PATH = PathElement.pathElement(AN_NAME);
73
74
75
76
77 public static final SimpleAttributeDefinition NAME =
78 new SimpleAttributeDefinitionBuilder(AN_NAME, ModelType.STRING, true)
79 .setXmlName(AN_NAME).setAllowExpression(true)
80 .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).build();
81
82
83
84
85 public static final PropertiesConfigurationResourceDefinition INSTANCE =
86 new PropertiesConfigurationResourceDefinition();
87
88
89
90
91
92
93
94 private final AdminResourceComponent adminResourceComponent =
95 new AdminResourceComponent(
96 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
97
98
99
100
101 private final CacheComponent cacheComponent = new CacheComponent(
102 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
103
104
105
106
107
108 private final DataSourceComponent dataSourceComponent =
109 new DataSourceComponent(
110 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
111
112
113
114
115
116 private final SecurityComponent securityComponent = new SecurityComponent(
117 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
118
119
120
121
122
123 private final FactoriesComponent factoriesComponent = new FactoriesComponent(
124 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
125
126
127
128
129
130
131
132
133 public PropertiesConfigurationResourceDefinition()
134 {
135 super(CONFIG_PATH, DescriptionUtils
136 .getResourceDescriptionResolver("configuration"),
137 PropertiesConfigurationResourceAdd.INSTANCE,
138 ReloadRequiredRemoveStepHandler.INSTANCE);
139 }
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 public AdminResourceComponent getDefinitionsComponent()
157 {
158 return adminResourceComponent;
159 }
160
161
162
163
164
165
166
167
168 public CacheComponent getCacheComponent()
169 {
170 return cacheComponent;
171 }
172
173
174
175
176
177
178
179
180 public DataSourceComponent getDataSourceComponent()
181 {
182 return dataSourceComponent;
183 }
184
185
186
187
188
189
190
191
192 public SecurityComponent getSecurityComponent()
193 {
194 return securityComponent;
195 }
196
197
198
199
200
201
202
203
204 public FactoriesComponent getFactoriesComponent()
205 {
206 return factoriesComponent;
207 }
208
209
210
211 @Override
212 public void registerAttributes(
213 final ManagementResourceRegistration resourceRegistration)
214 {
215 resourceRegistration.registerReadWriteAttribute(NAME, null,
216 PropertiesConfigurationResourceAttributeHandler.INSTANCE);
217
218 adminResourceComponent.registerAttributes(resourceRegistration);
219 cacheComponent.registerAttributes(resourceRegistration);
220 dataSourceComponent.registerAttributes(resourceRegistration);
221 securityComponent.registerAttributes(resourceRegistration);
222 factoriesComponent.registerAttributes(resourceRegistration);
223 }
224
225 public void apply(final String identifier,
226 final PropertiesConfiguration propertiesConfig, final ModelNode model)
227 {
228 adminResourceComponent.apply(propertiesConfig, model);
229 cacheComponent.apply(identifier, propertiesConfig, model);
230 dataSourceComponent.apply(propertiesConfig, model);
231 securityComponent.apply(propertiesConfig, model);
232 factoriesComponent.apply(propertiesConfig, model);
233 }
234
235
236
237 }