use of org.mule.runtime.core.internal.config.CustomService in project mule by mulesoft.
the class SpringMuleContextServiceConfigurator method createCustomServices.
private void createCustomServices() {
final Map<String, CustomService> customServices = customServiceRegistry.getCustomServices();
for (String serviceName : customServices.keySet()) {
if (beanDefinitionRegistry.containsBeanDefinition(serviceName)) {
throw new IllegalStateException("There is already a bean definition registered with key: " + serviceName);
}
final CustomService customService = customServices.get(serviceName);
final BeanDefinition beanDefinition = getCustomServiceBeanDefinition(customService);
registerBeanDefinition(serviceName, beanDefinition);
}
}
use of org.mule.runtime.core.internal.config.CustomService in project mule by mulesoft.
the class SpringMuleContextServiceConfigurator method getCustomServiceBeanDefinition.
private BeanDefinition getCustomServiceBeanDefinition(CustomService customService) {
BeanDefinition beanDefinition;
Optional<Class> customServiceClass = customService.getServiceClass();
Optional<Object> customServiceImpl = customService.getServiceImpl();
if (customServiceClass.isPresent()) {
beanDefinition = getBeanDefinitionBuilder(customServiceClass.get()).getBeanDefinition();
} else if (customServiceImpl.isPresent()) {
if (customServiceImpl.get() instanceof Service) {
beanDefinition = getConstantObjectBeanDefinition(createInjectProviderParamsServiceProxy((Service) customServiceImpl.get(), registry));
} else {
beanDefinition = getConstantObjectBeanDefinition(customServiceImpl.get());
}
} else {
throw new IllegalStateException("A custom service must define a service class or instance");
}
return beanDefinition;
}
Aggregations