当前位置: 首页>>代码示例>>Java>>正文


Java StaticListableBeanFactory类代码示例

本文整理汇总了Java中org.springframework.beans.factory.support.StaticListableBeanFactory的典型用法代码示例。如果您正苦于以下问题:Java StaticListableBeanFactory类的具体用法?Java StaticListableBeanFactory怎么用?Java StaticListableBeanFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StaticListableBeanFactory类属于org.springframework.beans.factory.support包,在下文中一共展示了StaticListableBeanFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGRL

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void initGRL() throws Exception {
    GlobalResourceLoader.stop();
    SimpleConfig config = new SimpleConfig();
    config.putProperty(CoreConstants.Config.APPLICATION_ID, "APPID");
    ConfigContext.init(config);

    StaticListableBeanFactory testBf = new StaticListableBeanFactory();
    when(kualiModuleService.getInstalledModuleServices()).thenReturn(installedModuleServices);

    testBf.addBean(KRADServiceLocator.PROVIDER_REGISTRY, mock(ProviderRegistry.class));
    testBf.addBean(KRADServiceLocatorWeb.KUALI_MODULE_SERVICE, kualiModuleService);

    ResourceLoader rl = new BeanFactoryResourceLoader(new QName("moduleservicebase-unittest"), testBf);
    GlobalResourceLoader.addResourceLoader(rl);
    GlobalResourceLoader.start();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:ModuleServiceBaseTest.java

示例2: installRiceKualiModuleService

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void installRiceKualiModuleService() throws Exception {
    GlobalResourceLoader.stop();
    SimpleConfig config = new SimpleConfig();
    config.putProperty(CoreConstants.Config.APPLICATION_ID, "APPID");
    ConfigContext.init(config);

    StaticListableBeanFactory testBf = new StaticListableBeanFactory();

    KualiModuleService riceKualiModuleService = mock(KualiModuleService.class);
    when(riceKualiModuleService.getInstalledModuleServices()).thenReturn(riceModuleServices);

    testBf.addBean(KRADServiceLocatorWeb.KUALI_MODULE_SERVICE, riceKualiModuleService);

    ResourceLoader rl = new BeanFactoryResourceLoader(new QName("moduleservicebase-unittest"), testBf);
    GlobalResourceLoader.addResourceLoader(rl);
    GlobalResourceLoader.start();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:KualiModuleServiceImplTest.java

示例3: mvc

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
public MockMvc mvc(Object controller) {
	StandaloneMockMvcBuilder builder = new StandaloneMockMvcBuilder(controller) {
		@Override
		protected WebApplicationContext initWebAppContext() {
			WebApplicationContext context = super.initWebAppContext();
			StaticListableBeanFactory beanFactory = (StaticListableBeanFactory)context.getAutowireCapableBeanFactory();

			Arrays.stream(BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, Object.class))
				.filter(name -> applicationContext.findAnnotationOnBean(name, ControllerAdvice.class) != null)
				.forEach(name -> beanFactory.addBean(name, applicationContext.getBean(name)));

			context.getBean(RequestMappingHandlerAdapter.class).afterPropertiesSet();
			return context;
		}
	};
	return builder.setHandlerExceptionResolvers(handlerExceptionResolver).build();
}
 
开发者ID:NetPenguin,项目名称:spring-boot-controller-test-example,代码行数:18,代码来源:TestHelper.java

示例4: testBeanAutowiredWithAnnotationConfigEnabled

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testBeanAutowiredWithAnnotationConfigEnabled() {
	GenericApplicationContext context = new GenericApplicationContext();
	context.registerBeanDefinition("myBf", new RootBeanDefinition(StaticListableBeanFactory.class));
	ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
	scanner.setBeanNameGenerator(new TestBeanNameGenerator());
	int beanCount = scanner.scan(BASE_PACKAGE);
	assertEquals(12, beanCount);
	context.refresh();

	FooServiceImpl fooService = context.getBean("fooService", FooServiceImpl.class);
	StaticListableBeanFactory myBf = (StaticListableBeanFactory) context.getBean("myBf");
	MessageSource ms = (MessageSource) context.getBean("messageSource");
	assertTrue(fooService.isInitCalled());
	assertEquals("bar", fooService.foo(123));
	assertSame(context.getDefaultListableBeanFactory(), fooService.beanFactory);
	assertEquals(2, fooService.listableBeanFactory.size());
	assertSame(context.getDefaultListableBeanFactory(), fooService.listableBeanFactory.get(0));
	assertSame(myBf, fooService.listableBeanFactory.get(1));
	assertSame(context, fooService.resourceLoader);
	assertSame(context, fooService.resourcePatternResolver);
	assertSame(context, fooService.eventPublisher);
	assertSame(ms, fooService.messageSource);
	assertSame(context, fooService.context);
	assertEquals(1, fooService.configurableContext.length);
	assertSame(context, fooService.configurableContext[0]);
	assertSame(context, fooService.genericContext);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ClassPathBeanDefinitionScannerTests.java

示例5: createOperationSource

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
protected JCacheOperationSource createOperationSource(CacheManager cacheManager,
		CacheResolver cacheResolver, CacheResolver exceptionCacheResolver, KeyGenerator keyGenerator) {

	DefaultJCacheOperationSource source = new DefaultJCacheOperationSource();
	source.setCacheManager(cacheManager);
	source.setCacheResolver(cacheResolver);
	source.setExceptionCacheResolver(exceptionCacheResolver);
	source.setKeyGenerator(keyGenerator);
	source.setBeanFactory(new StaticListableBeanFactory());
	source.afterPropertiesSet();
	source.afterSingletonsInstantiated();
	return source;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:JCacheInterceptorTests.java

示例6: testHierarchicalCountBeansWithNonHierarchicalFactory

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testHierarchicalCountBeansWithNonHierarchicalFactory() {
	StaticListableBeanFactory lbf = new StaticListableBeanFactory();
	lbf.addBean("t1", new TestBean());
	lbf.addBean("t2", new TestBean());
	assertTrue(BeanFactoryUtils.countBeansIncludingAncestors(lbf) == 2);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:BeanFactoryUtilsTests.java

示例7: testNoBeansOfType

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testNoBeansOfType() {
	StaticListableBeanFactory lbf = new StaticListableBeanFactory();
	lbf.addBean("foo", new Object());
	Map<String, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false);
	assertTrue(beans.isEmpty());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:BeanFactoryUtilsTests.java

示例8: testFindsBeansOfTypeWithStaticFactory

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testFindsBeansOfTypeWithStaticFactory() {
	StaticListableBeanFactory lbf = new StaticListableBeanFactory();
	TestBean t1 = new TestBean();
	TestBean t2 = new TestBean();
	DummyFactory t3 = new DummyFactory();
	DummyFactory t4 = new DummyFactory();
	t4.setSingleton(false);
	lbf.addBean("t1", t1);
	lbf.addBean("t2", t2);
	lbf.addBean("t3", t3);
	lbf.addBean("t4", t4);

	Map<String, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, true);
	assertEquals(4, beans.size());
	assertEquals(t1, beans.get("t1"));
	assertEquals(t2, beans.get("t2"));
	assertEquals(t3.getObject(), beans.get("t3"));
	assertTrue(beans.get("t4") instanceof TestBean);

	beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, DummyFactory.class, true, true);
	assertEquals(2, beans.size());
	assertEquals(t3, beans.get("&t3"));
	assertEquals(t4, beans.get("&t4"));

	beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, FactoryBean.class, true, true);
	assertEquals(2, beans.size());
	assertEquals(t3, beans.get("&t3"));
	assertEquals(t4, beans.get("&t4"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:BeanFactoryUtilsTests.java

示例9: initGRL

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void initGRL() throws Exception {
    GlobalResourceLoader.stop();
    SimpleConfig config = new SimpleConfig();
    config.putProperty(CoreConstants.Config.APPLICATION_ID, "APPID");
    ConfigContext.init(config);
    StaticListableBeanFactory testBf = new StaticListableBeanFactory();
    testBf.addBean(KRADServiceLocator.PROVIDER_REGISTRY, prMock);
    ResourceLoader rl = new BeanFactoryResourceLoader(new QName("moduleconfiguration-unittest"), testBf);
    GlobalResourceLoader.addResourceLoader(rl);
    GlobalResourceLoader.start();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:ModuleConfigurationTest.java

示例10: setup

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    GlobalResourceLoader.stop();

    SimpleConfig config = new SimpleConfig();
    config.putProperty(CoreConstants.Config.APPLICATION_ID, getClass().getName());
    ConfigContext.init(config);
    ConfigContext.getCurrentContextConfig().removeProperty(KRADConstants.Config.ENABLE_LEGACY_DATA_FRAMEWORK);
    ConfigContext.getCurrentContextConfig().removeProperty(KRADConstants.Config.KNS_ENABLED);

    StaticListableBeanFactory testBf = new StaticListableBeanFactory();
    testBf.addBean("metadataRepository", metadataRepository);
    testBf.addBean("dataDictionaryService", dataDictionaryService);
    testBf.addBean("knsLegacyDataAdapter", knsLegacyDataAdapter);
    testBf.addBean("kradLegacyDataAdapter", kradLegacyDataAdapter);

    ResourceLoader rl = new BeanFactoryResourceLoader(new QName(getClass().getName()), testBf);
    GlobalResourceLoader.addResourceLoader(rl);
    GlobalResourceLoader.start();

    MetadataManager mm = MetadataManager.getInstance();

    // register Legacy object
    ClassDescriptor legacyDescriptor = new ClassDescriptor(mm.getGlobalRepository());
    legacyDescriptor.setClassOfObject(Legacy.class);
    mm.getGlobalRepository().put(Legacy.class, legacyDescriptor);

    // register LegacyDocument object
    ClassDescriptor legacyDocumentDescriptor = new ClassDescriptor(mm.getGlobalRepository());
    legacyDocumentDescriptor.setClassOfObject(LegacyDocument.class);
    mm.getGlobalRepository().put(LegacyDocument.class, legacyDocumentDescriptor);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:33,代码来源:LegacyDataAdapterImplTest.java

示例11: createBadInstance

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void createBadInstance() {
    StaticListableBeanFactory bf = new StaticListableBeanFactory();
    bf.addBean("bean", "This is a bean");
    bad = (BadInterface)
            Proxy.newProxyInstance(this.getClass().getClassLoader(),
                    new Class[]{BadInterface.class},
                    new BeanFactoryInvocationHandler(bf));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:BeanFactoryInvocationHandlerTest.java

示例12: testBeanAutowiredWithAnnotationConfigEnabled

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testBeanAutowiredWithAnnotationConfigEnabled() {
	GenericApplicationContext context = new GenericApplicationContext();
	context.registerBeanDefinition("myBf", new RootBeanDefinition(StaticListableBeanFactory.class));
	ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
	scanner.setBeanNameGenerator(new TestBeanNameGenerator());
	int beanCount = scanner.scan(BASE_PACKAGE);
	assertEquals(10, beanCount);
	context.refresh();

	FooServiceImpl fooService = context.getBean("fooService", FooServiceImpl.class);
	StaticListableBeanFactory myBf = (StaticListableBeanFactory) context.getBean("myBf");
	MessageSource ms = (MessageSource) context.getBean("messageSource");
	assertTrue(fooService.isInitCalled());
	assertEquals("bar", fooService.foo(123));
	assertSame(context.getDefaultListableBeanFactory(), fooService.beanFactory);
	assertEquals(2, fooService.listableBeanFactory.size());
	assertSame(context.getDefaultListableBeanFactory(), fooService.listableBeanFactory.get(0));
	assertSame(myBf, fooService.listableBeanFactory.get(1));
	assertSame(context, fooService.resourceLoader);
	assertSame(context, fooService.resourcePatternResolver);
	assertSame(context, fooService.eventPublisher);
	assertSame(ms, fooService.messageSource);
	assertSame(context, fooService.context);
	assertEquals(1, fooService.configurableContext.length);
	assertSame(context, fooService.configurableContext[0]);
	assertSame(context, fooService.genericContext);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:ClassPathBeanDefinitionScannerTests.java

示例13: setUp

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Override
@SuppressWarnings("serial")
protected void setUp() {
	facesContext = new MockFacesContext();
	beanFactory = new StaticListableBeanFactory();

	delPhaseListener = new DelegatingPhaseListenerMulticaster() {
		@Override
		protected ListableBeanFactory getBeanFactory(FacesContext facesContext) {
			return beanFactory;
		}
	};
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:DelegatingPhaseListenerTests.java

示例14: setUp

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Override
protected void setUp() {
	facesContext = new MockFacesContext();
	beanFactory = new StaticListableBeanFactory();
	origNavHandler = new TestNavigationHandler();

	delNavHandler = new DelegatingNavigationHandlerProxy(origNavHandler) {
		@Override
		protected BeanFactory getBeanFactory(FacesContext facesContext) {
			return beanFactory;
		}
	};
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:DelegatingNavigationHandlerTests.java

示例15: testNoBeansOfType

import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Test
public void testNoBeansOfType() {
	StaticListableBeanFactory lbf = new StaticListableBeanFactory();
	lbf.addBean("foo", new Object());
	Map<?, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false);
	assertTrue(beans.isEmpty());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:BeanFactoryUtilsTests.java


注:本文中的org.springframework.beans.factory.support.StaticListableBeanFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。