1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.extras.spring.config; |
12 | |
|
13 | |
import java.io.IOException; |
14 | |
|
15 | |
import org.springframework.beans.BeansException; |
16 | |
import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
17 | |
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; |
18 | |
import org.springframework.context.support.AbstractXmlApplicationContext; |
19 | |
import org.springframework.core.io.Resource; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public class MuleApplicationContext extends AbstractXmlApplicationContext |
29 | |
{ |
30 | |
private final Resource[] configResources; |
31 | |
private final String[] configLocations; |
32 | |
|
33 | |
public MuleApplicationContext(Resource[] configResources) |
34 | |
{ |
35 | 0 | this(configResources, true); |
36 | 0 | } |
37 | |
|
38 | |
public MuleApplicationContext(Resource[] configResources, boolean refresh) throws BeansException |
39 | 0 | { |
40 | 0 | this.configResources = configResources; |
41 | 0 | this.configLocations = null; |
42 | 0 | if (refresh) |
43 | |
{ |
44 | 0 | refresh(); |
45 | |
} |
46 | 0 | } |
47 | |
|
48 | |
public MuleApplicationContext(String[] configLocations) |
49 | |
{ |
50 | 0 | this(configLocations, true); |
51 | 0 | } |
52 | |
|
53 | |
public MuleApplicationContext(String[] configLocations, boolean refresh) throws BeansException |
54 | 0 | { |
55 | 0 | this.configLocations = configLocations; |
56 | 0 | this.configResources = null; |
57 | 0 | if (refresh) |
58 | |
{ |
59 | 0 | refresh(); |
60 | |
} |
61 | 0 | } |
62 | |
|
63 | |
|
64 | |
protected Resource[] getConfigResources() |
65 | |
{ |
66 | 0 | return configResources; |
67 | |
} |
68 | |
|
69 | |
|
70 | |
protected String[] getConfigLocations() |
71 | |
{ |
72 | 0 | return configLocations; |
73 | |
} |
74 | |
|
75 | |
|
76 | |
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException |
77 | |
{ |
78 | 0 | XmlBeanDefinitionReader beanDefinitionReader = new MuleBeanDefinitionReader(beanFactory, |
79 | |
configResources != null ? configResources.length : configLocations.length); |
80 | |
|
81 | 0 | initBeanDefinitionReader(beanDefinitionReader); |
82 | 0 | loadBeanDefinitions(beanDefinitionReader); |
83 | 0 | } |
84 | |
} |