use of org.springframework.cloud.service.AbstractCloudServiceConnectorFactory in project spring-cloud-connectors by spring-cloud.
the class CloudServiceIntroducer method postProcessBeanFactory.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
try {
Constructor<?> ctor = serviceConnectorFactoryType.getConstructor(String.class, ServiceConnectorConfig.class);
AbstractCloudServiceConnectorFactory<?> serviceFactory = (AbstractCloudServiceConnectorFactory<?>) ctor.newInstance(serviceId, serviceConnectorConfig);
serviceFactory.setServiceConnectorType((Class) serviceConnectorType);
serviceFactory.setBeanFactory(beanFactory);
serviceFactory.afterPropertiesSet();
// id is the beanId if specified, otherwise the serviceId
if (StringUtils.hasText(beanId)) {
beanFactory.registerSingleton(beanId, serviceFactory);
} else {
beanFactory.registerSingleton(serviceFactory.getServiceId(), serviceFactory);
}
} catch (Exception ex) {
throw new BeanCreationException("Error registering service factory", ex);
}
}
Aggregations