Source Code Cross Referenced for Tomcat5FileSystemInstaller.java in  » Portal » Pluto » org » apache » pluto » util » install » file » tomcat5 » 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.tomcat5 
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.tomcat5;
018:
019:        import java.io.File;
020:        import java.io.FileWriter;
021:        import java.io.IOException;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:
026:        import org.apache.pluto.util.install.InstallationConfig;
027:        import org.apache.pluto.util.install.file.FileSystemInstaller;
028:
029:        public class Tomcat5FileSystemInstaller extends FileSystemInstaller {
030:
031:            //
032:            // PortalInstaller Interface
033:            //
034:
035:            /**
036:             * Determine whether or not this is a valid Tomcat 5.x installation.
037:             * @param installDir the proposed TOMCAT BASE directory
038:             * @return true if and only if <code>conf/server.xml</code> and
039:             *         <code>conf/catalina.properties exist.</code>
040:             */
041:            public boolean isValidInstallationDirectory(File installDir) {
042:                File serverConfig = new File(installDir, "conf/server.xml");
043:                File catalinaProps = new File(installDir,
044:                        "conf/catalina.properties");
045:                return serverConfig.exists() && catalinaProps.exists();
046:            }
047:
048:            //
049:            // FileSystemInstaller Implementation
050:            //
051:
052:            public void writeConfiguration(InstallationConfig config)
053:                    throws IOException {
054:
055:                File contextConfigurationDirectory = getConfigurationDir(config);
056:                if (!contextConfigurationDirectory.exists()) {
057:                    contextConfigurationDirectory.mkdirs();
058:                }
059:
060:                Iterator it = config.getPortletApplications().entrySet()
061:                        .iterator();
062:                while (it.hasNext()) {
063:                    Map.Entry entry = (Map.Entry) it.next();
064:                    String context = entry.getKey().toString();
065:                    File portletApp = (File) entry.getValue();
066:
067:                    String deployed = "../"
068:                            + config.getServerConfig().getDomain() + "/"
069:                            + portletApp.getName();
070:                    String contents = getPortletApplicationConfig(context,
071:                            deployed);
072:                    FileWriter out = new FileWriter(new File(
073:                            contextConfigurationDirectory, context + ".xml"));
074:                    out.write(contents);
075:                    out.flush();
076:                    out.close();
077:                }
078:
079:                File xmlFile = new File(contextConfigurationDirectory, config
080:                        .getPortalContextPath()
081:                        + ".xml");
082:
083:                FileWriter out = new FileWriter(xmlFile);
084:                out.write(getPortalApplicationConfig(config));
085:                out.flush();
086:                out.close();
087:            }
088:
089:            protected File getEndorsedDir(InstallationConfig config) {
090:                File installationDirectory = config.getInstallationDirectory();
091:                return new File(installationDirectory, "common/endorsed");
092:            }
093:
094:            protected File getSharedDir(InstallationConfig config) {
095:                File installationDirectory = config.getInstallationDirectory();
096:                // Tomcat 5 provides commons-logging-api.  Should be a nicer way
097:                // for installers to indicate what dependencies are provided by the
098:                // servlet container.
099:                if (new File(config.getInstallationDirectory(),
100:                        "bin/commons-logging-api.jar").exists()) {
101:                    for (Iterator iter = config.getSharedDependencies()
102:                            .iterator(); iter.hasNext();) {
103:                        File dep = (File) iter.next();
104:                        if (dep.getPath().indexOf("commons-logging-api") != -1) {
105:                            iter.remove();
106:                        }
107:                    }
108:                }
109:                return new File(installationDirectory, "shared/lib");
110:            }
111:
112:            protected File getWebAppDir(InstallationConfig config) {
113:                File installationDirectory = config.getInstallationDirectory();
114:                return new File(installationDirectory, config.getServerConfig()
115:                        .getDomain());
116:            }
117:
118:            //
119:            // Helpers
120:            //
121:
122:            protected File getConfigurationDir(InstallationConfig config) {
123:                File installationDirectory = config.getInstallationDirectory();
124:                String engine = "Catalina";
125:                String host = config.getServerConfig().getHost();
126:                return new File(installationDirectory, "conf/" + engine + "/"
127:                        + host);
128:            }
129:
130:            private String getPortalApplicationConfig(InstallationConfig config) {
131:                String war = "../" + config.getServerConfig().getDomain() + "/"
132:                        + config.getPortalApplication().getName();
133:                String contextPath = config.getPortalContextPath();
134:                return getConfigContents(war, contextPath);
135:            }
136:
137:            private String getPortletApplicationConfig(String contextPath,
138:                    String file) {
139:                return getConfigContents(file, contextPath);
140:            }
141:
142:            private String getConfigContents(String war, String contextPath) {
143:                StringBuffer contents = new StringBuffer();
144:                contents.append("<Context ").append("path=\"").append(
145:                        contextPath).append("\" ").append("docBase=\"").append(
146:                        war).append("\" ").append("crossContext=\"true\">")
147:                        .append("</Context>");
148:                return contents.toString();
149:            }
150:        }
w__w_w_.j__av___a2__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.