@Override public void setServletConfig(@Nullable ServletConfig servletConfig) { this.servletConfig = servletConfig; if (servletConfig != null && this.servletContext == null) { setServletContext(servletConfig.getServletContext()); } }
@Override public void setServletConfig(@Nullable ServletConfig servletConfig) { this.servletConfig = servletConfig; if (servletConfig != null && this.servletContext == null) { setServletContext(servletConfig.getServletContext()); } }
context.setServletContext(servletContext); MockServletConfig servletConfig = new MockServletConfig(servletContext); servletConfig.addInitParameter("environmentConfigLocations", StringUtils.arrayToCommaDelimitedString(yamlFiles));
@Override public void setServletConfig(@Nullable ServletConfig servletConfig) { this.servletConfig = servletConfig; if (servletConfig != null && this.servletContext == null) { setServletContext(servletConfig.getServletContext()); } }
@Override public void setServletConfig(@Nullable ServletConfig servletConfig) { this.servletConfig = servletConfig; if (servletConfig != null && this.servletContext == null) { setServletContext(servletConfig.getServletContext()); } }
protected WebApplicationContext createWebApplicationContext(ServletContext servletContext) { Class<?>[] configClasses = getSpringConfigClasses(servletContext); String configLocation = getSpringConfigLocation(servletContext); // We can only use one or the other... AbstractRefreshableWebApplicationContext appContext; if (StringUtils.isNotBlank(configLocation) && configClasses != null) { String msg = String.format("Only XML or Annotation configuration can be used but not both."); throw new IllegalArgumentException(msg); } else if (configClasses != null) { appContext = new AnnotationConfigWebApplicationContext(); ((AnnotationConfigWebApplicationContext)appContext).register(configClasses); } else if (StringUtils.isNotBlank(configLocation)) { appContext = new XmlWebApplicationContext(); appContext.setConfigLocation(configLocation); } else { String msg = String.format("Either an XML or Annotation configuration can be specified."); throw new IllegalArgumentException(msg); } String[] profiles = getSpringProfiles(servletContext, appContext); if (profiles != null && profiles.length > 0) { appContext.getEnvironment().setActiveProfiles(profiles); } // Refresh the spring context -- important, Jersey 2.x // Spring integration will not work with out it. appContext.setServletContext(servletContext); appContext.refresh(); return appContext; }