01: /*
02: * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.romaframework.core.config;
18:
19: import java.util.Collection;
20: import java.util.LinkedHashMap;
21: import java.util.Map;
22:
23: import org.romaframework.core.GlobalConstants;
24:
25: public class Configurable<T> {
26:
27: public Collection<T> getConfigurationValues() {
28: return configuration.values();
29: }
30:
31: public T getConfiguration(String iObjectName) {
32: return configuration.get(iObjectName);
33: }
34:
35: /**
36: * Add an object registering it with key equals to toString() result.
37: *
38: * @param iObjectName
39: * @param iObject
40: */
41: public void addConfiguration(T iObject) {
42: configuration.put(iObject.toString(), iObject);
43: }
44:
45: /**
46: * Add an onbject
47: *
48: * @param iObjectName
49: * @param iObject
50: */
51: public void addConfiguration(String iObjectName, T iObject) {
52: configuration.put(iObjectName, iObject);
53: }
54:
55: /**
56: * Set multiple objects in one shot. This method it's callable by spring to
57: * set multiple references.
58: *
59: * @param iConfig
60: */
61: public void setConfiguration(Map<String, T> iConfig) {
62: configuration.putAll(iConfig);
63: }
64:
65: protected Map<String, T> configuration = new LinkedHashMap<String, T>();
66:
67: public static final String DEFAULT_CONFIG = GlobalConstants.ROOT_CLASS;
68: }
|