Search in sources :

Example 6 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class DefaultApplicationPolicyInstanceTestCase method correctArtifactTypeForPolicies.

@Test
@Issue("MULE-14289")
@Ignore("MULE-14289: The discovered ArtifactConfigurationProcessor is not compatible with the provided mocks.")
public void correctArtifactTypeForPolicies() throws InitialisationException {
    MuleContextListener muleContextListener = mock(MuleContextListener.class);
    ArgumentCaptor<MuleContext> muleContextCaptor = ArgumentCaptor.forClass(MuleContext.class);
    PolicyTemplate policyTemplate = mock(PolicyTemplate.class, RETURNS_DEEP_STUBS);
    when(policyTemplate.getArtifactClassLoader().getClassLoader()).thenReturn(this.getClass().getClassLoader());
    Application application = mock(Application.class, RETURNS_DEEP_STUBS);
    Registry registry = application.getRegistry();
    doReturn(of(mockContextWithServices())).when(registry).lookupByType(MuleContext.class);
    doReturn(of(mock(ExtensionManager.class))).when(registry).lookupByName(OBJECT_EXTENSION_MANAGER);
    PolicyParametrization parameterization = mock(PolicyParametrization.class, RETURNS_DEEP_STUBS);
    when(parameterization.getId()).thenReturn("policyId");
    DefaultApplicationPolicyInstance applicationPolicyInstance = new DefaultApplicationPolicyInstance(application, policyTemplate, parameterization, mock(ServiceRepository.class), mock(ClassLoaderRepository.class), emptyList(), mock(ExtensionModelLoaderRepository.class), muleContextListener);
    applicationPolicyInstance.initialise();
    verify(muleContextListener).onCreation(muleContextCaptor.capture());
    assertThat(muleContextCaptor.getValue().getArtifactType(), is(POLICY));
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) ClassLoaderRepository(org.mule.runtime.module.artifact.api.classloader.ClassLoaderRepository) ExtensionModelLoaderRepository(org.mule.runtime.module.extension.internal.loader.ExtensionModelLoaderRepository) MuleContextListener(org.mule.runtime.core.api.context.notification.MuleContextListener) Registry(org.mule.runtime.api.artifact.Registry) ServiceRepository(org.mule.runtime.api.service.ServiceRepository) Application(org.mule.runtime.deployment.model.api.application.Application) PolicyTemplate(org.mule.runtime.deployment.model.api.policy.PolicyTemplate) PolicyParametrization(org.mule.runtime.core.api.policy.PolicyParametrization) Ignore(org.junit.Ignore) Issue(io.qameta.allure.Issue) Test(org.junit.Test)

Example 7 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class DefaultApplicationPolicyInstance method initPolicyContext.

private void initPolicyContext() throws InitialisationException {
    ArtifactContextBuilder artifactBuilder = newBuilder().setArtifactType(POLICY).setArtifactProperties(new HashMap<>(parametrization.getParameters())).setArtifactName(parametrization.getId()).setConfigurationFiles(parametrization.getConfig().getAbsolutePath()).setExecutionClassloader(template.getArtifactClassLoader().getClassLoader()).setServiceRepository(serviceRepository).setClassLoaderRepository(classLoaderRepository).setArtifactPlugins(artifactPlugins).setParentArtifact(application).setExtensionManagerFactory(new CompositeArtifactExtensionManagerFactory(application, extensionModelLoaderRepository, artifactPlugins, new DefaultExtensionManagerFactory())).setMuleContextListener(muleContextListener);
    artifactBuilder.withServiceConfigurator(customizationService -> {
        Registry applicationRegistry = application.getRegistry();
        /*
       * OBJECT_POLICY_MANAGER_STATE_HANDLER is not proxied as it doesn't implement any lifecycle interfaces (Startable, Stoppable
       * or Disposable)
       */
        customizationService.overrideDefaultServiceImpl(OBJECT_POLICY_MANAGER_STATE_HANDLER, applicationRegistry.lookupByName(OBJECT_POLICY_MANAGER_STATE_HANDLER).get());
        customizationService.overrideDefaultServiceImpl(OBJECT_LOCK_PROVIDER, createLifecycleFilterProxy(applicationRegistry.lookupByName(OBJECT_LOCK_PROVIDER).get()));
        customizationService.overrideDefaultServiceImpl(BASE_PERSISTENT_OBJECT_STORE_KEY, createLifecycleFilterProxy(applicationRegistry.lookupByName(BASE_PERSISTENT_OBJECT_STORE_KEY).get()));
        customizationService.overrideDefaultServiceImpl(BASE_IN_MEMORY_OBJECT_STORE_KEY, createLifecycleFilterProxy(applicationRegistry.lookupByName(BASE_IN_MEMORY_OBJECT_STORE_KEY).get()));
        customizationService.overrideDefaultServiceImpl(OBJECT_TIME_SUPPLIER, createLifecycleFilterProxy(applicationRegistry.lookupByName(OBJECT_TIME_SUPPLIER).get()));
        applicationRegistry.lookupByName(CLUSTER_MANAGER_ID).ifPresent(muleClusterManager -> customizationService.registerCustomServiceImpl(CLUSTER_MANAGER_ID, createLifecycleFilterProxy(muleClusterManager)));
    });
    try {
        policyContext = artifactBuilder.build();
        enableNotificationListeners(parametrization.getNotificationListeners());
        policyContext.getMuleContext().start();
    } catch (MuleException e) {
        throw new InitialisationException(createStaticMessage("Cannot create artifact context for the policy instance"), e, this);
    }
}
Also used : ArtifactContextBuilder(org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder) CompositeArtifactExtensionManagerFactory(org.mule.runtime.module.deployment.impl.internal.artifact.CompositeArtifactExtensionManagerFactory) HashMap(java.util.HashMap) DefaultExtensionManagerFactory(org.mule.runtime.module.extension.api.manager.DefaultExtensionManagerFactory) Registry(org.mule.runtime.api.artifact.Registry) NotificationListenerRegistry(org.mule.runtime.api.notification.NotificationListenerRegistry) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException)

Example 8 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class SoapOperationExecutor method execute.

/**
 * {@inheritDoc}
 */
@Override
public Publisher<Object> execute(ExecutionContext<OperationModel> context) {
    try {
        String serviceId = context.getParameter(SERVICE_PARAM);
        ForwardingSoapClient connection = (ForwardingSoapClient) connectionResolver.resolve(context).get();
        Map<String, String> customHeaders = connection.getCustomHeaders(serviceId, getOperation(context));
        SoapRequest request = getRequest(context, customHeaders);
        SoapClient soapClient = connection.getSoapClient(serviceId);
        SoapResponse response = connection.getExtensionsClientDispatcher(() -> new ExtensionsClientArgumentResolver(registry, policyManager).resolve(context).get()).map(d -> soapClient.consume(request, d)).orElseGet(() -> soapClient.consume(request));
        return justOrEmpty(response.getAsResult(streamingHelperArgumentResolver.resolve(context).get()));
    } catch (MessageTransformerException | TransformerException e) {
        return error(e);
    } catch (Exception e) {
        return error(soapExceptionEnricher.enrich(e));
    } catch (Throwable t) {
        return error(wrapFatal(t));
    }
}
Also used : HEADERS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.HEADERS_PARAM) Exceptions.wrapFatal(org.mule.runtime.core.api.rx.Exceptions.wrapFatal) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) BindingContext(org.mule.runtime.api.el.BindingContext) MuleExpressionLanguage(org.mule.runtime.api.el.MuleExpressionLanguage) ComponentExecutor(org.mule.runtime.extension.api.runtime.operation.ComponentExecutor) ATTACHMENTS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.ATTACHMENTS_PARAM) HashMap(java.util.HashMap) SoapRequestBuilder(org.mule.runtime.soap.api.message.SoapRequestBuilder) Inject(javax.inject.Inject) ExtensionsClientArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver) ConnectionArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ConnectionArgumentResolver) MESSAGE_GROUP(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.MESSAGE_GROUP) SoapClient(org.mule.runtime.soap.api.client.SoapClient) Map(java.util.Map) SoapResponse(org.mule.runtime.soap.api.message.SoapResponse) Registry(org.mule.runtime.api.artifact.Registry) IOUtils(org.mule.runtime.core.api.util.IOUtils) PolicyManager(org.mule.runtime.core.internal.policy.PolicyManager) Mono.error(reactor.core.publisher.Mono.error) INPUT_STREAM(org.mule.runtime.api.metadata.DataType.INPUT_STREAM) BODY_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.BODY_PARAM) TransformationService(org.mule.runtime.api.transformation.TransformationService) ExecutionContext(org.mule.runtime.extension.api.runtime.operation.ExecutionContext) OPERATION_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.OPERATION_PARAM) DataType(org.mule.runtime.api.metadata.DataType) Publisher(org.reactivestreams.Publisher) SoapRequest(org.mule.runtime.soap.api.message.SoapRequest) Mono.justOrEmpty(reactor.core.publisher.Mono.justOrEmpty) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) SoapAttachment(org.mule.runtime.extension.api.soap.SoapAttachment) SERVICE_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.SERVICE_PARAM) TypedValue(org.mule.runtime.api.metadata.TypedValue) TRANSPORT_HEADERS_PARAM(org.mule.runtime.module.extension.soap.internal.loader.SoapInvokeOperationDeclarer.TRANSPORT_HEADERS_PARAM) StreamingHelperArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.StreamingHelperArgumentResolver) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) ExtensionsClient(org.mule.runtime.extension.api.client.ExtensionsClient) Optional(java.util.Optional) SoapExceptionEnricher(org.mule.runtime.soap.api.exception.error.SoapExceptionEnricher) InputStream(java.io.InputStream) SoapClient(org.mule.runtime.soap.api.client.SoapClient) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException) ForwardingSoapClient(org.mule.runtime.module.extension.soap.internal.runtime.connection.ForwardingSoapClient) SoapRequest(org.mule.runtime.soap.api.message.SoapRequest) SoapResponse(org.mule.runtime.soap.api.message.SoapResponse) ExtensionsClientArgumentResolver(org.mule.runtime.module.extension.internal.runtime.resolver.ExtensionsClientArgumentResolver) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) MessageTransformerException(org.mule.runtime.core.api.transformer.MessageTransformerException) TransformerException(org.mule.runtime.core.api.transformer.TransformerException)

Example 9 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class MuleArtifactContext method createApplicationComponents.

/**
 * Creates te definition for all the objects to be created form the enabled components in the {@code applicationModel}.
 *
 * @param beanFactory the bean factory in which definition must be created.
 * @param applicationModel the artifact application model.
 * @param mustBeRoot if the component must be root to be created.
 * @return an order list of the created bean names. The order must be respected for the creation of the objects.
 */
protected List<String> createApplicationComponents(DefaultListableBeanFactory beanFactory, ApplicationModel applicationModel, boolean mustBeRoot) {
    // This should only be done once at the initial application model creation, called from Spring
    List<Pair<ComponentModel, Optional<String>>> objectProvidersByName = lookObjectProvidersComponentModels(applicationModel);
    List<String> createdComponentModels = new ArrayList<>();
    applicationModel.executeOnEveryMuleComponentTree(cm -> {
        SpringComponentModel componentModel = (SpringComponentModel) cm;
        if (!mustBeRoot || componentModel.isRoot()) {
            if (componentModel.getIdentifier().equals(MULE_IDENTIFIER) || componentModel.getIdentifier().equals(MULE_DOMAIN_IDENTIFIER) || componentModel.getIdentifier().equals(MULE_EE_DOMAIN_IDENTIFIER)) {
                return;
            }
            SpringComponentModel parentComponentModel = componentModel.getParent() != null ? (SpringComponentModel) componentModel.getParent() : (SpringComponentModel) applicationModel.getRootComponentModel();
            if (componentModel.isEnabled()) {
                if (componentModel.getNameAttribute() != null && componentModel.isRoot()) {
                    createdComponentModels.add(componentModel.getNameAttribute());
                }
                beanDefinitionFactory.resolveComponentRecursively(parentComponentModel, componentModel, beanFactory, (resolvedComponentModel, registry) -> {
                    SpringComponentModel resolvedSpringComponentModel = (SpringComponentModel) resolvedComponentModel;
                    if (resolvedComponentModel.isRoot()) {
                        String nameAttribute = resolvedComponentModel.getNameAttribute();
                        if (resolvedComponentModel.getIdentifier().equals(CONFIGURATION_IDENTIFIER)) {
                            nameAttribute = OBJECT_MULE_CONFIGURATION;
                        } else if (nameAttribute == null) {
                            // This may be a configuration that does not requires a name.
                            nameAttribute = uniqueValue(resolvedSpringComponentModel.getBeanDefinition().getBeanClassName());
                        }
                        registry.registerBeanDefinition(nameAttribute, resolvedSpringComponentModel.getBeanDefinition());
                        postProcessBeanDefinition(componentModel, registry, nameAttribute);
                    }
                }, null, componentLocator);
            } else {
                beanDefinitionFactory.resolveComponentRecursively(parentComponentModel, componentModel, beanFactory, null, null, componentLocator);
            }
            componentLocator.addComponentLocation(cm.getComponentLocation());
        }
    });
    this.objectProviders.addAll(objectProvidersByName.stream().map(pair -> (ConfigurableObjectProvider) pair.getFirst().getObjectInstance()).collect(toList()));
    registerObjectFromObjectProviders(beanFactory);
    Set<String> alwaysEnabledComponents = dependencyResolver.resolveAlwaysEnabledComponents().stream().map(dependencyNode -> dependencyNode.getComponentName()).collect(toSet());
    Set<String> objectProviderNames = objectProvidersByName.stream().map(Pair::getSecond).filter(Optional::isPresent).map(Optional::get).collect(toSet());
    // Put object providers first, then always enabled components, then the rest
    createdComponentModels.sort(Comparator.comparing(beanName -> {
        if (objectProviderNames.contains(beanName)) {
            return 1;
        } else if (alwaysEnabledComponents.contains(beanName)) {
            return 2;
        } else {
            return 3;
        }
    }));
    return createdComponentModels;
}
Also used : ClassLoaderResourceProvider(org.mule.runtime.config.internal.dsl.model.ClassLoaderResourceProvider) CORE_PREFIX(org.mule.runtime.internal.dsl.DslConstants.CORE_PREFIX) SimpleConfigAttribute(org.mule.runtime.config.api.dsl.processor.SimpleConfigAttribute) Optional.of(java.util.Optional.of) Thread.currentThread(java.lang.Thread.currentThread) ContextAnnotationAutowireCandidateResolver(org.springframework.context.annotation.ContextAnnotationAutowireCandidateResolver) ByteArrayResource(org.springframework.core.io.ByteArrayResource) MuleInjectorProcessor(org.mule.runtime.config.internal.processor.MuleInjectorProcessor) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) BeanDefinitionFactory(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory) Arrays.asList(java.util.Arrays.asList) Document(org.w3c.dom.Document) Map(java.util.Map) MULE_EE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_EE_DOMAIN_IDENTIFIER) PostRegistrationActionsPostProcessor(org.mule.runtime.config.internal.processor.PostRegistrationActionsPostProcessor) ComponentBuildingDefinitionUtils.registerComponentBuildingDefinitions(org.mule.runtime.config.internal.util.ComponentBuildingDefinitionUtils.registerComponentBuildingDefinitions) Resource(org.springframework.core.io.Resource) ConfigurableObjectProvider(org.mule.runtime.api.ioc.ConfigurableObjectProvider) Set(java.util.Set) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME(org.springframework.context.annotation.AnnotationConfigUtils.CONFIGURATION_ANNOTATION_PROCESSOR_BEAN_NAME) ComponentLocatorCreatePostProcessor(org.mule.runtime.config.internal.processor.ComponentLocatorCreatePostProcessor) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Optional.empty(java.util.Optional.empty) MulePropertyEditorRegistrar(org.mule.runtime.config.internal.editors.MulePropertyEditorRegistrar) BeanDefinitionBuilder.genericBeanDefinition(org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition) Preconditions.checkArgument(org.mule.runtime.api.util.Preconditions.checkArgument) TransformerResolver(org.mule.runtime.core.internal.registry.TransformerResolver) DefaultRegistry(org.mule.runtime.core.internal.registry.DefaultRegistry) ArrayList(java.util.ArrayList) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) MULE_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_IDENTIFIER) ConstructorArgumentValues(org.springframework.beans.factory.config.ConstructorArgumentValues) Component(org.mule.runtime.api.component.Component) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) XmlConfigurationDocumentLoader.noValidationDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader.noValidationDocumentLoader) Registry(org.mule.runtime.api.artifact.Registry) ConfigurationDependencyResolver(org.mule.runtime.config.internal.dsl.model.ConfigurationDependencyResolver) ConfigFile(org.mule.runtime.config.api.dsl.processor.ConfigFile) REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME(org.springframework.context.annotation.AnnotationConfigUtils.REQUIRED_ANNOTATION_PROCESSOR_BEAN_NAME) LaxInstantiationStrategyWrapper(org.mule.runtime.config.internal.util.LaxInstantiationStrategyWrapper) ManagedMap(org.springframework.beans.factory.support.ManagedMap) I18nMessageFactory.createStaticMessage(org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage) ComponentModelHelper.updateAnnotationValue(org.mule.runtime.config.internal.dsl.spring.ComponentModelHelper.updateAnnotationValue) ApplicationModel(org.mule.runtime.config.internal.model.ApplicationModel) IOException(java.io.IOException) BeansException(org.springframework.beans.BeansException) ArtifactConfig(org.mule.runtime.config.api.dsl.processor.ArtifactConfig) GenericBeanDefinition(org.springframework.beans.factory.support.GenericBeanDefinition) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) LifecycleUtils.disposeIfNeeded(org.mule.runtime.core.api.lifecycle.LifecycleUtils.disposeIfNeeded) SPRING_SINGLETON_OBJECT(org.mule.runtime.config.internal.dsl.spring.BeanDefinitionFactory.SPRING_SINGLETON_OBJECT) ComponentIdentifier(org.mule.runtime.api.component.ComponentIdentifier) ResourceProvider(org.mule.runtime.config.api.dsl.model.ResourceProvider) CglibSubclassingInstantiationStrategy(org.springframework.beans.factory.support.CglibSubclassingInstantiationStrategy) LoggerFactory(org.slf4j.LoggerFactory) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory) ManagedList(org.springframework.beans.factory.support.ManagedList) XmlApplicationParser(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser) OBJECT_REGISTRY(org.mule.runtime.core.api.config.MuleProperties.OBJECT_REGISTRY) DslResolvingContext(org.mule.runtime.api.dsl.DslResolvingContext) Preconditions.checkState(org.mule.runtime.api.util.Preconditions.checkState) ServiceRegistry(org.mule.runtime.core.api.registry.ServiceRegistry) Pair(org.mule.runtime.api.util.Pair) DOMAIN(org.mule.runtime.core.api.config.bootstrap.ArtifactType.DOMAIN) Collectors.toSet(java.util.stream.Collectors.toSet) XmlConfigurationDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader) EnvironmentPropertiesConfigurationProvider(org.mule.runtime.config.internal.dsl.model.config.EnvironmentPropertiesConfigurationProvider) MULE_DOMAIN_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.MULE_DOMAIN_IDENTIFIER) POLICY(org.mule.runtime.core.api.config.bootstrap.ArtifactType.POLICY) ImmutableSet(com.google.common.collect.ImmutableSet) IMPORT_ELEMENT(org.mule.runtime.config.api.dsl.CoreDslConstants.IMPORT_ELEMENT) ObjectProvider(org.mule.runtime.api.ioc.ObjectProvider) OBJECT_MULE_CONTEXT(org.mule.runtime.core.api.config.MuleProperties.OBJECT_MULE_CONTEXT) String.format(java.lang.String.format) AbstractRefreshableConfigApplicationContext(org.springframework.context.support.AbstractRefreshableConfigApplicationContext) BeanPostProcessor(org.springframework.beans.factory.config.BeanPostProcessor) List(java.util.List) APP(org.mule.runtime.core.api.config.bootstrap.ArtifactType.APP) AutoIdUtils.uniqueValue(org.mule.runtime.config.internal.parsers.generic.AutoIdUtils.uniqueValue) Optional(java.util.Optional) OBJECT_MULE_CONFIGURATION(org.mule.runtime.core.api.config.MuleProperties.OBJECT_MULE_CONFIGURATION) MuleRegistryHelper(org.mule.runtime.core.internal.registry.MuleRegistryHelper) Converter(org.mule.runtime.core.api.transformer.Converter) ComponentBuildingDefinitionRegistry(org.mule.runtime.config.api.dsl.model.ComponentBuildingDefinitionRegistry) UrlResource(org.springframework.core.io.UrlResource) ConfigurationProperties(org.mule.runtime.api.component.ConfigurationProperties) MuleContext(org.mule.runtime.core.api.MuleContext) ImmutableList(com.google.common.collect.ImmutableList) ArtifactDeclaration(org.mule.runtime.app.declaration.api.ArtifactDeclaration) XmlApplicationServiceRegistry(org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationServiceRegistry) DiscardedOptionalBeanPostProcessor(org.mule.runtime.config.internal.processor.DiscardedOptionalBeanPostProcessor) RuntimeConfigurationException(org.mule.runtime.config.internal.dsl.model.config.RuntimeConfigurationException) ConfigLine(org.mule.runtime.config.api.dsl.processor.ConfigLine) IOUtils(org.mule.runtime.core.api.util.IOUtils) ROOT_CONTAINER_NAME_KEY(org.mule.runtime.api.component.AbstractComponent.ROOT_CONTAINER_NAME_KEY) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Optional.ofNullable(java.util.Optional.ofNullable) PropertyValue(org.springframework.beans.PropertyValue) ConfigResource(org.mule.runtime.core.api.config.ConfigResource) DefaultConfigurationPropertiesResolver(org.mule.runtime.config.internal.dsl.model.config.DefaultConfigurationPropertiesResolver) XmlConfigurationDocumentLoader.schemaValidatingDocumentLoader(org.mule.runtime.config.api.XmlConfigurationDocumentLoader.schemaValidatingDocumentLoader) LifecycleStatePostProcessor(org.mule.runtime.config.internal.processor.LifecycleStatePostProcessor) Collectors.toList(java.util.stream.Collectors.toList) ArtifactType(org.mule.runtime.core.api.config.bootstrap.ArtifactType) ConfigurationClassPostProcessor(org.springframework.context.annotation.ConfigurationClassPostProcessor) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) ComponentModel(org.mule.runtime.config.internal.model.ComponentModel) RequiredAnnotationBeanPostProcessor(org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) CONFIGURATION_IDENTIFIER(org.mule.runtime.config.api.dsl.CoreDslConstants.CONFIGURATION_IDENTIFIER) Comparator(java.util.Comparator) InputStream(java.io.InputStream) Optional(java.util.Optional) SpringComponentModel(org.mule.runtime.config.internal.dsl.model.SpringComponentModel) ArrayList(java.util.ArrayList) Pair(org.mule.runtime.api.util.Pair)

Example 10 with Registry

use of org.mule.runtime.api.artifact.Registry in project mule by mulesoft.

the class FlowProcessingPhaseTestCase method before.

@Before
public void before() {
    when(notificationManager.isNotificationEnabled(any(Class.class))).thenReturn(true);
    when(muleContext.getNotificationManager()).thenReturn(notificationManager);
    phase.setMuleContext(muleContext);
    Registry registry = mock(Registry.class);
    when(registry.lookupByName(any())).thenReturn(of(this.flowConstruct));
    phase.setRegistry(registry);
    ComponentLocation mockComponentLocation = mock(ComponentLocation.class);
    when(mockComponentLocation.getRootContainerName()).thenReturn("root");
    when(messageSource.getLocation()).thenReturn(mockComponentLocation);
    when(mockContext.getTransactionConfig()).thenReturn(empty());
    when(mockContext.getMessageSource()).thenReturn(messageSource);
}
Also used : ComponentLocation(org.mule.runtime.api.component.location.ComponentLocation) Registry(org.mule.runtime.api.artifact.Registry) Before(org.junit.Before)

Aggregations

Registry (org.mule.runtime.api.artifact.Registry)10 Test (org.junit.Test)4 Before (org.junit.Before)3 MuleContext (org.mule.runtime.core.api.MuleContext)3 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Optional (java.util.Optional)2 TypedValue (org.mule.runtime.api.metadata.TypedValue)2 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)2 IOUtils (org.mule.runtime.core.api.util.IOUtils)2 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Issue (io.qameta.allure.Issue)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 Thread.currentThread (java.lang.Thread.currentThread)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1