if (container instanceof Engine) {
Service service = ((Engine)container).getService();
name = new ObjectName(domain + ":type=Loader,service=" +
service.getName());
} else if (container instanceof Host) {
Engine engine = (Engine) container.getParent();
Service service = engine.getService();
name = new ObjectName(domain + ":type=Loader,host=" +
container.getName() + ",service=" +
service.getName());
} else if (container instanceof Context) {
String path = ((Context)container).getPath();
if (path.length() < 1) {
path = "/";
}
Host host = (Host) container.getParent();
Engine engine = (Engine) host.getParent();
Service service = engine.getService();
name = new ObjectName(domain + ":type=Loader,path=" + path +
",host=" + host.getName() + ",service=" +
service.getName());
} else if (container == null) {
DefaultContext defaultContext = loader.getDefaultContext();
if (defaultContext != null) {
Container parent = defaultContext.getParent();
if (parent instanceof Engine) {
Service service = ((Engine)parent).getService();
name = new ObjectName(domain + ":type=DefaultLoader,service=" +
service.getName());
} else if (parent instanceof Host) {
Engine engine = (Engine) parent.getParent();
Service service = engine.getService();
name = new ObjectName(domain + ":type=DefaultLoader,host=" +
parent.getName() + ",service=" + service.getName());
}
}
}