MuleContext context = new DefaultMuleContextFactory().createMuleContext(new ScriptConfigurationBuilder("mule-config.groovy"));
context.start();
About Configuration Builders
Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version. |
The configuration builder is responsible for creating the configuration that’s used at run time from the configuration files you provide. Mule provides two standard configuration builders, or you can create your own.
SpringXmlConfigurationBuilder
The default configuration builder used to configure Mule is the SpringXmlConfigurationBuilder. This configuration builder uses Spring to configure Mule based on one or more XML files leveraging custom Mule namespaces. For more information, see About the XML Configuration File.
ScriptConfigurationBuilder
This configuration builder allows a JSR-223 compliant script engine such as Groovy or Jython to configure Mule. For more information, see Scripting Module Reference.
Custom Configuration Builders
You can easily create your own custom configuration builder by implementing the ConfigurationBuilder interface, which has a method configure
. Typically, you call configure(MuleContext muleContext.getRegistry())
to get access to Mule’s internal registry, which contains the configuration information, and to register objects and other elements.
In most cases, you will want to inherit from the class
AbstractResourceConfigurationBuilder
, which will make any configuration files specified on the command line available in an instance variable called configResources
.
Specifying the Configuration Builder
AutoConfigurationBuilder is the default configuration builder. If you want to use another configuration builder, you can specify it in the deployment descriptor of an application.
You can also specify the configuration builder as a parameter to the MuleContextFactory when starting Mule programatically: