當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericXmlApplicationContext.refresh方法代碼示例

本文整理匯總了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();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:22,代碼來源:AsyncAnnotationBeanPostProcessorTests.java

示例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);
}
 
開發者ID:suewonjp,項目名稱:civilizer,代碼行數:17,代碼來源:WebFileBoxTest.java

示例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");
}
 
開發者ID:1and1,項目名稱:cosmo,代碼行數:18,代碼來源:SpringContextInitializerListener.java

示例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) {
	}
}
 
開發者ID:tlin-fei,項目名稱:ds4p,代碼行數:24,代碼來源:ScheduledTaskRunner.java

示例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);
}
 
開發者ID:tlin-fei,項目名稱:ds4p,代碼行數:18,代碼來源:ApplicationContextAnotherIntegrationTest.java

示例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;

    }
 
開發者ID:iTransformers,項目名稱:netTransformer,代碼行數:27,代碼來源:SpringBasedNetworkDiscovererFactory.java

示例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;

}
 
開發者ID:iTransformers,項目名稱:netTransformer,代碼行數:22,代碼來源:DiscoveryResultTopologyViewerFactory.java

示例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"));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:14,代碼來源:ContextNamespaceHandlerTests.java

示例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));
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:15,代碼來源:EnvironmentSystemIntegrationTests.java

示例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);
}
 
開發者ID:atliwen,項目名稱:EDIOrderPlatform,代碼行數:10,代碼來源:ItemTest.java

示例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);
}
 
開發者ID:atliwen,項目名稱:EDIOrderPlatform,代碼行數:10,代碼來源:UserTest.java

示例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;
}
 
開發者ID:HotwireDotCom,項目名稱:bdd-test-automation-for-mobile,代碼行數:16,代碼來源:ContextConfigurationTest.java

示例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;
}
 
開發者ID:subes,項目名稱:invesdwin-instrument,代碼行數:11,代碼來源:DynamicInstrumentationLoader.java


注:本文中的org.springframework.context.support.GenericXmlApplicationContext.refresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。