code: public static synchronized AbstractApplicationContext getContext(Class<?> springConfigurationClass) {
          if (!CONTEXTS.containsKey(springConfigurationClass)) {
              AbstractApplicationContext context = new AnnotationConfigApplicationContext(springConfigurationClass);
              context.registerShutdownHook();
              CONTEXTS.put(springConfigurationClass, context);
          }
  
          return CONTEXTS.get(springConfigurationClass);
      }
docs: Get application context for configuration class.