Source Code Cross Referenced for MetaBossSpecificUtils.java in  » UML » MetaBoss » com » metaboss » 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 » UML » MetaBoss » com.metaboss.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.util;
016:
017:        import java.io.File;
018:        import java.io.FileFilter;
019:        import java.io.FileInputStream;
020:        import java.io.IOException;
021:        import java.util.Properties;
022:
023:        import org.apache.commons.logging.Log;
024:        import org.apache.commons.logging.LogFactory;
025:
026:        /** Useful collection of MetaBoss internal utilities.
027:         * These utilities have little or no value for general use programs. */
028:        public class MetaBossSpecificUtils {
029:            // Commons Logging instance.
030:            private static final Object sLoggerInitialisationSemaphore = new Object();
031:            private static Log sLogger = null;
032:
033:            // This method will initialis logger if it has not been initialised yet
034:            // The rationale here is that we have to give applications a chance to 
035:            // call setupSystemProperties() before logger is initialised. Therefore
036:            // we have to delay initialisatin of the logger for as long as possible.
037:            // (and we are not using logger at all in the setupSystemProperties() method  
038:            private static void initialiseLoggerIfNecessary() {
039:                if (sLogger == null) {
040:                    synchronized (sLoggerInitialisationSemaphore) {
041:                        if (sLogger == null) {
042:                            sLogger = LogFactory
043:                                    .getLog(MetaBossSpecificUtils.class);
044:                        }
045:                    }
046:                }
047:            }
048:
049:            /** Returns the name of the directory where metaboss is installed or 
050:             * null if it was unable to determine the name of this directory */
051:            public static String getMetaBossHomeDir() {
052:                // This method may want to use loger
053:                initialiseLoggerIfNecessary();
054:
055:                String lMetaBossHome = System.getProperty("MetaBoss.Home");
056:                if (lMetaBossHome == null)
057:                    sLogger
058:                            .error("System property \"MetaBoss.Home\" is not defined. It is very likely that the application you are running is not configurred properly.");
059:                return lMetaBossHome;
060:            }
061:
062:            /** This method reads all *.properties file from the location specified by
063:             * MetaBoss.Home system property. After reading it proceeds to resolve possible
064:             * macros inside property values and after that it updates System properties with it
065:             * If MetaBoss.Home property is not defined - warning message is logged
066:             * If no properties file has not been found - warning message is logged
067:             * Note that files are loaded in no particular order, so duplicate key names would
068:             * override each other and the surviving value is unpredictable.
069:             * Also note that this method does not use commons logging in order to give
070:             * application  achance to load properties prior to initialising  the logging 
071:             */
072:            public static void setupSystemProperties() {
073:                String lMetaBossHome = System
074:                        .getProperty("MetaBoss.Home", null);
075:                if (lMetaBossHome == null) {
076:                    System.out
077:                            .println("System property \"MetaBoss.Home\" is not defined. It is very likely that the application you are running is not configurred properly.");
078:                    return;
079:                }
080:                File lMetaBossHomeDirectory = new File(lMetaBossHome)
081:                        .getAbsoluteFile();
082:                if (lMetaBossHomeDirectory.exists() == false) {
083:                    System.out
084:                            .println("Directory "
085:                                    + lMetaBossHomeDirectory.getAbsolutePath()
086:                                    + " not found. It is very likely that the application you are running is not configurred properly.");
087:                    return;
088:                }
089:
090:                File lMetaBossConfigDirectory = new File(lMetaBossHome
091:                        + File.separator + "config").getAbsoluteFile();
092:                if (lMetaBossConfigDirectory.exists() == false) {
093:                    System.out
094:                            .println("Directory "
095:                                    + lMetaBossConfigDirectory
096:                                            .getAbsolutePath()
097:                                    + " not found. It is very likely that the application you are running is not configurred properly.");
098:                    return;
099:                }
100:
101:                File[] lAllPropertyFiles = lMetaBossConfigDirectory
102:                        .listFiles(new FileFilter() {
103:                            public boolean accept(File pPathname) {
104:                                // Return all *.properties files
105:                                if (pPathname.isFile()) {
106:                                    String lFileName = pPathname.getName()
107:                                            .toLowerCase();
108:                                    if (lFileName.endsWith(".properties"))
109:                                        return true;
110:                                }
111:                                return false;
112:                            }
113:                        });
114:
115:                if (lAllPropertyFiles == null || lAllPropertyFiles.length == 0) {
116:                    System.out
117:                            .println("Not a single property file has been found in "
118:                                    + lMetaBossConfigDirectory
119:                                            .getAbsolutePath()
120:                                    + " directory. It is very likely that the application you are running is not configurred properly.");
121:                    return;
122:                }
123:
124:                Properties lLoadedProperties = new Properties();
125:                for (int i = 0; i < lAllPropertyFiles.length; i++) {
126:                    try {
127:                        lLoadedProperties.load(new FileInputStream(
128:                                lAllPropertyFiles[i]));
129:                    } catch (IOException e) {
130:                        System.err.println("Error while reading file "
131:                                + lAllPropertyFiles[i].getAbsolutePath());
132:                        e.printStackTrace(System.err);
133:                    }
134:                }
135:                Properties lSystemProperties = System.getProperties();
136:                Properties lResolvedProperties = PropertiesUtils
137:                        .resolveProperties(lLoadedProperties, lSystemProperties);
138:                lSystemProperties.putAll(lResolvedProperties);
139:                System.setProperties(lSystemProperties);
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.