本文整理汇总了Java中org.springframework.beans.factory.support.StaticListableBeanFactory类的典型用法代码示例。如果您正苦于以下问题:Java StaticListableBeanFactory类的具体用法?Java StaticListableBeanFactory怎么用?Java StaticListableBeanFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StaticListableBeanFactory类属于org.springframework.beans.factory.support包,在下文中一共展示了StaticListableBeanFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: createInstance
import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
private DefaultMessageHandlerMethodFactory createInstance() {
DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
factory.setBeanFactory(new StaticListableBeanFactory());
return factory;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:DefaultMessageHandlerMethodFactoryTests.java
示例17: initializeFactory
import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
factory.setBeanFactory(new StaticListableBeanFactory());
factory.afterPropertiesSet();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:MessagingMessageListenerAdapterTests.java
示例18: setup
import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
@Before
public void setup() {
registrar.setEndpointRegistry(registry);
registrar.setBeanFactory(new StaticListableBeanFactory());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:JmsListenerEndpointRegistrarTests.java
示例19: doTestSchedulerFactoryBean
import org.springframework.beans.factory.support.StaticListableBeanFactory; //导入依赖的package包/类
private void doTestSchedulerFactoryBean(boolean explicitJobDetail, boolean prototypeJob) throws Exception {
TestBean tb = new TestBean("tb", 99);
JobDetailBean jobDetail0 = new JobDetailBean();
jobDetail0.setJobClass(Job.class);
jobDetail0.setBeanName("myJob0");
Map jobData = new HashMap();
jobData.put("testBean", tb);
jobDetail0.setJobDataAsMap(jobData);
jobDetail0.afterPropertiesSet();
assertEquals(tb, jobDetail0.getJobDataMap().get("testBean"));
CronTriggerBean trigger0 = new CronTriggerBean();
trigger0.setBeanName("myTrigger0");
trigger0.setJobDetail(jobDetail0);
trigger0.setCronExpression("0/1 * * * * ?");
trigger0.afterPropertiesSet();
TestMethodInvokingTask task1 = new TestMethodInvokingTask();
MethodInvokingJobDetailFactoryBean mijdfb = new MethodInvokingJobDetailFactoryBean();
mijdfb.setBeanName("myJob1");
if (prototypeJob) {
StaticListableBeanFactory beanFactory = new StaticListableBeanFactory();
beanFactory.addBean("task", task1);
mijdfb.setTargetBeanName("task");
mijdfb.setBeanFactory(beanFactory);
}
else {
mijdfb.setTargetObject(task1);
}
mijdfb.setTargetMethod("doSomething");
mijdfb.afterPropertiesSet();
JobDetail jobDetail1 = mijdfb.getObject();
SimpleTriggerBean trigger1 = new SimpleTriggerBean();
trigger1.setBeanName("myTrigger1");
trigger1.setJobDetail(jobDetail1);
trigger1.setStartDelay(0);
trigger1.setRepeatInterval(20);
trigger1.afterPropertiesSet();
final Scheduler scheduler = mock(Scheduler.class);
given(scheduler.getContext()).willReturn(new SchedulerContext());
given(scheduler.scheduleJob(trigger0)).willReturn(new Date());
given(scheduler.scheduleJob(trigger1)).willReturn(new Date());
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
@Override
protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
return scheduler;
}
};
schedulerFactoryBean.setJobFactory(null);
Map schedulerContext = new HashMap();
schedulerContext.put("otherTestBean", tb);
schedulerFactoryBean.setSchedulerContextAsMap(schedulerContext);
if (explicitJobDetail) {
schedulerFactoryBean.setJobDetails(new JobDetail[] {jobDetail0});
}
schedulerFactoryBean.setTriggers(new Trigger[] {trigger0, trigger1});
try {
schedulerFactoryBean.afterPropertiesSet();
schedulerFactoryBean.start();
}
finally {
schedulerFactoryBean.destroy();
}
verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP);
verify(scheduler).getJobDetail("myJob1", Scheduler.DEFAULT_GROUP);
verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP);
verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP);
verify(scheduler).addJob(jobDetail0, true);
verify(scheduler).addJob(jobDetail1, true);
verify(scheduler).start();
verify(scheduler).shutdown(false);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:77,代码来源:QuartzSupportTests.java
示例20: 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<?, ?> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, true, false);
assertEquals(2, beans.size());
assertEquals(t1, beans.get("t1"));
assertEquals(t2, beans.get("t2"));
beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(lbf, ITestBean.class, false, true);
assertEquals(3, beans.size());
assertEquals(t1, beans.get("t1"));
assertEquals(t2, beans.get("t2"));
assertEquals(t3.getObject(), beans.get("t3"));
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:deathspeeder,项目名称:class-guard,代码行数:42,代码来源:BeanFactoryUtilsTests.java
注:本文中的org.springframework.beans.factory.support.StaticListableBeanFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论