01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php
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: package org.kuali.rice.config;
17:
18: import org.kuali.rice.core.Core;
19:
20: /**
21: * A convienent superclass or utility for DAOs which read and write data from the various components in
22: * the configuration framework. Also allows for access to the NodeSettings service which
23: * allows for persistence of configuration parameters.
24: *
25: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
26: */
27: public class ConfigDAOSupport {
28:
29: // private NodeSettings nodeSettings;
30:
31: /**
32: * Returns a String property from the current context config.
33: */
34: public String getStringProperty(String name) {
35: String property = getConfig().getProperty(name);
36: // if (property == null) {
37: // property = getNodeSettings().getSetting(name);
38: // }
39: return property;
40: }
41:
42: public Integer getIntProperty(String name) {
43: String property = getStringProperty(name);
44: if (property == null) {
45: return null;
46: }
47: return Integer.valueOf(property);
48: }
49:
50: public Long getLongProperty(String name) {
51: String property = getStringProperty(name);
52: if (property == null) {
53: return null;
54: }
55: return Long.valueOf(property);
56: }
57:
58: public Boolean getBooleanProperty(String name) {
59: String property = getStringProperty(name);
60: if (property == null) {
61: return null;
62: }
63: return Boolean.valueOf(property);
64: }
65:
66: public Boolean getBooleanProperty(String name, Boolean defaultValue) {
67: Boolean property = getBooleanProperty(name);
68: if (property == null) {
69: return defaultValue;
70: }
71: return property;
72: }
73:
74: public Object getObjectProperty(String name) {
75: return getConfig().getObject(name);
76: }
77:
78: // public NodeSettings getNodeSettings() {
79: // return this.nodeSettings;
80: // }
81: //
82: // public void setNodeSettings(NodeSettings nodeSettings) {
83: // this.nodeSettings = nodeSettings;
84: // }
85:
86: public Config getConfig() {
87: return Core.getCurrentContextConfig();
88: }
89:
90: }
|