use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class FlowRefFactoryBean method getReferencedFlow.
protected Processor getReferencedFlow(String name, FlowRefMessageProcessor flowRefMessageProcessor) throws MuleException {
if (name == null) {
throw new RoutePathNotFoundException(createStaticMessage("flow-ref name expression returned 'null'"), flowRefMessageProcessor);
}
Component referencedFlow = getReferencedProcessor(name);
if (referencedFlow == null) {
throw new RoutePathNotFoundException(createStaticMessage("No flow/sub-flow with name '%s' found", name), flowRefMessageProcessor);
}
// for subflows, we create a new one so it must be initialised manually
if (!(referencedFlow instanceof Flow)) {
if (referencedFlow instanceof SubflowMessageProcessorChainBuilder) {
MessageProcessorChainBuilder chainBuilder = (MessageProcessorChainBuilder) referencedFlow;
locator.find(flowRefMessageProcessor.getRootContainerLocation()).filter(c -> c instanceof Flow).map(c -> (Flow) c).ifPresent(f -> chainBuilder.setProcessingStrategy(f.getProcessingStrategy()));
referencedFlow = chainBuilder.build();
}
initialiseIfNeeded(referencedFlow, muleContext);
Map<QName, Object> annotations = new HashMap<>(referencedFlow.getAnnotations());
annotations.put(ROOT_CONTAINER_NAME_KEY, getRootContainerLocation().toString());
referencedFlow.setAnnotations(annotations);
startIfNeeded(referencedFlow);
}
return (Processor) referencedFlow;
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class DomainContextBuilder method build.
public MuleContext build() throws Exception {
List<ConfigurationBuilder> builders = new ArrayList<>(3);
ConfigurationBuilder cfgBuilder = getDomainBuilder(domainConfig);
builders.add(cfgBuilder);
addBuilders(builders);
DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
MuleContext domainContext = muleContextFactory.createMuleContext(builders, muleContextBuilder);
domainContext.start();
return domainContext;
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class DomainFunctionalTestCase method setUpMuleContexts.
@Before
public void setUpMuleContexts() throws Exception {
final DomainContextBuilder domainContextBuilder = new DomainContextBuilder() {
@Override
protected void addBuilders(List<ConfigurationBuilder> builders) {
super.addBuilders(builders);
builders.add(new SimpleConfigurationBuilder(getDomainStartUpRegistryObjects()));
if (getBuilder() != null) {
builders.add(getBuilder());
}
}
}.setDomainConfig(getDomainConfigs());
domainContext = domainContextBuilder.build();
domainInfrastructure = new ArtifactInstanceInfrastructure();
domainContext.getInjector().inject(domainInfrastructure);
ApplicationConfig[] applicationConfigs = getConfigResources();
for (ApplicationConfig applicationConfig : applicationConfigs) {
MuleContext muleContext = createAppMuleContext(applicationConfig.applicationResources);
muleContexts.put(applicationConfig.applicationName, muleContext);
ArtifactInstanceInfrastructure appInfrasturcture = new ArtifactInstanceInfrastructure();
muleContext.getInjector().inject(appInfrasturcture);
applsInfrastructures.put(applicationConfig.applicationName, appInfrasturcture);
}
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class DomainFunctionalTestCase method disposeMuleContexts.
@After
public void disposeMuleContexts() {
for (MuleContext muleContext : muleContexts.values()) {
try {
disposeMuleContext(muleContext);
} catch (Exception e) {
// Nothing to do
}
}
muleContexts.clear();
applsInfrastructures.clear();
disposeMuleContext(domainContext);
domainInfrastructure = null;
}
use of org.mule.runtime.core.api.MuleContext in project mule by mulesoft.
the class ExtensionFunctionalTestCase method addBuilders.
/**
* Adds a {@link ConfigurationBuilder} that sets the {@link #extensionManager} into the {@link #muleContext}. This
* {@link ConfigurationBuilder} is set as the first element of the {@code builders} {@link List}
*
* @param builders the list of {@link ConfigurationBuilder}s that will be used to initialise the {@link #muleContext}
*/
@Override
protected // TODO - MULE-11119: Make final again once we can add the HTTP service injection as the scehduler's is
void addBuilders(List<ConfigurationBuilder> builders) {
super.addBuilders(builders);
builders.add(0, new AbstractConfigurationBuilder() {
@Override
protected void doConfigure(MuleContext muleContext) throws Exception {
createExtensionsManager(muleContext);
}
});
}
Aggregations