Search in sources :

Example 6 with CustomService

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);
    }
}
Also used : CustomService(org.mule.runtime.core.internal.config.CustomService) BeanDefinitionBuilder.genericBeanDefinition(org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 7 with CustomService

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;
}
Also used : CustomService(org.mule.runtime.core.internal.config.CustomService) DefaultClusterService(org.mule.runtime.core.internal.cluster.DefaultClusterService) Service(org.mule.runtime.api.service.Service) MuleValueProviderService(org.mule.runtime.core.internal.value.MuleValueProviderService) EventContextService(org.mule.runtime.core.api.event.EventContextService) DefaultConnectivityTestingService(org.mule.runtime.core.internal.connectivity.DefaultConnectivityTestingService) DefaultStreamCloserService(org.mule.runtime.core.internal.util.DefaultStreamCloserService) ExtendedTransformationService(org.mule.runtime.core.privileged.transformer.ExtendedTransformationService) DefaultEventContextService(org.mule.runtime.core.internal.event.DefaultEventContextService) MuleMetadataService(org.mule.runtime.core.internal.metadata.MuleMetadataService) BeanDefinitionBuilder.genericBeanDefinition(org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Aggregations

CustomService (org.mule.runtime.core.internal.config.CustomService)7 Test (org.junit.Test)4 Service (org.mule.runtime.api.service.Service)2 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)2 BeanDefinitionBuilder.genericBeanDefinition (org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Map (java.util.Map)1 Optional (java.util.Optional)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Inject (javax.inject.Inject)1 Registry (org.mule.runtime.api.artifact.Registry)1 ConfigurationProperties (org.mule.runtime.api.component.ConfigurationProperties)1 ConfigurationComponentLocator (org.mule.runtime.api.component.location.ConfigurationComponentLocator)1 ServiceConfigurator (org.mule.runtime.api.config.custom.ServiceConfigurator)1 CONNECTIVITY_TESTING_SERVICE_KEY (org.mule.runtime.api.connectivity.ConnectivityTestingService.CONNECTIVITY_TESTING_SERVICE_KEY)1 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 METADATA_SERVICE_KEY (org.mule.runtime.api.metadata.MetadataService.METADATA_SERVICE_KEY)1