Source Code Cross Referenced for StandaloneServletClient.java in  » Web-Framework » helma » helma » servlet » 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 » helma » helma.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Helma License Notice
003:         *
004:         * The contents of this file are subject to the Helma License
005:         * Version 2.0 (the "License"). You may not use this file except in
006:         * compliance with the License. A copy of the License is available at
007:         * http://adele.helma.org/download/helma/license.txt
008:         *
009:         * Copyright 1998-2003 Helma Software. All Rights Reserved.
010:         *
011:         * $RCSfile$
012:         * $Author: root $
013:         * $Revision: 8604 $
014:         * $Date: 2007-09-28 15:16:38 +0200 (Fre, 28 Sep 2007) $
015:         */
016:
017:        package helma.servlet;
018:
019:        import helma.framework.repository.Repository;
020:        import helma.framework.core.Application;
021:        import helma.framework.repository.FileRepository;
022:        import java.io.*;
023:        import javax.servlet.*;
024:
025:        /**
026:         *  Standalone servlet client that runs a Helma application all by itself
027:         *  in embedded mode without relying on a central instance of helma.main.Server
028:         *  to start and manage the application.
029:         *
030:         *  StandaloneServletClient takes the following init parameters:
031:         *     <ul>
032:         *       <li> application - the application name </li>
033:         *       <li> appdir - the path of the application home directory </li>
034:         *       <li> dbdir - the path of the embedded XML data store </li>
035:         *     </ul>
036:         */
037:        public final class StandaloneServletClient extends
038:                AbstractServletClient {
039:            private Application app = null;
040:            private String appName;
041:            private String appDir;
042:            private String dbDir;
043:
044:            /**
045:             *
046:             *
047:             * @param init ...
048:             *
049:             * @throws ServletException ...
050:             */
051:            public void init(ServletConfig init) throws ServletException {
052:                super .init(init);
053:
054:                appName = init.getInitParameter("application");
055:
056:                if ((appName == null) || (appName.trim().length() == 0)) {
057:                    throw new ServletException(
058:                            "application parameter not specified");
059:                }
060:
061:                appDir = init.getInitParameter("appdir");
062:
063:                if ((appDir == null) || (appDir.trim().length() == 0)) {
064:                    throw new ServletException("appdir parameter not specified");
065:                }
066:
067:                dbDir = init.getInitParameter("dbdir");
068:
069:                if ((dbDir == null) || (dbDir.trim().length() == 0)) {
070:                    throw new ServletException("dbdir parameter not specified");
071:                }
072:            }
073:
074:            /**
075:             * Returns the {@link helma.framework.core.Application Applicaton}
076:             * instance the servlet is talking to.
077:             *
078:             * @return this servlet's application instance
079:             */
080:            Application getApplication() {
081:                if (app == null) {
082:                    createApp();
083:                }
084:
085:                return app;
086:            }
087:
088:            /**
089:             * Create the application. Since we are synchronized only here, we
090:             * do another check if the app already exists and immediately return if it does.
091:             */
092:            synchronized void createApp() {
093:                if (app != null) {
094:                    return;
095:                }
096:
097:                try {
098:                    Repository[] repositories = new Repository[1];
099:                    repositories[0] = new FileRepository(new File(appDir));
100:                    File dbHome = new File(dbDir);
101:
102:                    app = new Application(appName, repositories, dbHome);
103:                    app.init();
104:                    app.start();
105:                } catch (Exception x) {
106:                    log("Error starting Application " + appName + ": " + x);
107:                    x.printStackTrace();
108:                }
109:            }
110:
111:            /**
112:             * The servlet is being destroyed. Close and release the application if
113:             * it does exist.
114:             */
115:            public void destroy() {
116:                if (app != null) {
117:                    try {
118:                        app.stop();
119:                    } catch (Exception x) {
120:                        log("Error shutting down app " + app.getName() + ": ");
121:                        x.printStackTrace();
122:                    }
123:                }
124:
125:                app = null;
126:            }
127:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.