// Create a new StandardDefaultContext instance
StandardDefaultContext context = new StandardDefaultContext();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
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);