Example usage for org.springframework.context.annotation ClassPathBeanDefinitionScanner addExcludeFilter

List of usage examples for org.springframework.context.annotation ClassPathBeanDefinitionScanner addExcludeFilter

Introduction

In this page you can find the example usage for org.springframework.context.annotation ClassPathBeanDefinitionScanner addExcludeFilter.

Prototype

public void addExcludeFilter(TypeFilter excludeFilter) 

Source Link

Document

Add an exclude type filter to the front of the exclusion list.

Usage

From source file:info.sargis.eventbus.config.EventBusHandlerBeanDefinitionParser.java

protected void parseTypeFilters(Element element, ClassPathBeanDefinitionScanner scanner,
        XmlReaderContext readerContext, ParserContext parserContext) {

    // Parse exclude and include filter elements.
    ClassLoader classLoader = scanner.getResourceLoader().getClassLoader();
    NodeList nodeList = element.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            String localName = parserContext.getDelegate().getLocalName(node);
            try {
                if (INCLUDE_FILTER_ELEMENT.equals(localName)) {
                    TypeFilter typeFilter = createTypeFilter((Element) node, classLoader);
                    scanner.addIncludeFilter(typeFilter);
                } else if (EXCLUDE_FILTER_ELEMENT.equals(localName)) {
                    TypeFilter typeFilter = createTypeFilter((Element) node, classLoader);
                    scanner.addExcludeFilter(typeFilter);
                }//from   ww  w. ja  v  a  2 s.c  o  m
            } catch (Exception ex) {
                readerContext.error(ex.getMessage(), readerContext.extractSource(element), ex.getCause());
            }
        }
    }
}