Source Code Cross Referenced for BexeeProperties.java in  » Workflow-Engines » bexee » bexee » util » 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 » Workflow Engines » bexee » bexee.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: BexeeProperties.java,v 1.6 2004/12/09 12:34:45 kowap Exp $
003:         *
004:         * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
005:         * Berne University of Applied Sciences
006:         * School of Engineering and Information Technology
007:         * All rights reserved.
008:         */
009:        package bexee.util;
010:
011:        import java.io.IOException;
012:        import java.io.InputStream;
013:        import java.util.Properties;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:
018:        /**
019:         * Provides a convenient way for accessing system properties and bexee
020:         * properties of which the latter are stored in a file called
021:         * <code>bexee.properties</code> and must be somewhere in the classpath.
022:         * <p>
023:         * Note that system properties take precedence over all other properties unless
024:         * a property is explicitly programmaticly set.
025:         * <p>
026:         * The system properties are always checked for changes whereas the properties
027:         * from the <code>bexee.properties</code> are only read once upon creation.
028:         * <p>
029:         * The class provides a number of static methods that always check first if the
030:         * properties had been loaded from the properties file.
031:         * 
032:         * @version $Revision: 1.6 $, $Date: 2004/12/09 12:34:45 $
033:         * @author Patric Fornasier
034:         */
035:        public class BexeeProperties {
036:
037:            protected static final String FILE_NAME = "bexee.properties";
038:
039:            private static Log log = LogFactory.getLog(BexeeProperties.class);
040:
041:            // union of bexee and system properties
042:            protected static Properties props;
043:
044:            // properties from bexee.properties file
045:            protected static Properties bexee;
046:
047:            /**
048:             * Searches for the property with the specified key in this property list.
049:             * The method returns null if the property is not found.
050:             * 
051:             * @param key
052:             *            the property key.
053:             * @return the value in this property list with the specified key value.
054:             */
055:            public static String getProperty(String key) {
056:                init();
057:                return props.getProperty(key);
058:            }
059:
060:            /**
061:             * Searches for the property with the specified key in this property list.
062:             * The method returns the default value argument if the property is not
063:             * found.
064:             * 
065:             * @param key
066:             *            the hashtable key
067:             * @param defaultValue
068:             *            a default value
069:             * @return the value in this property list with the specified key value
070:             */
071:            public static String getProperty(String key, String defaultValue) {
072:                init();
073:                return props.getProperty(key, defaultValue);
074:            }
075:
076:            /**
077:             * Returns the initialized underlying property file.
078:             * 
079:             * @return a <code>Property</code> object.
080:             */
081:            public static Properties getProperties() {
082:                init();
083:                return props;
084:            }
085:
086:            /**
087:             * Calls the Hashtable method put. Provided for parallelism with the
088:             * getProperty method. Enforces use of strings for property keys and values.
089:             * The value returned is the result of the Hashtable call to put.
090:             * 
091:             * @param key
092:             *            the key to be placed into this property list
093:             * @param value
094:             *            the value corresponding to key
095:             * @return the previous value of the specified key in this property list, or
096:             *         null if it did not have one
097:             */
098:            public static Object setProperty(String key, String value) {
099:                init();
100:                return props.setProperty(key, value);
101:            }
102:
103:            /**
104:             * Makes sure the properties are initialized. This method is the first thing
105:             * called in every method inside this class.
106:             * <p>
107:             * If created for the first time this method tries to load the properties
108:             * from a property file and then adds system properties, which means that
109:             * application specified properties may be overriden.
110:             */
111:            private static void init() {
112:                if (props == null) {
113:
114:                    props = new Properties();
115:                    bexee = new Properties();
116:
117:                    // find properties file
118:                    ClassLoader loader = BexeeProperties.class.getClassLoader();
119:                    InputStream is = loader.getResourceAsStream(FILE_NAME);
120:
121:                    // try to load it
122:                    if (is == null) {
123:                        log.info("unable to locate file: " + FILE_NAME);
124:                    } else {
125:                        try {
126:                            // load properties from file once and store them in bexee
127:                            bexee.load(is);
128:                            // copy properties (they can be overriden by system props)
129:                            props.putAll(bexee);
130:                        } catch (IOException e) {
131:                            log.info("unable to load file: " + FILE_NAME, e);
132:                        }
133:                    }
134:                }
135:
136:                // always override with latest system properties
137:                props.putAll(System.getProperties());
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.