Source Code Cross Referenced for Jetty5FileSystemInstaller.java in  » Portal » Pluto » org » apache » pluto » util » install » file » jetty » 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 » Portal » Pluto » org.apache.pluto.util.install.file.jetty 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.pluto.util.install.file.jetty;
018:
019:        import org.apache.commons.io.FileUtils;
020:        import org.apache.pluto.util.install.InstallationConfig;
021:        import org.apache.pluto.util.install.file.FileSystemInstaller;
022:        import org.apache.pluto.util.UtilityException;
023:
024:        import java.io.File;
025:        import java.io.IOException;
026:        import java.util.Iterator;
027:
028:        public class Jetty5FileSystemInstaller extends FileSystemInstaller {
029:
030:            protected File getEndorsedDir(InstallationConfig config) {
031:                File installationDirectory = config.getInstallationDirectory();
032:                return new File(installationDirectory, "ext");
033:            }
034:
035:            protected File getSharedDir(InstallationConfig config) {
036:                File installationDirectory = config.getInstallationDirectory();
037:                // Jetty 5.1 provides commons-logging.  Should be a nicer way
038:                // for installers to indicate what dependencies are provided by the
039:                // servlet container.
040:                if (new File(config.getInstallationDirectory(),
041:                        "ext/commons-logging.jar").exists()) {
042:                    for (Iterator iter = config.getSharedDependencies()
043:                            .iterator(); iter.hasNext();) {
044:                        File dep = (File) iter.next();
045:                        if (dep.getPath().indexOf("commons-logging-api") != -1) {
046:                            iter.remove();
047:                        }
048:                    }
049:                }
050:                return new File(installationDirectory, "ext");
051:            }
052:
053:            protected File getWebAppDir(InstallationConfig config) {
054:                File installationDirectory = config.getInstallationDirectory();
055:                return new File(installationDirectory, "webapps");
056:            }
057:
058:            protected File getConfigurationDir(InstallationConfig config) {
059:                File installationDirectory = config.getInstallationDirectory();
060:                String engine = "Catalina";
061:                String host = config.getServerConfig().getHost();
062:                return new File(installationDirectory, "conf/" + engine + "/"
063:                        + host);
064:            }
065:
066:            public void uninstall(InstallationConfig config) {
067:            }
068:
069:            public void deploy() {
070:
071:            }
072:
073:            public boolean isValidInstallationDirectory(File installDir) {
074:                File serverConfig = new File(installDir, "etc/jetty.xml");
075:                return serverConfig.exists();
076:            }
077:
078:            /**
079:             * NOTE: Order is important.  If the server is running, we want to
080:             * make sure that the correct order is preserved
081:             * <p/>
082:             * 1) Install endorsed dependencies
083:             * 2) Install shared dependencies
084:             * 4) Prep Time
085:             * -- Create a domain directory for the portal
086:             * -- Init the configs holder
087:             * 5) Install the Portlet Applications
088:             * 6) Install the Portal Application
089:             * 7) Finally, install the configs
090:             *
091:             * @param config
092:             * @throws org.apache.pluto.util.UtilityException
093:             *
094:             */
095:            public void install(InstallationConfig config)
096:                    throws UtilityException {
097:                File endorsedDir = getEndorsedDir(config);
098:                File sharedDir = getSharedDir(config);
099:                File domainDir = getWebAppDir(config);
100:                domainDir.mkdirs();
101:                File contextConfigurationDirectory = getConfigurationDir(config);
102:
103:                try {
104:
105:                    // Jetty Doesn't need 'em
106:                    //copyFilesToDirectory(config.getEndorsedDependencies(), endorsedDir);
107:
108:                    copyFilesToDirectory(config.getSharedDependencies(),
109:                            sharedDir);
110:
111:                    Iterator it = config.getPortletApplications().values()
112:                            .iterator();
113:                    while (it.hasNext()) {
114:                        File portletApp = (File) it.next();
115:                        FileUtils.copyFileToDirectory(portletApp, domainDir);
116:                    }
117:
118:                    FileUtils.copyFileToDirectory(
119:                            config.getPortalApplication(), domainDir);
120:
121:                    //            it = config.getPortletApplications().entrySet().iterator();
122:                    //            while (it.hasNext()) {
123:                    //                Map.Entry entry = (Map.Entry) it.next();
124:                    //                String context = entry.getKey().toString();
125:                    //                File portletApp = (File) entry.getValue();
126:                    //
127:                    //                File deployed = new File(domainDir, portletApp.getName());
128:                    //                String contents = getPortletApplicationConfig(context, deployed);
129:                    //                //FileWriter out = new FileWriter(
130:                    //                //        new File(contextConfigurationDirectory, context + ".xml"));
131:                    //                out.write(contents);
132:                    //                out.flush();
133:                    //                out.close();
134:                    //            }
135:
136:                    //            File xmlFile = new File(contextConfigurationDirectory, config.getPortalContextPath() + ".xml");
137:                    //            FileWriter out = new FileWriter(xmlFile);
138:                    //            out.write(getPortalApplicationConfig(config));
139:                    //            out.flush();
140:                    //            out.close();
141:                } catch (IOException io) {
142:                    throw new UtilityException(io);
143:                }
144:            }
145:
146:            private String getPortalApplicationConfig(InstallationConfig config) {
147:                File domainDir = this .getWebAppDir(config);
148:                String war = domainDir.getAbsolutePath() + File.separatorChar
149:                        + config.getPortalApplication().getName();
150:                String contextPath = config.getPortalContextPath();
151:                return getConfigContents(war, contextPath);
152:            }
153:
154:            private String getPortletApplicationConfig(String contextPath,
155:                    File file) {
156:                String war = file.getAbsolutePath();
157:                return getConfigContents(war, contextPath);
158:            }
159:
160:            public void writeConfiguration(InstallationConfig config) {
161:
162:            }
163:
164:            private String getConfigContents(String war, String contextPath) {
165:                return "JettyConfigContents: war=" + war + "contextPath="
166:                        + contextPath;
167:            }
168:        }
w_w_w.j___ava2_s__._c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.