Example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeanNamesForType

List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeanNamesForType

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory getBeanNamesForType.

Prototype

String[] getBeanNamesForType(ResolvableType type, boolean includeNonSingletons, boolean allowEagerInit);

Source Link

Document

Return the names of beans matching the given type (including subclasses), judging from either bean definitions or the value of getObjectType in the case of FactoryBeans.

Usage

From source file:org.springframework.integration.ws.config.WsIntegrationConfigurationInitializer.java

@Override
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (beanFactory instanceof BeanDefinitionRegistry) {
        if (beanFactory.getBeanNamesForType(EndpointAdapter.class, false, false).length > 0) {
            BeanDefinitionBuilder requestMappingBuilder = BeanDefinitionBuilder
                    .genericBeanDefinition(MessageEndpointAdapter.class);
            requestMappingBuilder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
            ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(MESSAGE_ENDPOINT_ADAPTER_BEAN_NAME,
                    requestMappingBuilder.getBeanDefinition());
        }/*from w  w w .j av a2  s.c  o m*/
    } else {
        logger.warn("'IntegrationRequestMappingHandlerMapping' isn't registered because 'beanFactory'"
                + " isn't an instance of `BeanDefinitionRegistry`.");
    }
}