本文整理汇总了Java中org.apache.xbean.spring.context.ResourceXmlApplicationContext类的典型用法代码示例。如果您正苦于以下问题:Java ResourceXmlApplicationContext类的具体用法?Java ResourceXmlApplicationContext怎么用?Java ResourceXmlApplicationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceXmlApplicationContext类属于org.apache.xbean.spring.context包,在下文中一共展示了ResourceXmlApplicationContext类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createApplicationContext
import org.apache.xbean.spring.context.ResourceXmlApplicationContext; //导入依赖的package包/类
@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;
}
}
示例2: getContext
import org.apache.xbean.spring.context.ResourceXmlApplicationContext; //导入依赖的package包/类
public ApplicationContext getContext(InputStream is, WorkflowModelImpl model) {
InputStreamResource isr = new InputStreamResource(is);
try {
ResourceXmlApplicationContext ctx = new ResourceXmlApplicationContext(isr, getPreprocessors(),
parentContext, Collections.emptyList(), false);// {
ctx.setValidating(false);
ctx.refresh();
return ctx;
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例3: createApplicationContext_envInstanceOfReversePropertySourcesStandardServletEnvironment
import org.apache.xbean.spring.context.ResourceXmlApplicationContext; //导入依赖的package包/类
@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);
}
}
示例4: createApplicationContext
import org.apache.xbean.spring.context.ResourceXmlApplicationContext; //导入依赖的package包/类
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 void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
reader.setValidating(isValidate());
}
};
} catch (FatalBeanException errorToLog) {
LOG.error("Failed to load: " + resource + ", reason: " + errorToLog.getLocalizedMessage(), errorToLog);
throw errorToLog;
}
}
示例5: afterPropertiesSet
import org.apache.xbean.spring.context.ResourceXmlApplicationContext; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
if (config == null) {
throw new IllegalArgumentException("config property must be set");
}
context = new ResourceXmlApplicationContext(config, parentContext);
try {
broker = (XBeanBrokerService)context.getBean("broker");
} catch (BeansException e) {
// ignore...
// log.trace("No bean named broker available: " + e, e);
}
if (broker == null) {
// lets try find by type
String[] names = context.getBeanNamesForType(BrokerService.class);
for (int i = 0; i < names.length; i++) {
String name = names[i];
broker = (XBeanBrokerService)context.getBean(name);
if (broker != null) {
break;
}
}
}
if (broker == null) {
throw new IllegalArgumentException("The configuration has no BrokerService instance for resource: " + config);
}
if( systemExitOnShutdown ) {
broker.addShutdownHook(new Runnable(){
public void run() {
System.exit(systemExitOnShutdownExitCode);
}
});
}
if (start) {
broker.start();
}
}