*/
public String createDefaultContext(String parent)
throws Exception {
// Create a new StandardDefaultContext instance
StandardDefaultContext context = new StandardDefaultContext();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
String type = pname.getKeyProperty("type");
Server server = ServerFactory.getServer();
String serviceName = pname.getKeyProperty("service");
if (serviceName == null) {
serviceName = pname.getKeyProperty("name");
}
Service service = server.findService(serviceName);
Engine engine = (Engine) service.getContainer();
String hostName = pname.getKeyProperty("host");
if (hostName == null) { //if DefaultContext is nested in Engine
context.setParent(engine);
engine.addDefaultContext(context);
} else { // if DefaultContext is nested in Host
Host host = (Host) engine.findChild(hostName);
context.setParent(host);
host.addDefaultContext(context);
}
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("DefaultContext");