Source Code Cross Referenced for AbstractTomcatContainer.java in  » Testing » jakarta-cactus » org » apache » cactus » integration » ant » container » tomcat » 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 » Testing » jakarta cactus » org.apache.cactus.integration.ant.container.tomcat 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * ========================================================================
003:         * 
004:         * Copyright 2003-2004 The Apache Software Foundation.
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         * 
018:         * ========================================================================
019:         */
020:        package org.apache.cactus.integration.ant.container.tomcat;
021:
022:        import java.io.File;
023:        import java.io.IOException;
024:        import java.util.ArrayList;
025:        import java.util.Iterator;
026:        import java.util.List;
027:
028:        import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
029:        import org.apache.tools.ant.BuildException;
030:        import org.apache.tools.ant.taskdefs.Copy;
031:        import org.apache.tools.ant.types.FileSet;
032:        import org.apache.tools.ant.util.FileUtils;
033:
034:        /**
035:         * Base support for Catalina based containers.
036:         * 
037:         * @version $Id: AbstractTomcatContainer.java 238811 2004-02-29 10:10:42Z vmassol $
038:         */
039:        public abstract class AbstractTomcatContainer extends
040:                AbstractJavaContainer {
041:
042:            // Instance Variables ------------------------------------------------------
043:
044:            /**
045:             * The Catalina installation directory.
046:             */
047:            private File dir;
048:
049:            /**
050:             * List of filesets that contain user-specified files that should be added
051:             * to the Tomcat conf directory.
052:             */
053:            private List confFileSets = new ArrayList();
054:
055:            /**
056:             * A user-specific server.xml configuration file. If this variable is not
057:             * set, the default configuration file from the JAR resources will be used.
058:             */
059:            private File serverXml;
060:
061:            /**
062:             * The port to which the container should be bound.
063:             */
064:            private int port = 8080;
065:
066:            // Public Methods ----------------------------------------------------------
067:
068:            /**
069:             * Adds a set of files to include in the Tomcat configuration directory.
070:             * 
071:             * @param theConf The fileset to add
072:             */
073:            public final void addConf(FileSet theConf) {
074:                // Exclude the server.xml file as there is a "serverXml" specific 
075:                // property for it.
076:                theConf.createExclude().setName("**/server.xml");
077:
078:                this .confFileSets.add(theConf);
079:            }
080:
081:            /**
082:             * Sets the Tomcat installation directory.
083:             * 
084:             * @return The directory
085:             */
086:            public final File getDir() {
087:                return this .dir;
088:            }
089:
090:            /**
091:             * Sets the Tomcat installation directory.
092:             * 
093:             * @param theDir The directory to set
094:             */
095:            public final void setDir(File theDir) {
096:                this .dir = theDir;
097:            }
098:
099:            /**
100:             * @return The server.xml file, if set or null otherwise
101:             */
102:            public final File getServerXml() {
103:                return this .serverXml;
104:            }
105:
106:            /**
107:             * Sets the server configuration file to use for the test installation of
108:             * Tomcat.
109:             *  
110:             * @param theServerXml The server.xml file
111:             */
112:            public final void setServerXml(File theServerXml) {
113:                this .serverXml = theServerXml;
114:            }
115:
116:            /**
117:             * Sets the port to which the container should listen.
118:             * 
119:             * @param thePort The port to set
120:             */
121:            public final void setPort(int thePort) {
122:                this .port = thePort;
123:            }
124:
125:            // AbstractContainer Implementation ----------------------------------------
126:
127:            /**
128:             * Returns the port to which the container should listen.
129:             * 
130:             * @return The port
131:             */
132:            public final int getPort() {
133:                return this .port;
134:            }
135:
136:            /**
137:             * @see org.apache.cactus.integration.ant.container.Container#init
138:             */
139:            public void init() {
140:                if (!this .dir.isDirectory()) {
141:                    throw new BuildException(this .dir + " is not a directory");
142:                }
143:
144:                if (!getDeployableFile().isWar()) {
145:                    throw new BuildException("Tomcat doesn't support the "
146:                            + "deployment of EAR files");
147:                }
148:            }
149:
150:            // Protected Methods -------------------------------------------------------
151:
152:            /**
153:             * Copies the configuration files specified by nested <conf> filesets
154:             * to the conf/ directory.
155:             * 
156:             * @param theConfDir The Tomcat configuration directory
157:             */
158:            protected final void copyConfFiles(File theConfDir) {
159:                if (getServerXml() != null) {
160:                    FileUtils fileUtils = FileUtils.newFileUtils();
161:                    try {
162:                        fileUtils.copyFile(getServerXml(), new File(theConfDir,
163:                                "server.xml"));
164:                    } catch (IOException ioe) {
165:                        throw new BuildException("Could not copy "
166:                                + getServerXml() + " to directory "
167:                                + theConfDir, ioe);
168:                    }
169:                }
170:
171:                if (!this .confFileSets.isEmpty()) {
172:                    Copy copy = (Copy) createAntTask("copy");
173:                    copy.setTodir(theConfDir);
174:                    for (Iterator i = this .confFileSets.iterator(); i.hasNext();) {
175:                        copy.addFileset((FileSet) i.next());
176:                    }
177:                    copy.execute();
178:                }
179:            }
180:
181:        }
w___w_w._ja_v___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.