List of usage examples for org.springframework.web.context WebApplicationContext getEnvironment
Environment getEnvironment();
From source file:com.github.nblair.web.ProfileConditionalDelegatingFilterProxyTest.java
/** * Set up a {@link ServletContext} to contain a {@link WebApplicationContext} with the provided {@link Environment}. * /*from w ww .java 2 s.c o m*/ * @param environment * @return a mock {@link ServletContext} ready for use in the delegate filter proxy */ protected ServletContext mockServletContextWithEnvironment(Environment environment) { ServletContext servletContext = mock(ServletContext.class); WebApplicationContext wac = mock(WebApplicationContext.class); when(wac.getEnvironment()).thenReturn(environment); when(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)) .thenReturn(wac); return servletContext; }
From source file:com.freebox.engeneering.application.web.common.ApplicationContextListener.java
/** * Reads config locations from initParameter. * @param context the web application context. * @param initParameter the init parameter. * @return the array of config locations. *///from www . ja v a 2 s . c om private String[] getConfigLocations(WebApplicationContext context, String initParameter) { String[] configLocations = null; if (initParameter != null) { final String[] locations = StringUtils.tokenizeToStringArray(initParameter, CONFIG_LOCATION_DELIMITERS); if (locations != null) { Assert.noNullElements(locations, "Config locations must not be null"); configLocations = new String[locations.length]; for (int i = 0; i < locations.length; i++) { configLocations[i] = context.getEnvironment().resolveRequiredPlaceholders(locations[i]).trim(); } } } return configLocations != null ? configLocations : getDefaultConfigLocations(); }