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


Java StaticApplicationContext.refresh方法代碼示例

本文整理匯總了Java中org.springframework.context.support.StaticApplicationContext.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Java StaticApplicationContext.refresh方法的具體用法?Java StaticApplicationContext.refresh怎麽用?Java StaticApplicationContext.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.context.support.StaticApplicationContext的用法示例。


在下文中一共展示了StaticApplicationContext.refresh方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: taskExecutorByBeanType

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Test
public void taskExecutorByBeanType() {
	StaticApplicationContext context = new StaticApplicationContext();

	BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);

	BeanDefinition executorDefinition = new RootBeanDefinition(ThreadPoolTaskExecutor.class);
	executorDefinition.getPropertyValues().add("threadNamePrefix", "testExecutor");
	context.registerBeanDefinition("myExecutor", executorDefinition);

	BeanDefinition targetDefinition =
			new RootBeanDefinition(AsyncAnnotationBeanPostProcessorTests.TestBean.class);
	context.registerBeanDefinition("target", targetDefinition);

	context.refresh();

	ITestBean testBean = context.getBean("target", ITestBean.class);
	testBean.test();
	testBean.await(3000);
	Thread asyncThread = testBean.getThread();
	assertTrue(asyncThread.getName().startsWith("testExecutor"));
	context.close();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:25,代碼來源:AsyncAnnotationBeanPostProcessorTests.java

示例2: listenersInApplicationContextWithNestedChild

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Test
public void listenersInApplicationContextWithNestedChild() {
	StaticApplicationContext context = new StaticApplicationContext();
	RootBeanDefinition nestedChild = new RootBeanDefinition(StaticApplicationContext.class);
	nestedChild.getPropertyValues().add("parent", context);
	nestedChild.setInitMethodName("refresh");
	context.registerBeanDefinition("nestedChild", nestedChild);
	RootBeanDefinition listener1Def = new RootBeanDefinition(MyOrderedListener1.class);
	listener1Def.setDependsOn("nestedChild");
	context.registerBeanDefinition("listener1", listener1Def);
	context.refresh();

	MyOrderedListener1 listener1 = context.getBean("listener1", MyOrderedListener1.class);
	MyEvent event1 = new MyEvent(context);
	context.publishEvent(event1);
	assertTrue(listener1.seenEvents.contains(event1));

	SimpleApplicationEventMulticaster multicaster = context.getBean(
			AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME,
			SimpleApplicationEventMulticaster.class);
	assertFalse(multicaster.getApplicationListeners().isEmpty());

	context.close();
	assertTrue(multicaster.getApplicationListeners().isEmpty());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:26,代碼來源:ApplicationContextEventTests.java

示例3: testAutoProxyCreatorWithFactoryBean

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Test
public void testAutoProxyCreatorWithFactoryBean() {
	StaticApplicationContext sac = new StaticApplicationContext();
	sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
	sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
	sac.refresh();

	TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
	tapc.testInterceptor.nrOfInvocations = 0;

	FactoryBean<?> factory = (FactoryBean<?>) sac.getBean("&singletonFactoryToBeProxied");
	assertTrue(AopUtils.isCglibProxy(factory));

	TestBean tb = (TestBean) sac.getBean("singletonFactoryToBeProxied");
	assertTrue(AopUtils.isCglibProxy(tb));
	assertEquals(2, tapc.testInterceptor.nrOfInvocations);
	tb.getAge();
	assertEquals(3, tapc.testInterceptor.nrOfInvocations);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:20,代碼來源:AutoProxyCreatorTests.java

示例4: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    this.serviceValidateController.setAuthenticationSystemSupport(getAuthenticationSystemSupport());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
    proxyHandler.setHttpClient(new SimpleHttpClientFactoryBean().getObject());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(getArgumentExtractor());
    this.serviceValidateController.setServicesManager(getServicesManager());
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:15,代碼來源:AbstractServiceValidateControllerTests.java

示例5: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    this.proxyController = new ProxyController();
    this.proxyController
    .setCentralAuthenticationService(getCentralAuthenticationService());

    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.proxyController.setApplicationContext(context);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:11,代碼來源:ProxyControllerTests.java

示例6: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
    proxyHandler.setHttpClient(new SimpleHttpClientFactoryBean().getObject());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(new CasArgumentExtractor());
    this.serviceValidateController.setServicesManager(this.servicesManager);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:14,代碼來源:AbstractServiceValidateControllerTests.java

示例7: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    this.serviceValidateController.setAuthenticationSystemSupport(getAuthenticationSystemSupport());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler(new SimpleHttpClientFactoryBean().getObject(), new DefaultUniqueTicketIdGenerator());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(getArgumentExtractor());
    this.serviceValidateController.setServicesManager(getServicesManager());
    this.serviceValidateController.setValidationSpecification(new Cas20WithoutProxyingValidationSpecification());
    this.serviceValidateController.setMultifactorTriggerSelectionStrategy(new DefaultMultifactorTriggerSelectionStrategy("", ""));
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:16,代碼來源:AbstractServiceValidateControllerTests.java

示例8: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    this.proxyController = new ProxyController(getCentralAuthenticationService(), getWebApplicationServiceFactory());
    final StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.proxyController.setApplicationContext(context);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:8,代碼來源:ProxyControllerTests.java

示例9: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    this.proxyController = new ProxyController();
    this.proxyController
    .setCentralAuthenticationService(getCentralAuthenticationService());

    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.proxyController.setApplicationContext(context);
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:11,代碼來源:ProxyControllerTests.java

示例10: onSetUp

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Before
public void onSetUp() throws Exception {
    StaticApplicationContext context = new StaticApplicationContext();
    context.refresh();
    this.serviceValidateController = new ServiceValidateController();
    this.serviceValidateController.setCentralAuthenticationService(getCentralAuthenticationService());
    final Cas20ProxyHandler proxyHandler = new Cas20ProxyHandler();
    proxyHandler.setHttpClient(new SimpleHttpClient());
    this.serviceValidateController.setProxyHandler(proxyHandler);
    this.serviceValidateController.setApplicationContext(context);
    this.serviceValidateController.setArgumentExtractor(new CasArgumentExtractor());
}
 
開發者ID:luotuo,項目名稱:cas4.0.x-server-wechat,代碼行數:13,代碼來源:ServiceValidateControllerTests.java

示例11: getStaticApplicationContext

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
private StaticApplicationContext getStaticApplicationContext()
{
    clientConnectedCount.set(0);
    clientDisconnectedCount.set(0);
    clientLostConnectionCount.set(0);
    clientFailedConnectionCount.set(0);
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.addApplicationListener(this);
    applicationContext.refresh();
    applicationContext.start();
    return applicationContext;
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:13,代碼來源:AutomaticReconnectTest.java

示例12: getStaticApplicationContext

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
private StaticApplicationContext getStaticApplicationContext()
{
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.addApplicationListener(this);
    applicationContext.refresh();
    applicationContext.start();
    return applicationContext;
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:9,代碼來源:ConnectionStatusTest.java

示例13: testCustomAutoProxyCreator

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Test
public void testCustomAutoProxyCreator() {
	StaticApplicationContext sac = new StaticApplicationContext();
	sac.registerSingleton("testAutoProxyCreator", TestAutoProxyCreator.class);
	sac.registerSingleton("noInterfaces", NoInterfaces.class);
	sac.registerSingleton("containerCallbackInterfacesOnly", ContainerCallbackInterfacesOnly.class);
	sac.registerSingleton("singletonNoInterceptor", TestBean.class);
	sac.registerSingleton("singletonToBeProxied", TestBean.class);
	sac.registerPrototype("prototypeToBeProxied", TestBean.class);
	sac.refresh();

	MessageSource messageSource = (MessageSource) sac.getBean("messageSource");
	NoInterfaces noInterfaces = (NoInterfaces) sac.getBean("noInterfaces");
	ContainerCallbackInterfacesOnly containerCallbackInterfacesOnly =
			(ContainerCallbackInterfacesOnly) sac.getBean("containerCallbackInterfacesOnly");
	ITestBean singletonNoInterceptor = (ITestBean) sac.getBean("singletonNoInterceptor");
	ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
	ITestBean prototypeToBeProxied = (ITestBean) sac.getBean("prototypeToBeProxied");
	assertFalse(AopUtils.isCglibProxy(messageSource));
	assertTrue(AopUtils.isCglibProxy(noInterfaces));
	assertTrue(AopUtils.isCglibProxy(containerCallbackInterfacesOnly));
	assertTrue(AopUtils.isCglibProxy(singletonNoInterceptor));
	assertTrue(AopUtils.isCglibProxy(singletonToBeProxied));
	assertTrue(AopUtils.isCglibProxy(prototypeToBeProxied));

	TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
	assertEquals(0, tapc.testInterceptor.nrOfInvocations);
	singletonNoInterceptor.getName();
	assertEquals(0, tapc.testInterceptor.nrOfInvocations);
	singletonToBeProxied.getAge();
	assertEquals(1, tapc.testInterceptor.nrOfInvocations);
	prototypeToBeProxied.getSpouse();
	assertEquals(2, tapc.testInterceptor.nrOfInvocations);
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:35,代碼來源:AutoProxyCreatorTests.java

示例14: testQualifiedByAnnotationValue

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
@Test
public void testQualifiedByAnnotationValue() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
	reader.loadBeanDefinitions(CONFIG_LOCATION);
	context.registerSingleton("testBean", QualifiedByAnnotationValueTestBean.class);
	context.refresh();
	QualifiedByAnnotationValueTestBean testBean = (QualifiedByAnnotationValueTestBean) context.getBean("testBean");
	Person person = testBean.getLarry();
	assertEquals("LarrySpecial", person.getName());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:12,代碼來源:QualifierAnnotationTests.java

示例15: severalFixedRates

import org.springframework.context.support.StaticApplicationContext; //導入方法依賴的package包/類
private void severalFixedRates(StaticApplicationContext context,
		BeanDefinition processorDefinition, BeanDefinition targetDefinition) {

	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(2, fixedRateTasks.size());
	IntervalTask task1 = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable1 = (ScheduledMethodRunnable) task1.getRunnable();
	Object targetObject = runnable1.getTarget();
	Method targetMethod = runnable1.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(0, task1.getInitialDelay());
	assertEquals(4000L, task1.getInterval());
	IntervalTask task2 = fixedRateTasks.get(1);
	ScheduledMethodRunnable runnable2 = (ScheduledMethodRunnable) task2.getRunnable();
	targetObject = runnable2.getTarget();
	targetMethod = runnable2.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(2000L, task2.getInitialDelay());
	assertEquals(4000L, task2.getInterval());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:33,代碼來源:ScheduledAnnotationBeanPostProcessorTests.java


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