code: public static ApplicationContext findApplicationContext(ServletContext servletContext) {
          if(servletContext == null) {
              return ContextLoader.getCurrentWebApplicationContext();
          }
          return WebApplicationContextUtils.getWebApplicationContext(servletContext);
      }
docs: Locates the ApplicationContext, returns null if not found
  @param servletContext The servlet context
  @return The ApplicationContext