Source Code Cross Referenced for RomaApplicationContext.java in  » Web-Framework » roma-webwizard » org » romaframework » core » 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 » Web Framework » roma webwizard » org.romaframework.core.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Luca Garulli (luca.garulli@assetdata.it)
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.romaframework.core.config;
018:
019:        import org.apache.commons.logging.Log;
020:        import org.apache.commons.logging.LogFactory;
021:        import org.romaframework.aspect.persistence.PersistenceAspect;
022:        import org.romaframework.core.Utility;
023:        import org.romaframework.core.aspect.AspectManager;
024:        import org.romaframework.core.flow.ObjectContext;
025:        import org.romaframework.core.module.ModuleManager;
026:        import org.springframework.context.ApplicationContext;
027:
028:        /**
029:         * Central singleton class to gather all service using Spring Application Context.
030:         * 
031:         * @author Luca Garulli (luca.garulli@assetdata.it)
032:         */
033:        public class RomaApplicationContext {
034:
035:            public static final byte STATUS_DOWN = 0;
036:            public static final byte STATUS_STARTUP = 1;
037:            public static final byte STATUS_UP = 2;
038:            public static final byte STATUS_SHUTDOWN = 3;
039:
040:            protected String applicationName;
041:            protected String applicationVersion = "1.0";
042:            protected String applicationPackage;
043:            protected boolean applicationDevelopment;
044:            protected ApplicationContext springContext;
045:            protected static String applicationPath;
046:            protected static byte status = STATUS_DOWN;
047:
048:            protected static RomaApplicationContext instance = null;
049:            protected static Log log = LogFactory
050:                    .getLog(RomaApplicationContext.class);
051:
052:            /**
053:             * Constructor called by Spring configuration.
054:             */
055:            public RomaApplicationContext() {
056:                instance = this ;
057:            }
058:
059:            protected synchronized void startup(ApplicationContext iContext) {
060:                status = STATUS_STARTUP;
061:
062:                springContext = iContext;
063:
064:                // TODO REMOVE THIS
065:                PersistenceAspect db = null;
066:                if (ObjectContext.getInstance().existComponent(
067:                        PersistenceAspect.class))
068:                    db = ObjectContext.getInstance().getContextComponent(
069:                            PersistenceAspect.class);
070:
071:                try {
072:                    // START ALL ASPECTS
073:                    AspectManager.getInstance().startup();
074:
075:                    // START ALL MODULES
076:                    ModuleManager.getInstance().startup();
077:
078:                    // STAR USER APPLICATION CONFIGURATION OBJECT
079:                    getBean(ApplicationConfiguration.class).startup();
080:
081:                    if (db != null)
082:                        db.commit();
083:                } finally {
084:                    if (db != null) {
085:                        db.close();
086:                        ObjectContext.getInstance().setContextComponent(
087:                                PersistenceAspect.class, null);
088:                    }
089:                }
090:
091:                status = STATUS_UP;
092:            }
093:
094:            public synchronized void shutdown() {
095:                status = STATUS_SHUTDOWN;
096:
097:                // STOP USER APPLICATION CONFIGURATION OBJECT
098:                getBean(ApplicationConfiguration.class).shutdown();
099:
100:                // STOP ALL MODULES
101:                ModuleManager.getInstance().shutdown();
102:
103:                // STOP ALL ASPECTS
104:                AspectManager.getInstance().shutdown();
105:
106:                springContext = null;
107:
108:                status = STATUS_DOWN;
109:            }
110:
111:            public <T> T getBean(Class<T> iBeanClass) {
112:                return (T) springContext.getBean(iBeanClass.getSimpleName(),
113:                        iBeanClass);
114:            }
115:
116:            public <T> T getBean(String iBeanName) {
117:                return (T) springContext.getBean(iBeanName);
118:            }
119:
120:            /*
121:             * public ServletConfig getServletConfig() { return servletConfig; }
122:             */
123:            public String getApplicationName() {
124:                return applicationName;
125:            }
126:
127:            public void setApplicationName(String applicationName) {
128:                this .applicationName = applicationName;
129:            }
130:
131:            public String getApplicationPackage() {
132:                return applicationPackage;
133:            }
134:
135:            public void setApplicationPackage(String applicationPackage) {
136:                this .applicationPackage = applicationPackage;
137:            }
138:
139:            public boolean isApplicationDevelopment() {
140:                return applicationDevelopment;
141:            }
142:
143:            public void setApplicationDevelopment(boolean applicationDevelopment) {
144:                this .applicationDevelopment = applicationDevelopment;
145:            }
146:
147:            public static String getApplicationPath() {
148:                return applicationPath;
149:            }
150:
151:            public String getApplicationVersion() {
152:                return applicationVersion;
153:            }
154:
155:            public void setApplicationVersion(String applicationVersion) {
156:                this .applicationVersion = applicationVersion;
157:            }
158:
159:            public static void setApplicationPath(String iApplicationPath) {
160:                iApplicationPath = Utility
161:                        .getUniversalResourcePath(iApplicationPath);
162:
163:                if (iApplicationPath.endsWith(Utility.PATH_SEPARATOR_STRING))
164:                    iApplicationPath = iApplicationPath.substring(0,
165:                            iApplicationPath.length() - 1);
166:
167:                applicationPath = iApplicationPath;
168:
169:                log.info("[RomaApplicationContext.setApplicationPath] "
170:                        + applicationPath);
171:            }
172:
173:            public static RomaApplicationContext getInstance() {
174:                return instance;
175:            }
176:
177:            public static void setup(ApplicationContext iSpringContext) {
178:                if (instance != null) {
179:                    instance.startup(iSpringContext);
180:                }
181:            }
182:
183:            public static byte getStatus() {
184:                return status;
185:            }
186:
187:            public boolean existBean(String iComponentName) {
188:                return springContext.containsBean(iComponentName);
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.