if(contained instanceof StandardHost){
HostConfig config = new HostConfig();
contained.addLifecycleListener(config);
} else if(contained instanceof StandardContext){
ContextConfig config = new ContextConfig();
contained.addLifecycleListener(config);
}
} catch (InstantiationException e) {
throw new MBeanException(e);
} catch (IllegalAccessException e) {