1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring; |
12 | |
|
13 | |
import org.mule.api.MuleContext; |
14 | |
import org.mule.api.config.ConfigurationException; |
15 | |
import org.mule.api.config.MuleConfiguration; |
16 | |
import org.mule.api.context.MuleContextAware; |
17 | |
import org.mule.config.DefaultMuleConfiguration; |
18 | |
import org.mule.config.i18n.MessageFactory; |
19 | |
|
20 | |
import org.apache.commons.logging.Log; |
21 | |
import org.apache.commons.logging.LogFactory; |
22 | |
import org.springframework.beans.factory.SmartFactoryBean; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 0 | public class MuleConfigurationConfigurator implements MuleContextAware, SmartFactoryBean |
32 | |
{ |
33 | |
private MuleContext muleContext; |
34 | |
|
35 | |
|
36 | |
|
37 | 0 | private DefaultMuleConfiguration config = new DefaultMuleConfiguration(); |
38 | |
|
39 | 0 | protected transient Log logger = LogFactory.getLog(MuleConfigurationConfigurator.class); |
40 | |
|
41 | |
public void setMuleContext(MuleContext context) |
42 | |
{ |
43 | 0 | this.muleContext = context; |
44 | 0 | } |
45 | |
|
46 | |
public boolean isEagerInit() |
47 | |
{ |
48 | 0 | return true; |
49 | |
} |
50 | |
|
51 | |
public boolean isPrototype() |
52 | |
{ |
53 | 0 | return false; |
54 | |
} |
55 | |
|
56 | |
public Object getObject() throws Exception |
57 | |
{ |
58 | 0 | MuleConfiguration configuration = muleContext.getConfiguration(); |
59 | 0 | if (configuration instanceof DefaultMuleConfiguration) |
60 | |
{ |
61 | 0 | ((DefaultMuleConfiguration) configuration).setDefaultSynchronousEndpoints(config.isDefaultSynchronousEndpoints()); |
62 | 0 | ((DefaultMuleConfiguration) configuration).setDefaultSynchronousEventTimeout(config.getDefaultSynchronousEventTimeout()); |
63 | 0 | ((DefaultMuleConfiguration) configuration).setDefaultRemoteSync(config.isDefaultRemoteSync()); |
64 | 0 | ((DefaultMuleConfiguration) configuration).setDefaultTransactionTimeout(config.getDefaultTransactionTimeout()); |
65 | 0 | return configuration; |
66 | |
} |
67 | |
else |
68 | |
{ |
69 | 0 | throw new ConfigurationException(MessageFactory.createStaticMessage("Unable to set properties on read-only MuleConfiguration: " + configuration.getClass())); |
70 | |
} |
71 | |
} |
72 | |
|
73 | |
public Class getObjectType() |
74 | |
{ |
75 | 0 | return MuleConfiguration.class; |
76 | |
} |
77 | |
|
78 | |
public boolean isSingleton() |
79 | |
{ |
80 | 0 | return true; |
81 | |
} |
82 | |
|
83 | |
public void setDefaultSynchronousEndpoints(boolean synchronous) |
84 | |
{ |
85 | 0 | config.setDefaultSynchronousEndpoints(synchronous); |
86 | 0 | } |
87 | |
|
88 | |
public void setDefaultSynchronousEventTimeout(int synchronousEventTimeout) |
89 | |
{ |
90 | 0 | config.setDefaultSynchronousEventTimeout(synchronousEventTimeout); |
91 | 0 | } |
92 | |
|
93 | |
public void setDefaultRemoteSync(boolean remoteSync) |
94 | |
{ |
95 | 0 | config.setDefaultRemoteSync(remoteSync); |
96 | 0 | } |
97 | |
|
98 | |
public void setDefaultTransactionTimeout(int defaultTransactionTimeout) |
99 | |
{ |
100 | 0 | config.setDefaultTransactionTimeout(defaultTransactionTimeout); |
101 | 0 | } |
102 | |
} |