1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.properties.spi.config.domain;
17
18 import java.io.IOException;
19 import java.io.ObjectInputStream;
20 import java.util.List;
21
22 import de.smartics.properties.api.config.app.ConfigurationPropertiesFactory;
23 import de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement;
24 import de.smartics.properties.api.config.domain.Property;
25 import de.smartics.properties.api.config.domain.PropertyProvider;
26 import de.smartics.properties.api.config.domain.PropertyStoreAccessor;
27 import de.smartics.properties.api.config.domain.SerializableConfigurationPropertiesManagement;
28 import de.smartics.properties.api.config.domain.UnknownPropertyException;
29 import de.smartics.properties.api.config.domain.key.ConfigurationKey;
30 import de.smartics.properties.api.core.domain.DuplicatePropertyDeclarationsException;
31 import de.smartics.properties.api.core.domain.PropertyDescriptor;
32 import de.smartics.properties.api.core.domain.PropertyDescriptorRegistry;
33 import de.smartics.properties.api.core.domain.PropertyKey;
34 import de.smartics.properties.api.core.domain.PropertyValidationException;
35 import de.smartics.properties.api.core.domain.ReadOnlyPropertyException;
36 import de.smartics.properties.api.core.security.PropertyValueSecurity;
37
38
39
40
41
42
43 public final class ConfigurationPropertiesManagementProxy extends
44 ConfigurationPropertiesProxy implements
45 SerializableConfigurationPropertiesManagement
46 {
47
48
49
50
51
52
53
54 private static final long serialVersionUID = 1L;
55
56
57
58
59
60
61 private transient ConfigurationPropertiesManagement configuration;
62
63
64
65
66
67
68
69
70
71
72
73
74
75 public ConfigurationPropertiesManagementProxy(final ConfigurationKey<?> key,
76 final ConfigurationPropertiesFactory factory)
77 {
78 super(key, factory);
79 this.configuration = getConfiguration();
80 }
81
82
83
84
85
86
87
88 private ConfigurationPropertiesManagement getConfiguration()
89 {
90 final ConfigurationKey<?> key = getKey();
91 final ConfigurationPropertiesFactory factory = getFactory();
92 final ConfigurationPropertiesManagement configuration =
93 factory.createManagement(key);
94 return configuration;
95 }
96
97
98
99 @Override
100 public PropertyDescriptorRegistry getRegistry()
101 {
102 return configuration.getRegistry();
103 }
104
105 @Override
106 public PropertyValueSecurity getPropertyValueSecurity()
107 {
108 return configuration.getPropertyValueSecurity();
109 }
110
111 @Override
112 public PropertyStoreAccessor getPropertyStoreAccessor()
113 {
114 return configuration.getPropertyStoreAccessor();
115 }
116
117 @Override
118 public boolean isInAdminMode()
119 {
120 return configuration.isInAdminMode();
121 }
122
123 @Override
124 public void setToAdminMode(final boolean newMode)
125 {
126 configuration.setToAdminMode(newMode);
127 }
128
129
130
131 @Override
132 public void addDescriptors(final Class<?> propertySetType)
133 throws DuplicatePropertyDeclarationsException
134 {
135 configuration.addDescriptors(propertySetType);
136 }
137
138 @Override
139 public PropertyDescriptor getDescriptor(final String key)
140 throws UnknownPropertyException
141 {
142 return configuration.getDescriptor(key);
143 }
144
145 @Override
146 public PropertyDescriptor getDescriptor(final PropertyKey key)
147 throws UnknownPropertyException
148 {
149 return configuration.getDescriptor(key);
150 }
151
152 @Override
153 public List<PropertyDescriptor> getMandatoryPropertyDescriptors()
154 {
155 return configuration.getMandatoryPropertyDescriptors();
156 }
157
158 @Override
159 public ConfigurationPropertiesManagement addDefinitions(
160 final PropertyProvider properties) throws NullPointerException
161 {
162 return configuration.addDefinitions(properties);
163 }
164
165 @Override
166 public Property setProperty(final PropertyKey key, final String value)
167 throws NullPointerException, PropertyValidationException,
168 ReadOnlyPropertyException
169 {
170 return configuration.setProperty(key, value);
171 }
172
173 @Override
174 public Property unsetProperty(final PropertyKey key)
175 throws NullPointerException, ReadOnlyPropertyException
176 {
177 return configuration.unsetProperty(key);
178 }
179
180 @Override
181 public void flush()
182 {
183 configuration.flush();
184 }
185
186 @Override
187 public ConfigurationPropertiesManagement toRepresentative()
188 {
189 return this;
190 }
191
192 @Override
193 public SerializableConfigurationPropertiesManagement toSerializable()
194 {
195 return this;
196 }
197
198
199
200
201
202
203
204
205
206
207 private void readObject(final ObjectInputStream in) throws IOException,
208 ClassNotFoundException
209 {
210 in.defaultReadObject();
211
212 configuration = getConfiguration();
213 }
214 }