/** * {@inheritDoc} * <p>Replace {@code Servlet}-related property sources. */ @Override protected void initPropertySources() { ConfigurableEnvironment env = getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, this.servletConfig); } }
/** * {@inheritDoc} * <p>Replace {@code Servlet}-related property sources. */ @Override protected void initPropertySources() { ConfigurableEnvironment env = getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, this.servletConfig); } }
String[] activeProfiles = context.getEnvironment().getActiveProfiles(); HashSet<String> envProfiles = new HashSet<>(Arrays.asList(activeProfiles)); envProfiles.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(profiles))); envProfiles.add("strict"); context.getEnvironment().setActiveProfiles(envProfiles.toArray(new String[0])); } else { context.getEnvironment().setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profiles)); context.getEnvironment().setActiveProfiles(StringUtils.commaDelimitedListToStringArray(profiles));
ctx.refresh(); ConfigurableEnvironment environment = ctx.getEnvironment(); assertThat(environment, instanceOf(StandardServletEnvironment.class)); MutablePropertySources propertySources = environment.getPropertySources();
/** * {@inheritDoc} * <p>Replace {@code Servlet}-related property sources. */ @Override protected void initPropertySources() { ConfigurableEnvironment env = getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, this.servletConfig); } }
/** * {@inheritDoc} * <p>Replace {@code Servlet}-related property sources. */ @Override protected void initPropertySources() { ConfigurableEnvironment env = getEnvironment(); if (env instanceof ConfigurableWebEnvironment) { ((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, this.servletConfig); } }
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; }