1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
package org.eclipse.jst.server.tomcat.core.internal;
/**********************************************************************
* Copyright (c) 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jst.server.j2ee.IWebModule;
/**
*
*/
public class Tomcat50Handler implements ITomcatVersionHandler {
public boolean verifyInstallPath(IPath installPath) {
if (installPath == null)
return false;
String s = installPath.lastSegment();
if (s != null && s.startsWith("jakarta-tomcat-") && !s.startsWith("jakarta-tomcat-5.0"))
return false;
return TomcatPlugin.verifyInstallPath(installPath, TomcatPlugin.TOMCAT_50);
}
/**
* Return the runtime class name.
*
* @return java.lang.String
*/
public String getRuntimeClass() {
return "org.apache.catalina.startup.Bootstrap";
}
public List getRuntimeClasspath(IPath installPath) {
List cp = new ArrayList();
// 5.0 - add bootstrap.jar from the Tomcat bin directory
IPath binPath = installPath.append("bin");
if (binPath.toFile().exists()) {
IPath path = binPath.append("bootstrap.jar");
cp.add(JavaRuntime.newArchiveRuntimeClasspathEntry(path));
}
return cp;
}
/**
* Return the program's runtime arguments.
*
* @return java.lang.String[]
*/
public String[] getRuntimeProgramArguments(IPath configPath, boolean debug, boolean starting) {
List list = new ArrayList();
if (configPath != null) {
list.add("-config");
list.add("\"" + configPath.append("conf").append("server.xml").toOSString() + "\"");
}
if (debug)
list.add("-debug");
if (starting)
list.add("start");
else
list.add("stop");
String[] temp = new String[list.size()];
list.toArray(temp);
return temp;
}
/**
* Return the runtime (VM) arguments.
*
* @return java.lang.String[]
*/
public String[] getRuntimeVMArguments(IPath installPath, IPath configPath, boolean isSecure) {
List list = new ArrayList();
list.add("-Dcatalina.home=\"" + installPath.toOSString() + "\"");
// run in secure mode
if (isSecure) {
IPath dir = configPath.append("conf").append("catalina.policy");
list.add("-Djava.security.manager");
list.add("-Djava.security.policy=\"" + dir.toOSString() + "\"");
}
String[] s = new String[list.size()];
list.toArray(s);
return s;
}
/**
* Returns true if the given project is supported by this
* server, and false otherwise.
*
* @param project org.eclipse.core.resources.IProject
* @return boolean
*/
public IStatus canAddModule(IWebModule module) {
if ("1.2".equals(module.getJ2EESpecificationVersion()) || "1.3".equals(module.getJ2EESpecificationVersion()) || "1.4".equals(module.getJ2EESpecificationVersion()))
return new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%canAddModule"), null);
else
return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorSpec50"), null);
}
}
|