List of usage examples for org.springframework.context ApplicationContext getBeanNamesForType
String[] getBeanNamesForType(ResolvableType type);
From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java
@Override public void afterPropertiesSet() { if (this.argumentResolvers.getResolvers().isEmpty()) { this.argumentResolvers.addResolvers(initArgumentResolvers()); }/* w ww . ja v a 2 s .co m*/ if (this.returnValueHandlers.getReturnValueHandlers().isEmpty()) { this.returnValueHandlers.addHandlers(initReturnValueHandlers()); } ApplicationContext context = getApplicationContext(); if (context == null) { return; } for (String beanName : context.getBeanNamesForType(Object.class)) { if (!beanName.startsWith(SCOPED_TARGET_NAME_PREFIX)) { Class<?> beanType = null; try { beanType = context.getType(beanName); } catch (Throwable ex) { // An unresolvable bean type, probably from a lazy bean - let's ignore it. if (logger.isDebugEnabled()) { logger.debug("Could not resolve target class for bean with name '" + beanName + "'", ex); } } if (beanType != null && isHandler(beanType)) { detectHandlerMethods(beanName); } } } }
From source file:org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration.java
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (ClassUtils.isPresent("org.springframework.security.web.authentication.RememberMeServices", null)) { this.usesSpringSessionRememberMeServices = !ObjectUtils .isEmpty(applicationContext.getBeanNamesForType(SpringSessionRememberMeServices.class)); }//from ww w .j av a2s. c o m }
From source file:test.profile.ClassPathXmlJobRegistry.java
public void afterPropertiesSet() throws Exception { for (Resource resource : jobPaths) { ClassPathXmlApplicationContextFactory applicationContextFactory = new ClassPathXmlApplicationContextFactory(); applicationContextFactory.setPath(resource); applicationContextFactory.setApplicationContext(parent); ApplicationContext context = applicationContextFactory.createApplicationContext(); String[] names = context.getBeanNamesForType(Job.class); for (String name : names) { logger.debug("Registering job: " + name + " from context: " + resource); ApplicationContextJobFactory jobFactory = new ApplicationContextJobFactory( applicationContextFactory, name); jobRegistry.register(jobFactory); }/*from w w w . j av a 2s .com*/ } if (jobRegistry.getJobNames().isEmpty()) { throw new NoSuchJobException("Could not locate any jobs in resources provided."); } }