@Before public void setUp() throws Exception { MockServletContext sc = new MockServletContext(""); wac = new XmlWebApplicationContext(); wac.setServletContext(sc); wac.setConfigLocations(new String[] {CONF}); wac.refresh(); }
@Before public void setUp() throws Exception { MockServletContext sc = new MockServletContext(""); wac = new XmlWebApplicationContext(); wac.setServletContext(sc); wac.setConfigLocations(new String[] {CONF}); wac.refresh(); hm = (HandlerMapping) wac.getBean("urlMapping"); }
MockServletContext sc = new MockServletContext(""); root.setServletContext(sc); root.setConfigLocations(new String[] {"/org/springframework/web/context/WEB-INF/applicationContext.xml"}); root.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { @Override
@Override protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) { super.customizeContext(servletContext, applicationContext); String[] newLocations = cloudStackContext.getConfigLocationsForWeb(configuredParentName, applicationContext.getConfigLocations()); applicationContext.setConfigLocations(newLocations); }
@Override public synchronized void setConfigLocations(String[] locations) { this.appContext.setConfigLocations(locations); }
@Override protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext){ super.customizeContext(servletContext, applicationContext); String[] oldLocations = applicationContext.getConfigLocations(); String[] newLocations; if(conditionIsTrue){ newLocations = new String[oldLocations.length+1]; for (int i = 0; i < oldLocations.length; i++) { newLocations[i] = oldLocations[i]; } newLocations[oldLocations.length] ="classpath:securityContext.xml"; }else{ newLocations = new String[oldLocations.length]; newLocations = Arrays.copyOf(oldLocations, oldLocations.length); } applicationContext.setConfigLocations(newLocations); }
@Override protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) { String[] locations = applicationContext.getConfigLocations(); locations = ObjectArrays.concat(locations, AppContext.RES_PATH); applicationContext.setConfigLocations(locations); } };
String configLocation = servletContext.getInitParameter(SESSION_CONFIG_LOCATION_PARAM); if (configLocation != null) { sessionContext.setConfigLocations(StringUtils.tokenizeToStringArray(configLocation, ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS)); } else { sessionContext.setConfigLocations(DEFAULT_SESSION_CONFIG);
/** * Allows loading/override of custom bean definitions from sakai.home * * <p>The pattern is the 'servlet_name-context.xml'</p> * * @param sc current servlet context * @param wac the new WebApplicationContext */ @Override protected void customizeContext(ServletContext sc, ConfigurableWebApplicationContext wac) { super.customizeContext(sc, wac); if (wac != null) { final String servletName = sc.getServletContextName(); String location = getHomeBeanDefinitionIfExists(servletName); if (StringUtils.isNotBlank(location)) { String[] configLocations = wac.getConfigLocations(); String[] newLocations = Arrays.copyOf(configLocations, configLocations.length + 1); newLocations[configLocations.length] = "file:" + location; wac.setConfigLocations(newLocations); log.info("Servlet {} added an additional bean config location [{}]", servletName, location); } } }
/** * Instantiate the root WebApplicationContext for this loader, either the * default context class or a custom context class if specified. * <p>This implementation expects custom contexts to implement * ConfigurableWebApplicationContext. Can be overridden in subclasses. * @param servletContext current servlet context * @param parent the parent ApplicationContext to use, or <code>null</code> if none * @return the root WebApplicationContext * @throws BeansException if the context couldn't be initialized * @see ConfigurableWebApplicationContext */ protected WebApplicationContext createWebApplicationContext( ServletContext servletContext, ApplicationContext parent) throws BeansException { Class contextClass = determineContextClass(servletContext); if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Custom context class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext"); } ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); wac.setParent(parent); wac.setServletContext(servletContext); String configLocation = servletContext.getInitParameter(CONFIG_LOCATION_PARAM); if (configLocation != null) { wac.setConfigLocations(StringUtils.tokenizeToStringArray(configLocation, ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS)); } wac.refresh(); return wac; }
appctx.setConfigLocations(new String[] { contextConfigLocation }); appctx.setServletContext(servletContext);
wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations( StringUtils.tokenizeToStringArray( getContextConfigLocation(), ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));
wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations( StringUtils.tokenizeToStringArray( getContextConfigLocation(), ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));
wac.setNamespace(getNamespace()); if (getContextConfigLocation() != null) { wac.setConfigLocations( StringUtils.tokenizeToStringArray( getContextConfigLocation(), ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));