本文整理匯總了Java中org.springframework.context.support.GenericXmlApplicationContext.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericXmlApplicationContext.refresh方法的具體用法?Java GenericXmlApplicationContext.refresh怎麽用?Java GenericXmlApplicationContext.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.GenericXmlApplicationContext
的用法示例。
在下文中一共展示了GenericXmlApplicationContext.refresh方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configuredThroughNamespace
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void configuredThroughNamespace() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load(new ClassPathResource("taskNamespaceTests.xml", getClass()));
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor"));
TestableAsyncUncaughtExceptionHandler exceptionHandler =
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertFalse("handler should not have been called yet", exceptionHandler.isCalled());
testBean.failWithVoid();
exceptionHandler.await(3000);
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
context.close();
}
示例2: renewTestData
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
private static void renewTestData() {
ctx = new GenericXmlApplicationContext();
ctx.load("classpath:datasource-context-h2-embedded.xml");
ctx.refresh();
fileEntityDao = ctx.getBean("fileEntityDao", FileEntityDao.class);
assertNotNull(fileEntityDao);
try {
FileUtils.deleteDirectory(new File(filesHomePath));
} catch (IOException e) {
e.printStackTrace();
}
TestUtil.touchTestFilesForFileBox(fileEntityDao);
}
示例3: enhanceExistingSpringWebApplicationContext
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
private void enhanceExistingSpringWebApplicationContext(ServletContextEvent sce, WebApplicationContext wac) {
LOGGER.info("Enhancing existing Spring application context...");
String cosmoContextLocation = sce.getServletContext().getInitParameter(CONTEXT_PARAM_NAME);
@SuppressWarnings("resource")
GenericXmlApplicationContext cosmoAppCtxt = new GenericXmlApplicationContext();
cosmoAppCtxt.setEnvironment((ConfigurableEnvironment) wac.getEnvironment());
cosmoAppCtxt.load(cosmoContextLocation);
cosmoAppCtxt.refresh();
cosmoAppCtxt.start();
//make beans that are required from web components (as delegating filter proxy) accesible
((AbstractRefreshableWebApplicationContext)wac).getBeanFactory().setParentBeanFactory(cosmoAppCtxt.getBeanFactory());
LOGGER.info("Enhanced existing Spring application context started");
}
示例4: main
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
/**
* The main method.
*
* @param args
* the arguments
* @throws Exception
* the exception
*/
public static void main(String[] args) throws Exception {
logger.info("Starting at {}...", new Date().toString());
try {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load("classpath:/META-INF/spring/applicationContext*.xml");
context.refresh();
} catch (Exception e) {
logger.error("Error occurred:", e);
throw e;
}
while (true) {
}
}
示例5: bootstrapAppFromXml
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void bootstrapAppFromXml() {
// Here cannot use WEB-INF/spring/root-context.xml
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load("classpath:META-INF/spring/applicationContext*.xml");
context.refresh();
assertThat(context, is(notNullValue()));
// EchoSignPollingService
EsignaturePollingService esignaturePollingService = (EsignaturePollingService)(context.getBean("esignaturePollingService"));
assertNotNull(esignaturePollingService);
// EchoSignPollingService
//EchoSignPollingService echoSignPollingService = (EchoSignPollingService)(context.getBean("esignaturePollingService"));
//assertNotNull(echoSignPollingService);
}
示例6: createNetworkDiscoverer
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
private NetworkDiscoverer createNetworkDiscoverer(String projectPath, String version, int initialNumberOfThreads, int maxNumberOfThreads) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:netDiscoverer/netDiscoverer.xml");
ctx.load("classpath:csvConnectionDetails/csvConnectionDetailsFactory.xml");
AbstractBeanDefinition projectPathBeanDefinition = BeanDefinitionBuilder.rootBeanDefinition(String.class)
.addConstructorArgValue(projectPath).getBeanDefinition();
BeanDefinition labelDirNameBeanDefinition = BeanDefinitionBuilder.
rootBeanDefinition(String.class)
.addConstructorArgValue(version).getBeanDefinition();
BeanDefinition versionBeanDefinition = BeanDefinitionBuilder.
rootBeanDefinition(String.class)
.addConstructorArgValue(version).getBeanDefinition();
ctx.registerBeanDefinition("projectPath", projectPathBeanDefinition);
ctx.registerBeanDefinition("labelDirName", labelDirNameBeanDefinition);
ctx.registerBeanDefinition("version", versionBeanDefinition);
ctx.refresh();
NetworkDiscoverer discoverer = ctx.getBean("parallelSnmpDiscovery", NetworkDiscoverer.class);
return discoverer;
}
示例7: createTopologyViewer
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
private TopologyViewer createTopologyViewer(String projectPath, String projectType) {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load("classpath:discoveryResultTopologyViewer/discoveryResultTopologyViewer.xml");
ctx.load("classpath:xmlTopologyViewerConfig/xmlTopologyViewerConfig.xml");
ctx.load("classpath:xmlNodeDataProvider/xmlNodeDataProvider.xml");
AbstractBeanDefinition projectPathBeanDefinition = BeanDefinitionBuilder.rootBeanDefinition(String.class)
.addConstructorArgValue(projectPath).getBeanDefinition();
AbstractBeanDefinition projectTypeBeanDefinition = BeanDefinitionBuilder.rootBeanDefinition(String.class)
.addConstructorArgValue(projectType).getBeanDefinition();
ctx.registerBeanDefinition("projectPath", projectPathBeanDefinition);
ctx.registerBeanDefinition("projectType", projectTypeBeanDefinition);
ctx.refresh();
TopologyViewer topologyViewer = ctx.getBean("discoveryResultTopologyViewer", TopologyViewer.class);
return topologyViewer;
}
示例8: GenericXmlApplicationContext
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void resourceIdResolverResolveToPhysicalResourceId_logicalResourceIdOfNonExistingResourceProvided_returnsLogicalResourceIdAsPhysicalResourceId() {
// Arrange
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);
when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("IntegrationTestStack"))).
thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary()));
applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-staticStackName.xml", getClass()));
applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);
applicationContext.refresh();
ResourceIdResolver resourceIdResolver = applicationContext.getBean(ResourceIdResolver.class);
// Act
String physicalResourceId = resourceIdResolver.resolveToPhysicalResourceId("nonExistingLogicalResourceId");
// Assert
assertThat(physicalResourceId, is("nonExistingLogicalResourceId"));
}
開發者ID:spring-cloud,項目名稱:spring-cloud-aws,代碼行數:22,代碼來源:StackConfigurationBeanDefinitionParserTest.java
示例9: resourceIdResolver_stackConfiguration_resourceIdResolverBeanExposed
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void resourceIdResolver_stackConfiguration_resourceIdResolverBeanExposed() {
// Arrange
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
AmazonCloudFormation amazonCloudFormation = Mockito.mock(AmazonCloudFormation.class);
when(amazonCloudFormation.listStackResources(new ListStackResourcesRequest().withStackName("IntegrationTestStack"))).
thenReturn(new ListStackResourcesResult().withStackResourceSummaries(new StackResourceSummary()));
applicationContext.load(new ClassPathResource(getClass().getSimpleName() + "-staticStackName.xml", getClass()));
applicationContext.getBeanFactory().registerSingleton(getBeanName(AmazonCloudFormation.class.getName()), amazonCloudFormation);
applicationContext.refresh();
// Act
ResourceIdResolver resourceIdResolver = applicationContext.getBean(ResourceIdResolver.class);
// Assert
assertThat(resourceIdResolver, is(not(nullValue())));
}
開發者ID:spring-cloud,項目名稱:spring-cloud-aws,代碼行數:21,代碼來源:StackConfigurationBeanDefinitionParserTest.java
示例10: propertyPlaceholderEnvironmentProperties
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void propertyPlaceholderEnvironmentProperties() throws Exception {
MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
applicationContext.setEnvironment(env);
applicationContext.load(new ClassPathResource("contextNamespaceHandlerTests-simple.xml", getClass()));
applicationContext.refresh();
Map<String, PlaceholderConfigurerSupport> beans = applicationContext
.getBeansOfType(PlaceholderConfigurerSupport.class);
assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
assertEquals("spam", applicationContext.getBean("string"));
assertEquals("none", applicationContext.getBean("fallback"));
}
示例11: genericXmlApplicationContext
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Test
public void genericXmlApplicationContext() {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.load(XML_PATH);
ctx.refresh();
assertHasEnvironment(ctx, prodEnv);
assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, prodEnv);
assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
示例12: setUp
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.setValidating(false);
context.load("classpath:spring/applicationContext*.xml");
context.refresh();
edi = context.getBean(ItemService.class);
}
示例13: setUp
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception
{
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.setValidating(false);
context.load("classpath:spring/applicationContext*.xml");
context.refresh();
edi = context.getBean(EdiUserService.class);
}
示例14: createContext
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
private GenericXmlApplicationContext createContext(String profile, String springProfile) {
System.setProperty("mobileOS", profile);
System.setProperty("app_dir", "");
System.setProperty("app_name", "");
System.setProperty("device_name", "");
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.getEnvironment().setActiveProfiles(springProfile);
context.load("classpath*:cucumber/runtime/java/spring/cucumber-glue.xml");
context.load("classpath:cucumber.xml");
context.registerBeanDefinition("appiumDriverFactory",
BeanDefinitionBuilder.genericBeanDefinition(NullAppiumDriverFactory.class).getBeanDefinition());
context.refresh();
context.start();
return context;
}
示例15: initLoadTimeWeavingContext
import org.springframework.context.support.GenericXmlApplicationContext; //導入方法依賴的package包/類
public static synchronized GenericXmlApplicationContext initLoadTimeWeavingContext() {
org.assertj.core.api.Assertions.assertThat(isInitialized()).isTrue();
if (ltwCtx == null) {
final GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
ctx.load(new ClassPathResource("/META-INF/ctx.spring.weaving.xml"));
ctx.refresh();
ltwCtx = ctx;
}
return ltwCtx;
}