String path = oname.getKeyProperty("path");
Server server = ServerFactory.getServer();
Service service = server.findService(serviceName);
StandardEngine engine = (StandardEngine) service.getContainer();
if (hostName == null) { // if realm's container is Engine
Realm realm = engine.getRealm();
Container container = realm.getContainer();
if (container instanceof StandardEngine) {
String sname =
((StandardEngine)container).getService().getName();
if (sname.equals(serviceName)) {
engine.setRealm(null);
}
}
} else if (path == null) { // if realm's container is Host
StandardHost host = (StandardHost) engine.findChild(hostName);
Realm realm = host.getRealm();
Container container = realm.getContainer();
if (container instanceof StandardHost) {
String hn = ((StandardHost)container).getName();
StandardEngine se =
(StandardEngine) ((StandardHost)container).getParent();
String sname = se.getService().getName();
if (sname.equals(serviceName) && hn.equals(hostName)) {
host.setRealm(null);
}
}
} else { // realm's container is Context
StandardHost host = (StandardHost) engine.findChild(hostName);
path = getPathStr(path);
StandardContext context = (StandardContext) host.findChild(path);
Realm realm = context.getRealm();
Container container = realm.getContainer();
if (container instanceof StandardContext) {
String pathName = ((StandardContext)container).getName();
StandardHost sh =
(StandardHost)((StandardContext)container).getParent();
String hn = sh.getName();;