Search in sources :

Example 6 with ClassPathScanningCandidateComponentProvider

use of org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider in project spring-boot by spring-projects.

the class ServletComponentRegisteringPostProcessor method createComponentProvider.

private ClassPathScanningCandidateComponentProvider createComponentProvider() {
    ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
    componentProvider.setEnvironment(this.applicationContext.getEnvironment());
    componentProvider.setResourceLoader(this.applicationContext);
    for (ServletComponentHandler handler : HANDLERS) {
        componentProvider.addIncludeFilter(handler.getTypeFilter());
    }
    return componentProvider;
}
Also used : ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider)

Example 7 with ClassPathScanningCandidateComponentProvider

use of org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider in project midpoint by Evolveum.

the class ConnectorFactoryBuiltinImpl method discoverConnectors.

private void discoverConnectors() {
    connectorMap = new HashMap<>();
    ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(ManagedConnector.class));
    LOGGER.trace("Scanning package {}", SCAN_PACKAGE);
    for (BeanDefinition bd : scanner.findCandidateComponents(SCAN_PACKAGE)) {
        LOGGER.debug("Found connector class {}", bd);
        String beanClassName = bd.getBeanClassName();
        try {
            Class connectorClass = Class.forName(beanClassName);
            ManagedConnector annotation = (ManagedConnector) connectorClass.getAnnotation(ManagedConnector.class);
            String type = annotation.type();
            LOGGER.debug("Found connector {} class {}", type, connectorClass);
            ConnectorStruct struct = createConnectorStruct(connectorClass, annotation);
            connectorMap.put(type, struct);
        } catch (ClassNotFoundException e) {
            LOGGER.error("Error loading connector class {}: {}", beanClassName, e.getMessage(), e);
        } catch (ObjectNotFoundException | SchemaException e) {
            LOGGER.error("Error discovering the connector {}: {}", beanClassName, e.getMessage(), e);
        }
    }
    LOGGER.trace("Scan done");
}
Also used : AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ClassPathScanningCandidateComponentProvider(org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ManagedConnector(com.evolveum.midpoint.provisioning.ucf.api.ManagedConnector) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Aggregations

ClassPathScanningCandidateComponentProvider (org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider)7 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)6 AnnotationTypeFilter (org.springframework.core.type.filter.AnnotationTypeFilter)4 ArrayList (java.util.ArrayList)2 ManagedConnector (com.evolveum.midpoint.provisioning.ucf.api.ManagedConnector)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Pattern (java.util.regex.Pattern)1 Entity (javax.persistence.Entity)1 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)1 MetadataSources (org.hibernate.boot.MetadataSources)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)1 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)1 DataAccessException (org.jooq.exception.DataAccessException)1 Description (org.junit.runner.Description)1