Search in sources :

Example 1 with ManagedConnector

use of com.evolveum.midpoint.provisioning.ucf.api.ManagedConnector 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

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 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 ClassPathScanningCandidateComponentProvider (org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider)1 AnnotationTypeFilter (org.springframework.core.type.filter.AnnotationTypeFilter)1