Search in sources :

Example 6 with ExtensionManager

use of org.mule.runtime.core.api.extension.ExtensionManager in project mule by mulesoft.

the class CompositeArtifactExtensionManagerFactoryTestCase method createsCompositeExtensionManager.

@Test
public void createsCompositeExtensionManager() throws Exception {
    Application application = mock(Application.class, RETURNS_DEEP_STUBS);
    ExtensionManager applicationExtensionManager = mock(ExtensionManager.class);
    when(application.getRegistry().lookupByName(MuleProperties.OBJECT_EXTENSION_MANAGER)).thenReturn(of(applicationExtensionManager));
    ExtensionModelLoaderRepository extensionModelLoaderRepository = mock(ExtensionModelLoaderRepository.class);
    ExtensionManagerFactory extensionManagerFactory = mock(ExtensionManagerFactory.class);
    CompositeArtifactExtensionManagerFactory factory = new CompositeArtifactExtensionManagerFactory(application, extensionModelLoaderRepository, emptyList(), extensionManagerFactory);
    ExtensionManager policyExtensionManager = mock(ExtensionManager.class);
    MuleContext muleContext = mock(MuleContext.class);
    when(extensionManagerFactory.create(muleContext)).thenReturn(policyExtensionManager);
    ExtensionManager extensionManager = factory.create(muleContext);
    assertThat(extensionManager, instanceOf(CompositeArtifactExtensionManager.class));
    CompositeArtifactExtensionManager compositeArtifactExtensionManager = (CompositeArtifactExtensionManager) extensionManager;
    assertThat(compositeArtifactExtensionManager.getParentExtensionManager(), equalTo(applicationExtensionManager));
    assertThat(compositeArtifactExtensionManager.getChildExtensionManager(), equalTo(policyExtensionManager));
}
Also used : MuleContext(org.mule.runtime.core.api.MuleContext) CompositeArtifactExtensionManager(org.mule.runtime.module.deployment.impl.internal.policy.CompositeArtifactExtensionManager) ExtensionModelLoaderRepository(org.mule.runtime.module.extension.internal.loader.ExtensionModelLoaderRepository) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) CompositeArtifactExtensionManager(org.mule.runtime.module.deployment.impl.internal.policy.CompositeArtifactExtensionManager) ExtensionManagerFactory(org.mule.runtime.module.extension.api.manager.ExtensionManagerFactory) Application(org.mule.runtime.deployment.model.api.application.Application) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Example 7 with ExtensionManager

use of org.mule.runtime.core.api.extension.ExtensionManager in project mule by mulesoft.

the class OperationExecutionTestCase method getInjectedDependency.

@Test
public void getInjectedDependency() throws Exception {
    ExtensionManager extensionManager = (ExtensionManager) runFlow("injectedExtensionManager").getMessage().getPayload().getValue();
    assertThat(extensionManager, is(sameInstance(muleContext.getExtensionManager())));
}
Also used : ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) Test(org.junit.Test)

Example 8 with ExtensionManager

use of org.mule.runtime.core.api.extension.ExtensionManager in project mule by mulesoft.

the class ComponentMessageProcessorBuilder method build.

public P build() {
    return withContextClassLoader(getClassLoader(extensionModel), () -> {
        try {
            final ExtensionManager extensionManager = muleContext.getExtensionManager();
            final ResolverSet operationArguments = getArgumentsResolverSet();
            P processor = createMessageProcessor(extensionManager, operationArguments);
            // TODO: MULE-5002 this should not be necessary but lifecycle issues when injecting message processors automatically
            muleContext.getInjector().inject(processor);
            return processor;
        } catch (Exception e) {
            throw new MuleRuntimeException(e);
        }
    });
}
Also used : ResolverSet(org.mule.runtime.module.extension.internal.runtime.resolver.ResolverSet) ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) ConfigurationException(org.mule.runtime.core.api.config.ConfigurationException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 9 with ExtensionManager

use of org.mule.runtime.core.api.extension.ExtensionManager in project mule by mulesoft.

the class IsolatedClassLoaderExtensionsManagerConfigurationBuilder method createExtensionManager.

/**
 * Creates an {@link ExtensionManager} to be used for registering the extensions.
 *
 * @param muleContext a {@link MuleContext} needed for creating the manager
 * @return an {@link ExtensionManager}
 * @throws InitialisationException if an error occurs while initializing the manager.
 */
private ExtensionManager createExtensionManager(final MuleContext muleContext) throws InitialisationException {
    if (muleContext.getExtensionManager() != null) {
        return muleContext.getExtensionManager();
    }
    ExtensionManager extensionManager = extensionManagerFactory.create(muleContext);
    muleContext.setExtensionManager(extensionManager);
    return extensionManager;
}
Also used : ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager)

Example 10 with ExtensionManager

use of org.mule.runtime.core.api.extension.ExtensionManager in project mule by mulesoft.

the class DefaultExtensionManagerFactory method create.

/**
 * {@inheritDoc}
 */
@Override
public ExtensionManager create(MuleContext muleContext) {
    ExtensionManager extensionManager = new DefaultExtensionManager();
    muleContext.setExtensionManager(extensionManager);
    try {
        initialiseIfNeeded(extensionManager, false, muleContext);
    } catch (InitialisationException e) {
        throw new MuleRuntimeException(createStaticMessage("Could not initialise extension manager"), e);
    }
    return extensionManager;
}
Also used : ExtensionManager(org.mule.runtime.core.api.extension.ExtensionManager) DefaultExtensionManager(org.mule.runtime.module.extension.internal.manager.DefaultExtensionManager) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) DefaultExtensionManager(org.mule.runtime.module.extension.internal.manager.DefaultExtensionManager)

Aggregations

ExtensionManager (org.mule.runtime.core.api.extension.ExtensionManager)11 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)2 MuleContext (org.mule.runtime.core.api.MuleContext)2 Application (org.mule.runtime.deployment.model.api.application.Application)2 CompositeArtifactExtensionManager (org.mule.runtime.module.deployment.impl.internal.policy.CompositeArtifactExtensionManager)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 MuleArtifactFunctionalTestCase (org.mule.functional.junit4.MuleArtifactFunctionalTestCase)1 DslResolvingContext (org.mule.runtime.api.dsl.DslResolvingContext)1 DslResolvingContext.getDefault (org.mule.runtime.api.dsl.DslResolvingContext.getDefault)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 Pair (org.mule.runtime.api.util.Pair)1 XmlApplicationParser (org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationParser)1 XmlApplicationServiceRegistry (org.mule.runtime.config.api.dsl.processor.xml.XmlApplicationServiceRegistry)1