Source Code Cross Referenced for MultiPropertiesConfig.java in  » Database-JDBC-Connection-Pool » c3p0 » com » mchange » v2 » cfg » 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 » Database JDBC Connection Pool » c3p0 » com.mchange.v2.cfg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Distributed as part of c3p0 v.0.9.1.2
003:         *
004:         * Copyright (C) 2005 Machinery For Change, Inc.
005:         *
006:         * Author: Steve Waldman <swaldman@mchange.com>
007:         *
008:         * This library is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU Lesser General Public License version 2.1, as 
010:         * published by the Free Software Foundation.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public License
018:         * along with this software; see the file LICENSE.  If not, write to the
019:         * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020:         * Boston, MA 02111-1307, USA.
021:         */
022:
023:        package com.mchange.v2.cfg;
024:
025:        import java.util.*;
026:        import java.io.*;
027:        import com.mchange.v2.log.*;
028:
029:        /**
030:         * MultiPropertiesConfig allows applications to accept configuration data
031:         * from a more than one property file (each of which is to be loaded from
032:         * a unique path using this class' ClassLoader's resource-loading mechanism),
033:         * and permits access to property data via the resource path from which the
034:         * properties were loaded, via the prefix of the property (where hierarchical 
035:         * property names are presumed to be '.'-separated), and simply by key.
036:         * In the by-key and by-prefix indices, when two definitions conflict, the
037:         * key value pairing specified in the MOST RECENT properties file shadows
038:         * earlier definitions, and files are loaded in the order of the list of
039:         * resource paths provided a constructor.
040:         *
041:         * The rescource path "/" is a special case that always refers to System
042:         * properties. No actual resource will be loaded.
043:
044:         * The class manages a special instance called "vmConfig" which is accessable
045:         * via a static method. It's resource path is list specified by a text-file,
046:         * itself a ClassLoader managed resource, which must be located at
047:         * <tt>/com/mchange/v2/cfg/vmConfigResourcePaths.txt</tt>. This file should
048:         * be one resource path per line, with blank lines ignored and lines beginning
049:         * with '#' treated as comments.
050:         */
051:        public abstract class MultiPropertiesConfig {
052:            final static MultiPropertiesConfig EMPTY = new BasicMultiPropertiesConfig(
053:                    new String[0]);
054:
055:            final static String VM_CONFIG_RSRC_PATHS = "/com/mchange/v2/cfg/vmConfigResourcePaths.txt";
056:
057:            static MultiPropertiesConfig vmConfig = null;
058:
059:            public static MultiPropertiesConfig read(String[] resourcePath,
060:                    MLogger logger) {
061:                return new BasicMultiPropertiesConfig(resourcePath, logger);
062:            }
063:
064:            public static MultiPropertiesConfig read(String[] resourcePath) {
065:                return new BasicMultiPropertiesConfig(resourcePath);
066:            }
067:
068:            public static MultiPropertiesConfig combine(
069:                    MultiPropertiesConfig[] configs) {
070:                return new CombinedMultiPropertiesConfig(configs);
071:            }
072:
073:            public static MultiPropertiesConfig readVmConfig(
074:                    String[] defaultResources, String[] preemptingResources) {
075:                List l = new LinkedList();
076:                if (defaultResources != null)
077:                    l.add(read(defaultResources));
078:                l.add(readVmConfig());
079:                if (preemptingResources != null)
080:                    l.add(read(preemptingResources));
081:                return combine((MultiPropertiesConfig[]) l
082:                        .toArray(new MultiPropertiesConfig[l.size()]));
083:            }
084:
085:            public static MultiPropertiesConfig readVmConfig() {
086:                if (vmConfig == null) {
087:                    List rps = new ArrayList();
088:
089:                    BufferedReader br = null;
090:                    try {
091:                        InputStream is = MultiPropertiesConfig.class
092:                                .getResourceAsStream(VM_CONFIG_RSRC_PATHS);
093:                        if (is != null) {
094:                            br = new BufferedReader(new InputStreamReader(is,
095:                                    "8859_1"));
096:                            String rp;
097:                            while ((rp = br.readLine()) != null) {
098:                                rp = rp.trim();
099:                                if ("".equals(rp) || rp.startsWith("#"))
100:                                    continue;
101:
102:                                rps.add(rp);
103:                            }
104:                            vmConfig = new BasicMultiPropertiesConfig(
105:                                    (String[]) rps.toArray(new String[rps
106:                                            .size()]));
107:                        } else {
108:                            System.err
109:                                    .println("com.mchange.v2.cfg.MultiPropertiesConfig: Resource path list could not be found at resource path: "
110:                                            + VM_CONFIG_RSRC_PATHS);
111:                            System.err
112:                                    .println("com.mchange.v2.cfg.MultiPropertiesConfig: Using empty vmconfig.");
113:                            vmConfig = EMPTY;
114:                        }
115:                    } catch (IOException e) {
116:                        e.printStackTrace();
117:                    } finally {
118:                        try {
119:                            if (br != null)
120:                                br.close();
121:                        } catch (IOException e) {
122:                            e.printStackTrace();
123:                        }
124:                    }
125:                }
126:                return vmConfig;
127:            }
128:
129:            public boolean foundVmConfig() {
130:                return vmConfig != EMPTY;
131:            }
132:
133:            public abstract String[] getPropertiesResourcePaths();
134:
135:            public abstract Properties getPropertiesByResourcePath(String path);
136:
137:            public abstract Properties getPropertiesByPrefix(String pfx);
138:
139:            public abstract String getProperty(String key);
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.