Here are the examples of the java api org.springframework.context.ApplicationContext.getBeansOfType() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
354 Examples
19
View Source File : SpringContextUtils.java
License : Apache License 2.0
Project Creator : zifangsky
License : Apache License 2.0
Project Creator : zifangsky
/**
* 根据bean的clreplaced来查找所有的对象(包括子类)
* @param <T>
* @param c
* @return
*/
public static <T> Map<String, T> getBeansByClreplaced(Clreplaced<T> c) {
return applicationContext.getBeansOfType(c);
}
19
View Source File : SpringContextHolder.java
License : MIT License
Project Creator : zhaojun1998
License : MIT License
Project Creator : zhaojun1998
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> clreplacedz) {
return applicationContext.getBeansOfType(clreplacedz);
}
19
View Source File : MiraiPlusApplicationBeanContext.java
License : GNU Affero General Public License v3.0
Project Creator : xiaoxu97
License : GNU Affero General Public License v3.0
Project Creator : xiaoxu97
public static <T> Map<String, T> getBeansByClreplaced(Clreplaced<T> tClreplaced) {
if (applicationContext == null) {
return null;
}
return applicationContext.getBeansOfType(tClreplaced);
}
19
View Source File : SpringInstanceProvider.java
License : Apache License 2.0
Project Creator : warlock-china
License : Apache License 2.0
Project Creator : warlock-china
public <T> Map<String, T> getInterfaces(Clreplaced<T> beanClreplaced) {
return applicationContext.getBeansOfType(beanClreplaced);
}
19
View Source File : SpringContext.java
License : Apache License 2.0
Project Creator : wangmingco
License : Apache License 2.0
Project Creator : wangmingco
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> requiredType) throws BeansException {
return context.getBeansOfType(requiredType);
}
19
View Source File : ApplicationHolder.java
License : Apache License 2.0
Project Creator : uhfun
License : Apache License 2.0
Project Creator : uhfun
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
return applicationContext.getBeansOfType(type);
}
19
View Source File : CacheManagerEndpoint.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
@GetMapping("/{cacheManager}")
public Object getAllCache(@PathVariable("cacheManager") String cacheManager) {
return applicationContext.getBeansOfType(CacheManager.clreplaced).entrySet().stream().filter(en -> en.getKey().equals(cacheManager)).map(en -> en.getValue().getCacheNames()).findFirst().orElseGet(ArrayDeque::new);
}
19
View Source File : InterceptorInitBeanSupport.java
License : Apache License 2.0
Project Creator : rocketmq
License : Apache License 2.0
Project Creator : rocketmq
/**
* 加载插件实例
*
* @param clazz 插件类型
* @return 插件Map, key为bean名称, value为插件实例对象
*/
protected Map<String, InterceptorPlugin> getPlugins(Clreplaced<InterceptorPlugin> clazz) {
return applicationContext.getBeansOfType(clazz);
}
19
View Source File : NewEventSpeechlet.java
License : MIT License
Project Creator : rainu
License : MIT License
Project Creator : rainu
Set<String> getCalendarNames() {
return context.getBeansOfType(CalendarCLIAdapter.clreplaced).keySet();
}
19
View Source File : ConnectionService.java
License : MIT License
Project Creator : nicolasmanic
License : MIT License
Project Creator : nicolasmanic
private Set<Map.Entry<String, InjectorService>> getInjectorEntrySet() {
return context.getBeansOfType(InjectorService.clreplaced).entrySet();
}
19
View Source File : ApplicationContextHolder.java
License : Apache License 2.0
Project Creator : MissThee
License : Apache License 2.0
Project Creator : MissThee
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> clazz) {
return applicationContext.getBeansOfType(clazz);
}
19
View Source File : Phoenix.java
License : Apache License 2.0
Project Creator : LinuxSuRen
License : Apache License 2.0
Project Creator : LinuxSuRen
public <T> Map<String, T> getRunner(Clreplaced<T> type) {
return context.getBeansOfType(type);
}
19
View Source File : SpringContextHolder.java
License : Apache License 2.0
Project Creator : learningtcc
License : Apache License 2.0
Project Creator : learningtcc
/**
* 根据类型获取容器中实例的集合
*
* @param requiredType
* @return
* @date 2015年11月17日
* @since V2.1.0
* @author Ternence
*/
public static <T> Map<String, T> getBeans(Clreplaced<T> requiredType) {
checkApplicationContext();
return applicationContext.getBeansOfType(requiredType);
}
19
View Source File : SpringContextUtil.java
License : Apache License 2.0
Project Creator : KimZing
License : Apache License 2.0
Project Creator : KimZing
/**
* 以Collection形式获取T的所有实例
*
* @param clazz
* @param <T>
* @return
*/
public static <T> Collection<T> getBeansByTypeToCollection(Clreplaced<T> clazz) {
return applicationContext.getBeansOfType(clazz).values();
}
19
View Source File : SpringContextUtil.java
License : Apache License 2.0
Project Creator : KimZing
License : Apache License 2.0
Project Creator : KimZing
/**
* 以Map形式获取T的所有实例
*
* @param clazz
* @param <T>
* @return
*/
public static <T> Map<String, T> getBeansByTypeToMap(Clreplaced<T> clazz) {
return applicationContext.getBeansOfType(clazz);
}
19
View Source File : SecuritySpringHook.java
License : Apache License 2.0
Project Creator : iyangyuan
License : Apache License 2.0
Project Creator : iyangyuan
/**
* 根据bean类型获取spring ioc管理的bean实例
* @param type bean类型,clreplaced或interface
* @return bean实例集合
*/
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
return applicationContext.getBeansOfType(type);
}
19
View Source File : ApplicationContextHolder.java
License : MIT License
Project Creator : Hccake
License : MIT License
Project Creator : Hccake
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
return context.getBeansOfType(type);
}
19
View Source File : ContextUtil.java
License : Apache License 2.0
Project Creator : Frodez
License : Apache License 2.0
Project Creator : Frodez
/**
* 使用spring上下文环境获取bean
* @param klreplaced bean的类型
* @author Frodez
* @param <T>
* @date 2018-12-21
*/
public static <T> Map<String, T> beans(Clreplaced<T> klreplaced) {
return context.getBeansOfType(klreplaced);
}
19
View Source File : NettyRpcApplication.java
License : Apache License 2.0
Project Creator : forezp
License : Apache License 2.0
Project Creator : forezp
public static Map<String, Object> getBeansOfType(Clreplaced clz) {
return context.getBeansOfType(clz);
}
19
View Source File : SpringBeanUtils.java
License : MIT License
Project Creator : fengdis
License : MIT License
Project Creator : fengdis
/**
* 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的Map集合.
*/
public static <T> Map<String, T> getBeanMap(Clreplaced<T> clazz) {
checkApplicationContext();
return applicationContext.getBeansOfType(clazz);
}
19
View Source File : AbstractRestlight4Spring.java
License : Apache License 2.0
Project Creator : esastack
License : Apache License 2.0
Project Creator : esastack
private void fireDeployContextAware() {
context.getBeansOfType(RestlightDeployContextAware.clreplaced).values().forEach(aware -> aware.setDeployContext(deployments().deployContext()));
}
19
View Source File : SpringUtil.java
License : Apache License 2.0
Project Creator : cai3178940
License : Apache License 2.0
Project Creator : cai3178940
/**
* 根据类型获取beanMap
*
* @param clz
* @return
*/
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> clz) {
if (applicationContext == null) {
return null;
}
return applicationContext.getBeansOfType(clz);
}
19
View Source File : SpringContextUtils.java
License : Apache License 2.0
Project Creator : atliwen
License : Apache License 2.0
Project Creator : atliwen
public static Map getBeansByClreplaced(Clreplaced c) {
return applicationContext.getBeansOfType(c);
}
19
View Source File : SpringAware.java
License : MIT License
Project Creator : aoju
License : MIT License
Project Creator : aoju
/**
* 获取指定类型对应的所有Bean,包括子类
*
* @param <T> Bean类型
* @param type 类、接口,null表示获取所有bean
* @return 类型对应的bean,key是bean注册的name,value是Bean
*/
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
return applicationContext.getBeansOfType(type);
}
19
View Source File : SpringContextUtil.java
License : Apache License 2.0
Project Creator : anylineorg
License : Apache License 2.0
Project Creator : anylineorg
public static <T> Map<String, T> getBeans(Clreplaced<T> clazz) throws BeansException {
return applicationContext.getBeansOfType(clazz);
}
19
View Source File : ApplicationUtils.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) throws BeansException {
return applicationContext.getBeansOfType(type);
}
19
View Source File : ApplicationUtils.java
License : Apache License 2.0
Project Creator : alibaba
License : Apache License 2.0
Project Creator : alibaba
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException {
return applicationContext.getBeansOfType(type, includeNonSingletons, allowEagerInit);
}
19
View Source File : ApplicationContextUtil.java
License : GNU Affero General Public License v3.0
Project Creator : AcceNoi
License : GNU Affero General Public License v3.0
Project Creator : AcceNoi
public static <T> Map<String, T> getBeans(Clreplaced<T> clazz) {
return context.getBeansOfType(clazz);
}
19
View Source File : SpringUtil.java
License : Apache License 2.0
Project Creator : 65487123
License : Apache License 2.0
Project Creator : 65487123
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> baseType) {
if (applicationContext != null) {
return applicationContext.getBeansOfType(baseType);
} else {
return new HashMap<>();
}
}
18
View Source File : SpringUtils.java
License : Apache License 2.0
Project Creator : zuihou
License : Apache License 2.0
Project Creator : zuihou
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
replacedert.notNull(type, "SpringUtil type is null");
try {
return applicationContext.getBeansOfType(type);
} catch (Exception e) {
return parentApplicationContext.getBeansOfType(type);
}
}
18
View Source File : ConfigContext.java
License : Apache License 2.0
Project Creator : zouzhirong
License : Apache License 2.0
Project Creator : zouzhirong
/**
* 注册配置项预处理器
*
* @return
*/
private void registerConfigItemPostProcessors() {
List<ConfigItemPostProcessor> configItemPostProcessors = new ArrayList<>();
configItemPostProcessors.addAll(applicationContext.getBeansOfType(ConfigItemPostProcessor.clreplaced).values());
AnnotationAwareOrderComparator.sort(configItemPostProcessors);
this.configItemPostProcessors.addAll(configItemPostProcessors);
}
18
View Source File : SpringBasedSelector.java
License : Apache License 2.0
Project Creator : yanglifan
License : Apache License 2.0
Project Creator : yanglifan
@Override
protected <T> Iterable<T> findCandidatesByType(Clreplaced<T> beanClreplaced) {
return applicationContext.getBeansOfType(beanClreplaced).values();
}
18
View Source File : JwtPermissionConfiguration.java
License : Apache License 2.0
Project Creator : whvcse
License : Apache License 2.0
Project Creator : whvcse
/**
* 获取Bean
*/
private <T> T getBean(Clreplaced<T> clazz) {
T bean = null;
Collection<T> beans = applicationContext.getBeansOfType(clazz).values();
while (beans.iterator().hasNext()) {
bean = beans.iterator().next();
if (bean != null)
break;
}
return bean;
}
18
View Source File : JwtPermissionClientConfiguration.java
License : Apache License 2.0
Project Creator : whvcse
License : Apache License 2.0
Project Creator : whvcse
/**
* 获取Bean
*/
private <T> T getBean(Clreplaced<T> clazz) {
T bean = null;
Collection<T> beans = applicationContext.getBeansOfType(clazz).values();
while (beans.iterator().hasNext()) {
bean = beans.iterator().next();
if (bean != null) {
break;
}
}
return bean;
}
18
View Source File : IntegrationTracingEnabledTest.java
License : Apache License 2.0
Project Creator : syndesisio
License : Apache License 2.0
Project Creator : syndesisio
@Test
public void testContextConfiguration() {
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced).values()).hasAtLeastOneElementOfType(TracingCamelContextConfiguration.clreplaced);
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced)).hreplacedize(2);
replacedertThat(applicationContext.getBeansOfType(Tracer.clreplaced)).hreplacedize(1);
replacedertThat(camelContext.getLogListeners()).hasAtLeastOneElementOfType(TracingLogListener.clreplaced);
}
18
View Source File : IntegrationTracingDisabledTest.java
License : Apache License 2.0
Project Creator : syndesisio
License : Apache License 2.0
Project Creator : syndesisio
@Test
public void testDisabledContextConfiguration() {
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced).values()).doesNotHaveAnyElementsOfTypes(TracingCamelContextConfiguration.clreplaced);
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced)).hreplacedize(1);
replacedertThat(camelContext.getLogListeners()).have(new Condition<LogListener>() {
@Override
public boolean matches(LogListener value) {
return !(value instanceof TracingLogListener);
}
});
}
18
View Source File : IntegrationLoggingEnabledTest.java
License : Apache License 2.0
Project Creator : syndesisio
License : Apache License 2.0
Project Creator : syndesisio
@Test
public void testContextConfiguration() {
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced)).hreplacedize(2);
replacedertThat(applicationContext.getBeansOfType(ActivityTracker.clreplaced)).hreplacedize(1);
replacedertThat(applicationContext.getBeansOfType(ActivityTracker.clreplaced).values()).hasAtLeastOneElementOfType(ActivityTracker.SysOut.clreplaced);
replacedertThat(camelContext.getLogListeners()).hasAtLeastOneElementOfType(IntegrationLoggingListener.clreplaced);
replacedertThat(camelContext.getUuidGenerator()).isNotInstanceOf(DefaultUuidGenerator.clreplaced);
}
18
View Source File : IntegrationLoggingDisabledTest.java
License : Apache License 2.0
Project Creator : syndesisio
License : Apache License 2.0
Project Creator : syndesisio
@Test
public void testDisabledContextConfiguration() {
replacedertThat(applicationContext.getBeansOfType(CamelContextConfiguration.clreplaced)).is(new Condition<Map<String, CamelContextConfiguration>>() {
@Override
public boolean matches(Map<String, CamelContextConfiguration> value) {
return value.size() == 1 && value.containsKey("integrationContextRuntimeConfiguration");
}
});
replacedertThat(camelContext.getLogListeners()).have(new Condition<LogListener>() {
@Override
public boolean matches(LogListener value) {
return !(value instanceof IntegrationLoggingListener);
}
});
replacedertThat(camelContext.getUuidGenerator()).isInstanceOf(DefaultUuidGenerator.clreplaced);
}
18
View Source File : ApplicationTest.java
License : Apache License 2.0
Project Creator : syndesisio
License : Apache License 2.0
Project Creator : syndesisio
@Test
public void testApplicationSetup() {
replacedertThat(applicationContext.getBeansOfType(IntegrationRuntimeAutoConfiguration.clreplaced)).hreplacedize(1);
replacedertThat(applicationContext.getBeansOfType(IntegrationMetadataAutoConfiguration.clreplaced)).hreplacedize(1);
replacedertThat(applicationContext.getBeansOfType(IntegrationLoggingAutoConfiguration.clreplaced)).hreplacedize(1);
replacedertThat(applicationContext.getBeansOfType(SyndesisHttpConfiguration.clreplaced)).hreplacedize(1);
}
18
View Source File : SpringInitializer.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
protected <T> List<T> getBeans(Clreplaced<T> cls) {
Map<String, T> beans = cxt.getBeansOfType(cls);
return new ArrayList<>(beans.values());
}
18
View Source File : CacheManagerEndpoint.java
License : Apache License 2.0
Project Creator : SpringCloud
License : Apache License 2.0
Project Creator : SpringCloud
@GetMapping()
public Object getAllCacheManager() {
return applicationContext.getBeansOfType(CacheManager.clreplaced).entrySet().stream().map((entry) -> {
entry.getKey();
Map<String, Object> cm = new HashMap<>();
cm.put("name", entry.getKey());
cm.put("caches", entry.getValue().getCacheNames());
return cm;
}).collect(Collectors.toList());
}
18
View Source File : WizardDaoImpl.java
License : GNU Lesser General Public License v3.0
Project Creator : schic
License : GNU Lesser General Public License v3.0
Project Creator : schic
@Override
public <W extends Wizard<?, ?>> Collection<W> getWizardsOfType(Clreplaced<W> wizardClreplaced) {
return _applicationContext.getBeansOfType(wizardClreplaced).values();
}
18
View Source File : InterceptorHookManager.java
License : GNU General Public License v3.0
Project Creator : qiushi123
License : GNU General Public License v3.0
Project Creator : qiushi123
/**
* 获取拦截类的所有钩子
*/
@PostConstruct
private void init() {
Map<String, InterceptorHook> map = applicationContext.getBeansOfType(InterceptorHook.clreplaced);
Iterator<Map.Entry<String, InterceptorHook>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, InterceptorHook> entry = it.next();
InterceptorHook interceptorHook = entry.getValue();
String[] names = interceptorHook.getInterceptor();
addInterceptorHook(names, interceptorHook);
}
}
18
View Source File : DoubleNameShouldBeResolvedAutomaticallyToReplaceExistingBean.java
License : MIT License
Project Creator : pchudzik
License : MIT License
Project Creator : pchudzik
@Test
public void should_replace_single_bean_with_mock() {
replacedertSame(aMock, mock);
replacedertEquals(1, applicationContext.getBeansOfType(ServiceToMock.clreplaced).size());
}
18
View Source File : DoubleNameShouldBeResolvedAutomaticallyToReplaceExistingBean.java
License : MIT License
Project Creator : pchudzik
License : MIT License
Project Creator : pchudzik
@Test
public void should_replace_single_bean_with_spy() {
replacedertSame(aSpy, spy);
replacedertEquals(1, applicationContext.getBeansOfType(ServiceToSpy.clreplaced).size());
}
18
View Source File : WebsocketTest.java
License : Apache License 2.0
Project Creator : opentracing-contrib
License : Apache License 2.0
Project Creator : opentracing-contrib
@Test
public void test() {
replacedertEquals(2, applicationContext.getBeansOfType(TracingChannelInterceptor.clreplaced).size());
}
18
View Source File : SpringContextHolder.java
License : Apache License 2.0
Project Creator : it235
License : Apache License 2.0
Project Creator : it235
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> type) {
replacedert.notNull(type, "SpringContextHolder type is null");
try {
return applicationContext.getBeansOfType(type);
} catch (Exception var2) {
return parentApplicationContext.getBeansOfType(type);
}
}
18
View Source File : StaticSpringContext.java
License : Apache License 2.0
Project Creator : i-novus-llc
License : Apache License 2.0
Project Creator : i-novus-llc
@Deprecated
public static <T> Map<String, T> getBeansOfType(Clreplaced<T> clazz) {
return CONTEXT.getBeansOfType(clazz);
}
18
View Source File : DirectiveRegistryImpl.java
License : MIT License
Project Creator : graphql-java-generator
License : MIT License
Project Creator : graphql-java-generator
/**
* {@inheritDoc}<BR/>
* This implementation works only if this clreplaced has been loaded as a Spring Component.
*/
@Override
public void registerAllDirectives() {
for (Directive type : ctx.getBeansOfType(Directive.clreplaced).values()) {
registerDirective(type);
}
}
18
View Source File : GuiModule.java
License : Apache License 2.0
Project Creator : gemini-projects
License : Apache License 2.0
Project Creator : gemini-projects
private void loadSmartModules() {
logger.info("SMART MODULES LOADING");
Map<String, SmartModule> modulesMap = context.getBeansOfType(SmartModule.clreplaced);
this.smartModules = modulesMap.values().stream().sorted(Comparator.comparingInt(SmartModule::order)).collect(Collectors.toList());
for (SmartModule module : smartModules) {
logger.info("Found SMART Module {} with dependecies {}", module.getName(), module.getDependencies());
}
}
See More Examples