Source Code Cross Referenced for BaseConfig.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » rice » config » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.rice.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2006 The Kuali Foundation.
003:         *
004:         *
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         * http://www.opensource.org/licenses/ecl1.php
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.kuali.rice.config;
018:
019:        import java.io.IOException;
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.LinkedHashMap;
023:        import java.util.List;
024:        import java.util.Map;
025:        import java.util.Properties;
026:
027:        import org.apache.log4j.Logger;
028:        import org.kuali.rice.core.Core;
029:        import org.kuali.rice.util.RiceUtilities;
030:
031:        /**
032:         * Abstract base hierarchical config implementation. Loads a hierarchy configs,
033:         * resolving placeholders at parse-time of each config, using the current and
034:         * ancestor configs for resolution.
035:         * 
036:         * @see HierarchicalConfigParser
037:         * 
038:         * @author Kuali Rice Team (kuali-rice@googlegroups.com)
039:         */
040:        public abstract class BaseConfig implements  Config {
041:
042:            private static final Logger LOG = Logger
043:                    .getLogger(BaseConfig.class);
044:
045:            private Map<String, Object> configs = new LinkedHashMap<String, Object>();
046:
047:            private List<String> fileLocs = new ArrayList<String>();
048:
049:            private Properties propertiesUsed = new Properties();
050:
051:            private Map<String, Object> objects = new LinkedHashMap<String, Object>();
052:
053:            public BaseConfig(String fileLoc) {
054:                this .fileLocs.add(fileLoc);
055:            }
056:
057:            public BaseConfig(List<String> fileLocs) {
058:                this .fileLocs = fileLocs;
059:            }
060:
061:            public void parseConfig() throws IOException {
062:                LOG.info("Loading workflow configs");
063:                Map<String, Object> baseObjects = getBaseObjects();
064:                if (baseObjects != null) {
065:                    this .objects.putAll(baseObjects);
066:                }
067:                configureBuiltIns(this .propertiesUsed);
068:                Properties baseProperties = getBaseProperties();
069:                if (baseProperties != null) {
070:                    this .propertiesUsed.putAll(baseProperties);
071:                }
072:                for (String fileLoc : this .fileLocs) {
073:                    HierarchicalConfigParser configParser = new HierarchicalConfigParser(
074:                            this .propertiesUsed);
075:                    LOG.info("Passing config " + fileLoc + " to config parser");
076:                    this .configs.putAll(configParser.parse(fileLoc));
077:                    // get all the properties from all the potentially nested configs in
078:                    // the master set
079:                    // of propertiesUsed. Do it now so that all the values are available
080:                    // for token replacement
081:                    // next iteration
082:                    for (Map.Entry<String, Object> config : this .configs
083:                            .entrySet()) {
084:                        if (config.getValue() instanceof  Properties) {
085:                            putPropertiesInPropsUsed((Properties) config
086:                                    .getValue(), config.getKey());
087:                        } else {
088:                            String configValue = (String) config.getValue();
089:                            LOG.info("-->Putting root config Prop "
090:                                    + config.getKey() + "=[" + configValue
091:                                    + "]");
092:                            this .propertiesUsed.put(config.getKey(),
093:                                    configValue);
094:                        }
095:                    }
096:                    LOG.info("File " + fileLoc + " parsed");
097:                }
098:
099:                if (!fileLocs.isEmpty()) {
100:                    LOG.info("");
101:                    LOG.info("####################################");
102:                    LOG.info("#");
103:                    LOG
104:                            .info("# Properties used after config override/replacement");
105:                    LOG.info("#");
106:                    LOG.info("####################################");
107:                    LOG.info("");
108:                    Map<String, String> safePropsUsed = ConfigLogger
109:                            .getDisplaySafeConfig(this .propertiesUsed);
110:                    for (Map.Entry<String, String> propUsed : safePropsUsed
111:                            .entrySet()) {
112:                        LOG.info("Using config Prop " + propUsed.getKey()
113:                                + "=[" + propUsed.getValue() + "]");
114:                    }
115:                }
116:            }
117:
118:            protected void putPropertiesInPropsUsed(Properties properties,
119:                    String fileName) {
120:                // Properties configProperties = (Properties)config.getValue();
121:                Map<String, String> safeConfig = ConfigLogger
122:                        .getDisplaySafeConfig(properties);
123:                LOG.info("-->Loading properties for config " + fileName);
124:                for (Iterator iterator2 = properties.entrySet().iterator(); iterator2
125:                        .hasNext();) {
126:                    Map.Entry configProp = (Map.Entry) iterator2.next();
127:                    String key = (String) configProp.getKey();
128:                    String value = (String) configProp.getValue();
129:                    String safeValue = safeConfig.get(key);
130:                    LOG.info("---->Putting config Prop " + key + "=["
131:                            + safeValue + "]");
132:                    this .propertiesUsed.put(key, value);
133:                }
134:            }
135:
136:            public void overrideProperty(String name, String value) {
137:                this .propertiesUsed.put(name, value);
138:            }
139:
140:            /**
141:             * Configures built-in properties.
142:             */
143:            protected void configureBuiltIns(Properties properties) {
144:                properties.put("host.ip", RiceUtilities.getIpNumber());
145:                properties.put("host.name", RiceUtilities.getHostName());
146:            }
147:
148:            public abstract Properties getBaseProperties();
149:
150:            public abstract Map<String, Object> getBaseObjects();
151:
152:            public Properties getProperties() {
153:                return this .propertiesUsed;
154:            }
155:
156:            public String getProperty(String key) {
157:                return getProperties().getProperty(key);
158:            }
159:
160:            public Map<String, Object> getObjects() {
161:                return this .objects;
162:            }
163:
164:            public Object getObject(String key) {
165:                return getObjects().get(key);
166:            }
167:
168:            public String getClientProtocol() {
169:                return getProperty(CLIENT_PROTOCOL);
170:            }
171:
172:            public String getBaseWebServiceURL() {
173:                return getProperty(BASE_WEB_SERVICE_URL_WORKFLOW_CLIENT_FILE);
174:            }
175:
176:            public String getBaseWebServiceWsdlPath() {
177:                return getProperty(BASE_WEB_SERVICE_WSDL_PATH);
178:            }
179:
180:            public String getClientWSDLFullPathAndFileName() {
181:                return getProperty(WSDL_LOCATION_WORKFLOW_CLIENT_FILE);
182:            }
183:
184:            public String getWebServicesConnectRetry() {
185:                return getProperty(WEB_SERVICE_CONNECT_RETRY);
186:            }
187:
188:            public String getLog4jFileLocation() {
189:                return getProperty(LOG4J_SETTINGS_PATH);
190:            }
191:
192:            public String getLog4jReloadInterval() {
193:                return getProperty(LOG4J_SETTINGS_RELOADINTERVAL_MINS);
194:            }
195:
196:            public String getTransactionTimeout() {
197:                return getProperty(TRANSACTION_TIMEOUT);
198:            }
199:
200:            public String getEmailConfigurationPath() {
201:                return getProperty(EMAIL_SECURITY_PATH);
202:            }
203:
204:            public String getBaseUrl() {
205:                return getProperty(BASE_URL);
206:            }
207:
208:            public String getEnvironment() {
209:                return getProperty(ENVIRONMENT);
210:            }
211:
212:            public String getEDLConfigLocation() {
213:                return getProperty(EDL_CONFIG_LOCATION);
214:            }
215:
216:            public String getMessageEntity() {
217:                return getProperty(MESSAGE_ENTITY);
218:            }
219:
220:            public String getDefaultNoteClass() {
221:                return getProperty(DEFAULT_NOTE_CLASS);
222:            }
223:
224:            public String getEmbeddedPluginLocation() {
225:                return getProperty(EMBEDDED_PLUGIN_LOCATIAON);
226:            }
227:
228:            public Integer getRefreshRate() {
229:                Integer refreshRate;
230:                try {
231:                    refreshRate = new Integer(Core.getCurrentContextConfig()
232:                            .getProperty(Config.REFRESH_RATE));
233:                } catch (NumberFormatException nfe) {
234:                    LOG
235:                            .error("Couldn't parse property "
236:                                    + Config.REFRESH_RATE
237:                                    + " to set bus refresh rate. Defaulting to 30 seconds.");
238:                    Core.getCurrentContextConfig().overrideProperty(
239:                            Config.REFRESH_RATE, "30");
240:                    return 30;
241:                }
242:                return refreshRate;
243:            }
244:
245:            public String getEndPointUrl() {
246:                return Core.getCurrentContextConfig().getProperty(
247:                        Config.SERVICE_SERVLET_URL);
248:            }
249:
250:            public String getAlternateOJBFile() {
251:                return getProperty(Config.ALT_OJB_FILE);
252:            }
253:
254:            public String getAlternateSpringFile() {
255:                return getProperty(Config.ALT_SPRING_FILE);
256:            }
257:
258:            public String getKeystoreAlias() {
259:                return getProperty(Config.KEYSTORE_ALIAS);
260:            }
261:
262:            public String getKeystorePassword() {
263:                return getProperty(Config.KEYSTORE_PASSWORD);
264:            }
265:
266:            public String getKeystoreFile() {
267:                return getProperty(Config.KEYSTORE_FILE);
268:            }
269:
270:            public String getDailyEmailFirstDeliveryDate() {
271:                return getProperty(Config.FIRST_DAILY_EMAIL_DELIVERY_DATE);
272:            }
273:
274:            public String getWeeklyEmailFirstDeliveryDate() {
275:                return getProperty(Config.FIRST_WEEKLY_EMAIL_DELIVERY_DATE);
276:            }
277:
278:            public String getDocumentLockTimeout() {
279:                return getProperty(Config.DOCUMENT_LOCK_TIMEOUT);
280:            }
281:
282:            public Boolean getRunningEmbeddedServerMode() {
283:                return new Boolean(getProperty(RUNNING_SERVER_IN_EMBEDDED));
284:            }
285:
286:            public Boolean getDevMode() {
287:                return new Boolean(getProperty(DEV_MODE));
288:            }
289:
290:            public Boolean getStoreAndForward() {
291:                return new Boolean(getProperty(Config.STORE_AND_FORWARD));
292:            }
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.