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));
}
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())));
}
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);
}
});
}
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;
}
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;
}
Aggregations