Source Code Cross Referenced for Tomcat.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ant » jonasbase » web » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.ant.jonasbase.web 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: Tomcat.java 9523 2006-09-05 15:55:34Z pelletib $
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.ant.jonasbase.web;
025:
026:        import org.objectweb.jonas.ant.JOnASBaseTask;
027:        import org.objectweb.jonas.ant.jonasbase.JReplace;
028:        import org.objectweb.jonas.ant.jonasbase.Tasks;
029:
030:        /**
031:         * Support Tomcat Connector Configuration.
032:         * Prefered order : http, director, ajp, https, cluster.
033:         *
034:         * @author Guillaume Sauthier
035:         */
036:        public class Tomcat extends Tasks {
037:
038:            /**
039:             * Info for the logger
040:             */
041:            private static final String INFO = "[Tomcat] ";
042:
043:            /**
044:             * Tomcat AJP Connector token
045:             */
046:            private static final String AJP_CONNECTOR_TOKEN = "<!-- Define an AJP";
047:
048:            /**
049:             * Tomcat HTTPS Connector token
050:             */
051:            private static final String HTTPS_CONNECTOR_TOKEN = "<!-- Define a SSL Coyote HTTP/1.1";
052:
053:            /**
054:             * Proxied HTTP/1.1 COnnector Token used to insert Director Connector.
055:             */
056:            private static final String DIRECTOR_CONNECTOR_TOKEN = "<!-- Define a Proxied HTTP/1.1";
057:
058:            /**
059:             * Tomcat HTTPS Connector token
060:             */
061:            private static final String JVM_ROUTE_TOKEN = "<Engine name=\"jonas\" defaultHost=\"localhost\">";
062:
063:            /**
064:             * Is HTTP Configured ?
065:             */
066:            private boolean httpConfigured = false;
067:
068:            /**
069:             * Default Constructor.
070:             */
071:            public Tomcat() {
072:                super ();
073:            }
074:
075:            /**
076:             * Configure a HTTP Connector.
077:             * @param http HTTP Configuration.
078:             */
079:            public void addConfiguredHttp(Http http) {
080:                httpConfigured = true;
081:                JReplace propertyReplace = new JReplace();
082:                propertyReplace
083:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
084:                propertyReplace.setToken(Http.DEFAULT_PORT);
085:                propertyReplace.setValue(http.getPort());
086:                propertyReplace.setLogInfo(INFO
087:                        + "Setting HTTP port number to : " + http.getPort());
088:                addTask(propertyReplace);
089:            }
090:
091:            /**
092:             * Configure a HTTPS Connector.
093:             * @param https HTTPS Configuration.
094:             */
095:            public void addConfiguredHttps(Https https) {
096:                // Add the HTTPS Connector
097:                JReplace propertyReplace = new JReplace();
098:                propertyReplace
099:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
100:                propertyReplace.setToken(HTTPS_CONNECTOR_TOKEN);
101:                StringBuffer value = new StringBuffer();
102:                value
103:                        .append("<!-- Define a SSL Coyote HTTP/1.1 Connector on port "
104:                                + https.getPort() + " -->\n");
105:                value.append("    <Connector port=\"" + https.getPort()
106:                        + "\" maxHttpHeaderSize=\"8192\"\n");
107:                value
108:                        .append("               maxThreads=\"150\" minSpareThreads=\"25\" maxSpareThreads=\"75\"\n");
109:                value
110:                        .append("               enableLookups=\"false\" disableUploadTimeout=\"true\"\n");
111:                value
112:                        .append("               acceptCount=\"100\" scheme=\"https\" secure=\"true\"\n");
113:                value
114:                        .append("               clientAuth=\"false\" sslProtocol=\"TLS\"\n");
115:                if (https.getKeystoreFile() != null) {
116:                    value.append("               keystoreFile=\""
117:                            + https.getKeystoreFile() + "\"\n");
118:                }
119:                if (https.getKeystorePass() != null) {
120:                    value.append("               keystorePass=\""
121:                            + https.getKeystorePass() + "\"\n");
122:                }
123:                value.append("               />\n\n");
124:                value.append("    " + HTTPS_CONNECTOR_TOKEN);
125:                propertyReplace.setValue(value.toString());
126:                propertyReplace.setLogInfo(INFO
127:                        + "Setting HTTPS Connector to : " + https.getPort());
128:                addTask(propertyReplace);
129:
130:                // Replace redirect port value in HTTP Connector
131:                propertyReplace = new JReplace();
132:                propertyReplace
133:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
134:                propertyReplace.setToken(" redirectPort=\""
135:                        + Https.DEFAULT_PORT + "\" ");
136:                propertyReplace.setValue(" redirectPort=\"" + https.getPort()
137:                        + "\" ");
138:                propertyReplace.setLogInfo(INFO
139:                        + "Fix HTTP redirect port number to : "
140:                        + https.getPort());
141:                addTask(propertyReplace);
142:
143:            }
144:
145:            /**
146:             * Configure an AJP Connector.
147:             * @param ajp AJP Configuration.
148:             */
149:            public void addConfiguredAjp(Ajp ajp) {
150:                JReplace propertyReplace = new JReplace();
151:                propertyReplace
152:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
153:                propertyReplace.setToken(AJP_CONNECTOR_TOKEN);
154:                StringBuffer value = new StringBuffer();
155:                value.append(" <!-- Define an AJP 1.3 Connector on port "
156:                        + ajp.getPort() + " -->\n");
157:                value.append("    <Connector port=\"" + ajp.getPort()
158:                        + "\" enableLookups=\"false\"\n");
159:                value
160:                        .append("               redirectPort=\"9043\" protocol=\"AJP/1.3\" />\n\n");
161:                value.append("    " + AJP_CONNECTOR_TOKEN);
162:                propertyReplace.setValue(value.toString());
163:                propertyReplace.setLogInfo(INFO + "Setting AJP Connector to : "
164:                        + ajp.getPort());
165:                addTask(propertyReplace);
166:
167:            }
168:
169:            /**
170:             * Configure a jvmRoute
171:             * @param jvmRoute jvm route name
172:             */
173:            public void addConfiguredJvmRoute(String jvmRoute) {
174:                JReplace propertyReplace = new JReplace();
175:                propertyReplace
176:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
177:                propertyReplace.setToken(JVM_ROUTE_TOKEN);
178:                StringBuffer value = new StringBuffer();
179:                value
180:                        .append("<Engine name=\"jonas\" defaultHost=\"localhost\" jvmRoute=\""
181:                                + jvmRoute + "\">");
182:                propertyReplace.setValue(value.toString());
183:                propertyReplace.setLogInfo(INFO + "Setting the jvmRoute to : "
184:                        + jvmRoute);
185:                addTask(propertyReplace);
186:            }
187:
188:            /**
189:             * Configure a Director Connector.
190:             * @param dir Director Configuration.
191:             */
192:            public void addConfiguredDirector(Director dir) {
193:                JReplace propertyReplace = new JReplace();
194:                propertyReplace
195:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
196:
197:                propertyReplace.setToken(DIRECTOR_CONNECTOR_TOKEN);
198:                StringBuffer value = new StringBuffer();
199:                value.append("<!--  Define a Director Connector on port "
200:                        + dir.getPort() + " -->\n");
201:                value
202:                        .append("    <Connector protocol=\"org.enhydra.servlet.connectionMethods.EnhydraDirector.DirectorProtocol\"\n");
203:                value.append("               port=\"" + dir.getPort() + "\"\n");
204:                value.append("               threadTimeout = \"300\"\n");
205:                value.append("               clientTimeout = \"30\"\n");
206:                value.append("               sessionAffinity = \"false\"\n");
207:                value.append("               queueSize = \"400\"\n");
208:                value.append("               numThreads = \"200\"\n");
209:                value
210:                        .append("               bindAddress = \"(All Interfaces)\"\n");
211:                value
212:                        .append("               authKey = \"(Unauthenticated)\"\n");
213:                value.append("               />\n\n");
214:                value.append("    " + DIRECTOR_CONNECTOR_TOKEN);
215:
216:                propertyReplace.setValue(value.toString());
217:                propertyReplace.setLogInfo(INFO
218:                        + "Setting Director Connector to : " + dir.getPort());
219:                addTask(propertyReplace);
220:
221:            }
222:
223:            /**
224:             * Configure a Cluster HTTP Session.
225:             * @param cluster Cluster HTTP Session.
226:             */
227:            public void addConfiguredCluster(Cluster cluster) {
228:                // General Cluster configuration
229:                setCluster();
230:
231:                // Cluster name
232:                JReplace propertyReplace = new JReplace();
233:                propertyReplace
234:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
235:                propertyReplace.setToken(Cluster.DEFAULT_CLUSTER_NAME);
236:                propertyReplace.setValue(cluster.getName());
237:                propertyReplace.setLogInfo(INFO + "Setting Cluster name : "
238:                        + cluster.getName());
239:                addTask(propertyReplace);
240:
241:                // Cluster listening port
242:                propertyReplace = new JReplace();
243:                propertyReplace
244:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
245:                propertyReplace.setToken(Cluster.DEFAULT_LISTEN_PORT);
246:                propertyReplace.setValue(cluster.getListenPort());
247:                propertyReplace.setLogInfo(INFO
248:                        + "Setting Cluster listen port : "
249:                        + cluster.getListenPort());
250:                addTask(propertyReplace);
251:
252:                // Cluster Multicast Address
253:                propertyReplace = new JReplace();
254:                propertyReplace
255:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
256:                propertyReplace.setToken(Cluster.DEFAULT_MCAST_ADDR);
257:                propertyReplace.setValue(cluster.getMcastAddr());
258:                propertyReplace.setLogInfo(INFO
259:                        + "Setting Cluster multicast addr : "
260:                        + cluster.getMcastAddr());
261:                addTask(propertyReplace);
262:
263:                // Cluster Multicast Port
264:                propertyReplace = new JReplace();
265:                propertyReplace
266:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
267:                propertyReplace.setToken(Cluster.DEFAULT_MCAST_PORT);
268:                propertyReplace.setValue(cluster.getMcastPort());
269:                propertyReplace.setLogInfo(INFO
270:                        + "Setting Cluster multicast port : "
271:                        + cluster.getMcastPort());
272:                addTask(propertyReplace);
273:
274:            }
275:
276:            /**
277:             * Enable the cluster feature.
278:             */
279:            private void setCluster() {
280:                JReplace propertyReplace = new JReplace();
281:                propertyReplace
282:                        .setConfigurationFile(JOnASBaseTask.TOMCAT_CONF_FILE);
283:                propertyReplace.setToken("</Host>");
284:                StringBuffer value = new StringBuffer("\n");
285:                value
286:                        .append("        <Cluster className=\"org.apache.catalina.cluster.tcp.SimpleTcpCluster\"\n");
287:                value.append("            clusterName=\""
288:                        + Cluster.DEFAULT_CLUSTER_NAME + "\"\n");
289:                value
290:                        .append("            managerClassName=\"org.apache.catalina.cluster.session.DeltaManager\"\n");
291:                value
292:                        .append("            expireSessionsOnShutdown=\"false\"\n");
293:                value.append("            useDirtyFlag=\"true\"\n");
294:                value
295:                        .append("            notifyListenersOnReplication=\"true\">\n");
296:                value.append("          <Membership\n");
297:                value
298:                        .append("              className=\"org.apache.catalina.cluster.mcast.McastService\"\n");
299:                value.append("              mcastAddr=\""
300:                        + Cluster.DEFAULT_MCAST_ADDR + "\"\n");
301:                value.append("              mcastPort=\""
302:                        + Cluster.DEFAULT_MCAST_PORT + "\"\n");
303:                value.append("              mcastFrequency=\"500\"\n");
304:                value.append("              mcastDropTime=\"3000\" />\n");
305:                value.append("          <Receiver\n");
306:                value
307:                        .append("              className=\"org.apache.catalina.cluster.tcp.ReplicationListener\"\n");
308:                value.append("              tcpListenAddress=\"auto\"\n");
309:                value.append("              tcpListenPort=\""
310:                        + Cluster.DEFAULT_LISTEN_PORT + "\"\n");
311:                value.append("              tcpSelectorTimeout=\"100\"\n");
312:                value.append("              tcpThreadCount=\"6\" />\n");
313:                value.append("          <Sender\n");
314:                value
315:                        .append("              className=\"org.apache.catalina.cluster.tcp.ReplicationTransmitter\"\n");
316:                value.append("              replicationMode=\"pooled\"\n");
317:                value.append("              ackTimeout=\"15000\" />\n");
318:                value
319:                        .append("          <Valve className=\"org.apache.catalina.cluster.tcp.ReplicationValve\"\n");
320:                value
321:                        .append("                 filter=\".*\\.gif;.*\\.js;.*\\.jpg;.*\\.png;.*\\.htm;.*\\.html;.*\\.css;.*\\.txt;\" />\n");
322:
323:                //              "          <Deployer className=\"org.apache.catalina.cluster.deploy.FarmWarDeployer\"" + "\n" +
324:                //              "                    tempDir=\"/tmp/war-temp/\"" + "\n" +
325:                //              "                    deployDir=\"/tmp/war-deploy/\"" + "\n" +
326:                //              "                    watchDir=\"/tmp/war-listen/\"" + "\n" +
327:                //              "                    watchEnabled=\"false\"/>" +"\n" +
328:                value.append("        </Cluster>\n");
329:                value.append("      </Host>");
330:                propertyReplace.setValue(value.toString());
331:                propertyReplace.setLogInfo(INFO + "Setting Cluster");
332:                addTask(propertyReplace);
333:            }
334:
335:            /**
336:             * @return Returns <code>true</code> if HTTP is configured.
337:             */
338:            public boolean isHttpConfigured() {
339:                return httpConfigured;
340:            }
341:
342:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.