static ConfigurableApplicationContext createParentContext(
     Object[] sources,
     String[] args,
     final boolean selfContained,
     boolean webEnvironment,
     boolean headless) {
   SpringApplicationBuilder aggregatorParentConfiguration = new SpringApplicationBuilder();
   aggregatorParentConfiguration
       .sources(sources)
       .web(webEnvironment)
       .headless(headless)
       .properties(
           "spring.jmx.default-domain="
               + AggregateApplicationBuilder.ParentConfiguration.class.getName(),
           SELF_CONTAINED_APP_PROPERTY_NAME + "=" + selfContained);
   return aggregatorParentConfiguration.run(args);
 }
 protected WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
   ApplicationContext parent = null;
   Object object =
       servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
   if (object instanceof ApplicationContext) {
     this.logger.info("Root context already created (using as parent).");
     parent = (ApplicationContext) object;
     servletContext.setAttribute(
         WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
   }
   SpringApplicationBuilder application =
       new SpringApplicationBuilder().sources(getConfigClasses());
   application.initializers(
       new ParentContextApplicationContextInitializer(parent),
       new ServletContextApplicationContextInitializer(servletContext));
   application.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);
   return (WebApplicationContext) application.run();
 }