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
|
public void initialize(IFMessage init) throws IFException {
config = init;
if (init.containsKey("Host")) {
hostname = init.getString("Host");
}
System.setProperty("catalina.host", hostname);
if (init.containsKey("Port")) {
port = init.getInt("Port");
}
System.setProperty("catalina.port", "" + port);
if (init.containsKey("SSLPort")) {
SSLport = init.getInt("SSLPort");
System.setProperty("catalina.sslport", "" + SSLport);
}
if (init.containsKey("keypass")) {
keypass = init.getString("keypass");
}
if (init.containsKey("keystore")) {
keystore = init.getString("keystore");
}
if (init.containsKey("Webapps")) {
webapps = init.getString("Webapps");
}
// set the home of tomcat
String projectHome = IF.getIFProject();
File home = new File(projectHome, "etc/Tomcat");
trace.println(3, "catalina.home: ", home);
System.setProperty("catalina.home", home.getAbsolutePath());
// instanciate tomcat
tomcat = new org.apache.catalina.startup.Tomcat();
tomcat.setPort(port);
tomcat.setHostname(hostname);
tomcat.setBaseDir(home.getAbsolutePath());
host = tomcat.getHost();
Engine engine = tomcat.getEngine();
engine.setDefaultHost(hostname);
engine.setName(IF.getRole() + "-Tomcat");
// create a default virtual host
webDir = new File(webapps); // Try this dir first
if (!webDir.isDirectory()) {
webDir = new File(projectHome, webapps); // Try relative dir
}
// create the ROOT context
File root = new File(webDir, "ROOT");
if (init.containsKey("RootContext")) {
String r = init.getString("RootContext");
root = new File(webDir, r);
}
Context rootContext;
try {
rootContext = tomcat.addWebapp("", root.getAbsolutePath());
} catch (Throwable error) {
trace.println(-1, "Unable to add ROOT context:", error);
}
// create the Project context
File project = new File(IF.getIFProject());
Context projectContext;
try {
projectContext = tomcat.addWebapp("/IFProject", project.getAbsolutePath());
//projectContext.getResources().setAllowLinking(true);
System.out.println("**********************************************IFProject context: "+ projectContext.toString());
} catch (Exception error) {
System.out.println("**********************************************");
error.printStackTrace();
System.out.println("**********************************************");
}
} |
Partager