use of org.apache.xbean.spring.context.ResourceXmlApplicationContext in project hevelian-activemq by Hevelian.
the class WebXBeanBrokerFactory method createApplicationContext.
@Override
protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
Resource resource = Utils.resourceFromString(uri);
LOG.debug("Using " + resource + " from " + uri);
try {
return new ResourceXmlApplicationContext(resource) {
@Override
protected ConfigurableEnvironment createEnvironment() {
return new ReversePropertySourcesStandardServletEnvironment();
}
@Override
protected void initPropertySources() {
WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(), ServletContextHolder.getServletContext());
}
};
} catch (FatalBeanException errorToLog) {
LOG.error("Failed to load: " + resource + ", reason: " + errorToLog.getLocalizedMessage(), errorToLog);
throw errorToLog;
}
}
use of org.apache.xbean.spring.context.ResourceXmlApplicationContext in project hevelian-activemq by Hevelian.
the class WebXBeanBrokerFactoryTest method createApplicationContext_envInstanceOfReversePropertySourcesStandardServletEnvironment.
@Test
public void createApplicationContext_envInstanceOfReversePropertySourcesStandardServletEnvironment() throws MalformedURLException {
ServletContextHolder.setServletContext(Mockito.mock(ServletContext.class));
ApplicationContext c = new WebXBeanBrokerFactory().createApplicationContext("classpath:activemq.xml");
assertTrue(c instanceof ResourceXmlApplicationContext);
try (ResourceXmlApplicationContext rc = (ResourceXmlApplicationContext) c) {
assertTrue(rc.getEnvironment() instanceof ReversePropertySourcesStandardServletEnvironment);
}
}
Aggregations