synchronized (connection.getConnector()) {
Container container=connection.getConnector().getContainer();
// the hostName should be in lowewr case (setName makes a toLowerCase).
Host host=(Host)container.findChild(hostName.toLowerCase());
if (host==null) {
WarpHost whost=new WarpHost();
whost.setName(hostName);
whost.setParent(container);
whost.setAppBase(connection.getConnector().getAppBase());
whost.setDebug(connection.getConnector().getDebug());
container.addChild(whost);
host=whost;
if (Constants.DEBUG)
logger.debug("Created new host "+host.getName());
} else if (Constants.DEBUG) {
logger.debug("Reusing instance of Host \""+host.getName()+"\"");
}
// TODO: Set up mapping mechanism for performance
if (applPath.endsWith("/"))
applPath=applPath.substring(0,applPath.length()-1);
Context appl=(Context)host.findChild(applPath);
if (appl==null) {
if (Constants.DEBUG)
logger.debug("No application for \""+applPath+"\"");
Deployer deployer=(Deployer)host;
File file=new File(applName);
if (!file.isAbsolute()) {
file=new File(host.getAppBase()+File.separator+applName);
if (!file.isAbsolute()) {
file=new File(System.getProperty("catalina.base"),
host.getAppBase()+File.separator+applName);
}
}
if (!file.exists()) {
logger.log("Cannot find \""+file.getPath()+"\" for appl. \""+
applName+"\" host \""+host.getName()+"\"");
return(null);
}
String path=file.getCanonicalPath();
URL url=new URL("file",null,path);