Source Code Cross Referenced for Directories.java in  » Net » Terracotta » com » tc » 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 » Net » Terracotta » com.tc.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.config;
005:
006:        import org.apache.commons.lang.StringUtils;
007:
008:        import java.io.File;
009:        import java.io.FileNotFoundException;
010:
011:        /**
012:         * Knows how to find certain directories. You should try <em>everything</em> you can to avoid using this class; using
013:         * it requires the user to set various system properties when running Terracotta, and we try to avoid that if at all
014:         * possible.
015:         */
016:        public class Directories {
017:
018:            /**
019:             * This is <code>public</code> <strong>ONLY</strong> so that some entities can <strong>SET</strong> it. You should
020:             * <strong>NOT</strong> set it yourself; that breaks the point of encapsulation. Use the method 
021:             * {@link Environment#inTest()} instead.  The property name is "tc.install-root".  
022:             */
023:            public static final String TC_INSTALL_ROOT_PROPERTY_NAME = "tc.install-root";
024:
025:            /**
026:             * The property "tc.install-root.ignore-checks", which is used for testing to ignore checks for the installation 
027:             * root directory.
028:             */
029:            public static final String TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME = "tc.install-root.ignore-checks";
030:
031:            /**
032:             * The property "tc.license-location", which indicates the directory containing the license.
033:             */
034:            public static final String TC_LICENSE_LOCATION_PROPERTY_NAME = "tc.license-location";
035:
036:            /**
037:             * Get the location of the license directory based on the value of {@link #TC_LICENSE_LOCATION_PROPERTY_NAME}.
038:             * @return Directory containing license file, never null
039:             * @throws FileNotFoundException If the tc.license-location directory has not been set, the license 
040:             * directory does not exist, or exists but is not a directory
041:             */
042:            public static File getLicenseLocation()
043:                    throws FileNotFoundException {
044:                String path = System
045:                        .getProperty(TC_LICENSE_LOCATION_PROPERTY_NAME);
046:                if (StringUtils.isBlank(path)) {
047:                    throw new FileNotFoundException(
048:                            "The system property '"
049:                                    + TC_LICENSE_LOCATION_PROPERTY_NAME
050:                                    + "' has not been set. As such, the Terracotta license location directory cannot be located.");
051:                }
052:                File licenseDir = new File(path).getAbsoluteFile();
053:                if (!licenseDir.exists() || !licenseDir.isDirectory()) {
054:                    throw new FileNotFoundException(
055:                            "The specified Terracotta installation directory, '"
056:                                    + licenseDir
057:                                    + "', located via the value of the system property '"
058:                                    + TC_LICENSE_LOCATION_PROPERTY_NAME
059:                                    + "', does not actually exist.");
060:                }
061:                return licenseDir;
062:            }
063:
064:            /**
065:             * Get installation root directory.
066:             * 
067:             * @return Installation root directory or null if TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME is set and
068:             *         TC_INSTALL_ROOT_PROPERTY_NAME is not.
069:             * @throws FileNotFoundException If {@link #TC_INSTALL_ROOT_PROPERTY_NAME} has not been set. If
070:             *         {@link #TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME} has not been set, this exception may be thrown if the
071:             *         installation root directory has not been set, is not a directory, or does not contain a lib/tc.jar that is
072:             *         a file.
073:             */
074:            public static File getInstallationRoot()
075:                    throws FileNotFoundException {
076:                boolean ignoreCheck = System
077:                        .getProperty(TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME) != null;
078:                String path = System.getProperty(TC_INSTALL_ROOT_PROPERTY_NAME);
079:                File theFile = path != null ? new File(path).getAbsoluteFile()
080:                        : null;
081:
082:                if (!ignoreCheck) {
083:                    if (StringUtils.isBlank(path)) {
084:                        // formatting
085:                        throw new FileNotFoundException(
086:                                "The system property '"
087:                                        + TC_INSTALL_ROOT_PROPERTY_NAME
088:                                        + "' has not been set. As such, the Terracotta installation directory cannot be located.");
089:                    }
090:
091:                    String absolutePath = theFile.getAbsolutePath();
092:                    if (!theFile.isDirectory()) {
093:                        // formatting
094:                        throw new FileNotFoundException(
095:                                "The specified Terracotta installation directory, '"
096:                                        + absolutePath
097:                                        + "', located via the value of the system property '"
098:                                        + TC_INSTALL_ROOT_PROPERTY_NAME
099:                                        + "', does not actually exist.");
100:                    }
101:
102:                    File searchFile = new File(new File(theFile, "lib"),
103:                            "tc.jar");
104:
105:                    if (!searchFile.exists() || !searchFile.isFile()) {
106:                        // This is just so we don't have to have tc.jar around in development configurations.
107:                        if (new File(theFile,
108:                                ".force-is-terracotta-install-dir").exists())
109:                            return theFile;
110:                        else {
111:                            // formatting
112:                            throw new FileNotFoundException(
113:                                    "The specified Terracotta installation directory, '"
114:                                            + absolutePath
115:                                            + "', located via the value of the system property '"
116:                                            + TC_INSTALL_ROOT_PROPERTY_NAME
117:                                            + "', does not seem to actually "
118:                                            + "be the root of the Terracotta installation. (The required "
119:                                            + "Terracotta JAR file, '"
120:                                            + searchFile.getAbsolutePath()
121:                                            + "', does not exist or is not a file.)");
122:                        }
123:                    }
124:                }
125:
126:                return theFile;
127:            }
128:
129:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.