code: protected GenericApplicationContext createApplicationContext(ApplicationContext parentCtx) {
          if (parentCtx != null && beanFactory != null) {
              Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory,
                      "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory");
  
              return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory,parentCtx);
          }
  
          if (beanFactory != null) {
              Assert.isInstanceOf(DefaultListableBeanFactory.class, beanFactory,
                      "ListableBeanFactory set must be a subclass of DefaultListableBeanFactory");
  
              return new GrailsApplicationContext((DefaultListableBeanFactory) beanFactory);
          }
  
          if (parentCtx != null) {
              return new GrailsApplicationContext(parentCtx);
          }
  
          return new GrailsApplicationContext();
      }
docs: Creates the ApplicationContext instance. Subclasses can override to customise the used ApplicationContext
  
  @param parentCtx The parent ApplicationContext instance. Can be null.
  
  @return An instance of GenericApplicationContext