use of org.mule.runtime.api.service.Service 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;
}
use of org.mule.runtime.api.service.Service in project mule by mulesoft.
the class InjectParamsFromContextServiceProxy method createInjectProviderParamsServiceProxy.
/**
* Creates a proxy for the provided service instance.
*
* @param service service to wrap. Non null.
* @param registry the {@link Registry} to use for resolving injectable parameters. Non null.
* @return a new proxy instance.
*/
public static Service createInjectProviderParamsServiceProxy(Service service, Registry registry) {
checkArgument(service != null, "service cannot be null");
checkArgument(registry != null, "registry cannot be null");
InvocationHandler handler = new InjectParamsFromContextServiceProxy(service, registry);
return (Service) newProxyInstance(service.getClass().getClassLoader(), findImplementedInterfaces(service.getClass()), handler);
}
Aggregations