Spring Application Contexts
This page describes the options available for controlling how Mule creates and manages Spring application contexts for your application.
By default, Mule will combine all resource files into a single
ApplicationContext, whether they are "pure" Spring files or Mule configuration files. For example, the following code will create a single application context consisting of the objects in
spring-beans.xml plus the objects in
|Single Application Context|
Or, in a more abbreviated form:
MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext( new SpringXmlConfigurationBuilder("spring-beans.xml, mule-config.xml")); muleContext.start();
You can instruct Mule to create a separate application context for each Mule configuration file. The following code will create two application contexts, one for each configuration resource:
|Multiple Application Contexts|
If you already have an application context, you can instruct Mule to use it as follows:
|Using an Existing Application Context|
You can designate an existing application context as a parent context for Mule, so that the Mule configuration can refer to and/or override beans in the application context:
|Using an Existing Application Context as Parent|
MuleXmlBuilderContextListener class checks to see if an application context (
WebApplicationContext) has already been created by Spring, and if there is one, Mule uses it as the parent automatically.