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;
}
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");
}
Aggregations