List of usage examples for org.springframework.beans.factory ListableBeanFactory getBeanNamesForType
String[] getBeanNamesForType(@Nullable Class<?> type);
From source file:org.springframework.flex.messaging.MessageTemplate.java
/** * //from ww w . j a v a 2s . c om * {@inheritDoc} */ public void afterPropertiesSet() throws Exception { if (this.messageBroker == null) { // first try the default id if (this.beanFactory.containsBean(BeanIds.MESSAGE_BROKER)) { this.messageBroker = (MessageBroker) this.beanFactory.getBean(BeanIds.MESSAGE_BROKER, MessageBroker.class); } else if (this.beanFactory instanceof ListableBeanFactory) { ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory; String[] brokerNames = lbf.getBeanNamesForType(MessageBroker.class); if (brokerNames.length == 1) { this.messageBroker = (MessageBroker) lbf.getBean(brokerNames[0]); } else if (brokerNames.length > 1) { log.warn( "A MessageBroker was not explicitly set and one could not be auto-detected in the MessageTemplate's bean factory as " + "multiple MessageBrokers were found. Will fall back to attempting to obtain the MessageBroker from the FlexContext for " + "each operation."); } else { log.warn( "A MessageBroker was not explicitly set and one could not be found in the MessageTemplate's bean factory. Will " + "will fall back to attempting to obtain the MessageBroker from the FlexContext for each operation."); } } } }