use of com.hevelian.activemq.support.ReversePropertySourcesStandardServletEnvironment in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerImpl method createBroker.
@Override
protected // TODO throw corresponding exceptions, not just Exception instances.
BrokerService createBroker(ServletContext sc) throws Exception {
// Initialize Web environment to make Spring resolve external
// properties.
StandardServletEnvironment standardServletEnvironment = new ReversePropertySourcesStandardServletEnvironment();
WebApplicationContextUtils.initServletPropertySources(standardServletEnvironment.getPropertySources(), sc);
URI configURI = new URI(standardServletEnvironment.getProperty(BROKER_URI_PROP));
LOG.info("Loading message broker from: " + configURI);
return BrokerFactory.createBroker(configURI);
}
use of com.hevelian.activemq.support.ReversePropertySourcesStandardServletEnvironment 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 com.hevelian.activemq.support.ReversePropertySourcesStandardServletEnvironment 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