Source Code Cross Referenced for Project.java in  » Web-Framework » JAT » com » jat » core » 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 » Web Framework » JAT » com.jat.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.core;
002:
003:        import java.util.Enumeration;
004:        import java.util.Vector;
005:
006:        import com.jat.core.config.Config;
007:        import com.jat.core.init.Initable;
008:        import com.jat.core.log.LogManager;
009:
010:        /**
011:         * <p>Title: JAT</p>
012:         * <p>Description: This class is responsible for JAT project activation.
013:         * </p>
014:         * <p>
015:         * You can use this class in your standalone application (e.g. batch program, server application, ect.)
016:         * or Web application.<br>
017:         * In case of Web Application you can use the servlet {@link com.jat.core.ProjectServlet} to instantiate this class.
018:         * </p>
019:         * <p>
020:         * A configuration file is needed to instantiate this class.
021:         * You can pass the configuration file name in the main method (in case of standalone application) or in the servlet initialization configuration of your application server.
022:         * Otherwise the default configuration file name will be used.
023:         * </p>
024:         * <p><b>Configuration:</b><br/>
025:         * The following sections must be configured:
026:         * <ul>
027:         * <li><b>general</b>:
028:         * <ul>
029:         * <li><b>date_format</b>: date format (ex. <i>dd/MM/yyyy</i>)</li>
030:         * <li><b>long_date_format</b>: long date format (ex. <i>dd/MM/yyyy HH:mm</i>)</li>
031:         * <li><b>version</b>: project version
032:         * </ul>
033:         * </li>
034:         * <li><b>config</b>: further configuration file name list (absolute or relative path included)</li>
035:         * <li><b>log</b>: logging information (see {@link com.jat.core.log.LogManager})
036:         * <li><b>init</b>: the list of object to be pre-loaded; these objects must implement the {@link com.jat.core.init.Initable} interface</li>
037:         * <li><b>xml_object</b>: the configuration for the business object XML representation (see {@link com.com.jat.business.BusinessObject} and {@link com.jat.business.BusinessObjectList})
038:         * <ul>
039:         * <li><b>schema</b> (<u>optional</u>) the XML schema filename (with absolute or relative path)</li>
040:         * <li><b>list</b> the name of the tag for a list of objects (see {@link com.jat.business.BusinessObjectList}. It must be conformed to the XML schema, if used</li>
041:         * <li><b>object</b> the name of the tag for an object (see {@link com.com.jat.business.BusinessObject}.It must be conformed to the XML schema, if used</li>
042:         * <li><b>property</b> the name of the tag for a property of an object (see {@link com.com.jat.business.BusinessObject}.It must be conformed to the XML schema, if used</li>
043:         * </ul>
044:         * </li>
045:         * <li><b>authentication</b> the class name responsible for authentication, if needed. This class must extends the {@link com.jat.business.authentication.Authenticator} class</li>
046:         * </ul>
047:         * </p>
048:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
049:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
050:         * @author stf
051:         * @version 1.1
052:         * @see com.jat.core.log.LogManager
053:         * @see com.jat.core.config.Config
054:         */
055:
056:        public final class Project {
057:
058:            public static Project getInstance() {
059:                return project_;
060:            }
061:
062:            public void init() throws Exception {
063:                errorOccours_ = 0;
064:                try {
065:                    this .initConfigFiles();
066:                    LogManager.init();
067:                    initBusinessObjects();
068:                } catch (Exception ex) {
069:                    try {
070:                        LogManager
071:                                .sendError("Project::init:: exception: " + ex);
072:                    } catch (Exception ignored) {
073:                    }
074:                    throw new Exception("init exception: " + ex);
075:                }
076:            }
077:
078:            public void initBusinessObjects() throws Exception {
079:                try {
080:                    Vector vect = Config.getCurrent().getSubValues("init",
081:                            "object");
082:                    Initable initable = null;
083:                    for (Enumeration e = vect.elements(); e.hasMoreElements();) {
084:                        initable = (Initable) (Class.forName((String) e
085:                                .nextElement())).newInstance();
086:                        initable.init();
087:                        LogManager.sendDebug("Project::initBusinessObjects: "
088:                                + initable.getClass().getName()
089:                                + ": init successfully");
090:                    }
091:                } catch (Exception ex) {
092:                    LogManager
093:                            .sendError("Project::initBusinessObjects: exception: "
094:                                    + ex);
095:                }
096:            }
097:
098:            public void initConfigFiles() throws Exception {
099:                try {
100:                    Config config = Config.init(configFile);
101:                    Vector configFiles = config
102:                            .getSubValues("config", "config");
103:                    config.addFiles(configFiles);
104:                } catch (Exception ex) {
105:                    throw new Exception("exception initialiting config files: "
106:                            + ex);
107:                }
108:            }
109:
110:            private Project(String _configFile) throws Exception {
111:                try {
112:                    if (_configFile == null)
113:                        this .configFile = DEFAULT_CONFIG_FILE;
114:                    else
115:                        this .configFile = _configFile;
116:                    project_ = this ;
117:                    System.out.println("JAT Project starting...");
118:                    init();
119:                    LogManager.sendLog("JAT Project '" + this .getProjectName()
120:                            + "' successfully inited.");
121:                    if (errorOccours_ == 0)
122:                        System.out.println("JAT Project '"
123:                                + this .getProjectName()
124:                                + "' successfully started");
125:                    else
126:                        System.out
127:                                .println("JAT Project '"
128:                                        + this .getProjectName()
129:                                        + "' started but some error(s) occours. Please, see error log for more details.");
130:                    inited_ = true;
131:                } catch (Exception ex) {
132:                    initError_ = true;
133:                    initException_ = ex;
134:                    System.out.println("Project init error: " + ex);
135:                    try {
136:                        LogManager.sendError("Project:: " + ex);
137:                    } catch (Exception ignored) {
138:                    }
139:                    throw ex;
140:                }
141:            }
142:
143:            public static synchronized void create(String configFile)
144:                    throws Exception {
145:                if (Project.initError_)
146:                    throw initException_;
147:                if (!inited_)
148:                    new Project(configFile);
149:            }
150:
151:            public static void notifyError() {
152:                errorOccours_++;
153:            }
154:
155:            public static int getErrors() {
156:                return errorOccours_;
157:            }
158:
159:            public static String getHostApplication() {
160:                if (hostAddress == null) {
161:                    try {
162:                        hostAddress = java.net.InetAddress.getLocalHost()
163:                                .getHostAddress();
164:                    } catch (Exception e) {
165:                        System.out
166:                                .println("Project::getHostApplication:: exception: "
167:                                        + e);
168:                        hostAddress = "N.D.";
169:                    }
170:                }
171:                return hostAddress;
172:            }
173:
174:            public String getProjectName() {
175:                try {
176:                    return Config.getCurrent().getValue("general",
177:                            "project_name");
178:                } catch (Exception ex) {
179:                    return "Unknown";
180:                }
181:            }
182:
183:            public String getVersion() throws Exception {
184:                return Config.getCurrent().getValue("general", "version");
185:            }
186:
187:            public static void main(String[] args) {
188:                String configFile = DEFAULT_CONFIG_FILE;
189:                try {
190:                    configFile = args[0];
191:                    System.out.println("JAT application: config file: "
192:                            + configFile);
193:                } catch (Exception ex) {
194:                    System.out
195:                            .println("JAT application: config file not found. Using default: "
196:                                    + configFile);
197:                }
198:                try {
199:                    Project.create(configFile);
200:                } catch (Exception ex) {
201:                    ex.printStackTrace();
202:                }
203:            }
204:
205:            protected static final String DEFAULT_CONFIG_FILE = "./config/general.config";
206:            protected String configFile;
207:
208:            /**
209:             * The unique CGConfig instance
210:             */
211:            private static Project project_ = null;
212:
213:            private static boolean inited_ = false;
214:            private static boolean initError_ = false;
215:            private static int errorOccours_ = 0;
216:            private static Exception initException_ = null;
217:            private static String hostAddress;
218:            private static String format;
219:            private static final String DEFAULT_FORMAT = "dd/MM/yyyy";
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.