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 defaultConfig = (DefaultMuleConfiguration) configuration; |
62 | 0 | defaultConfig.setDefaultResponseTimeout(config.getDefaultResponseTimeout()); |
63 | 0 | defaultConfig.setDefaultTransactionTimeout(config.getDefaultTransactionTimeout()); |
64 | 0 | defaultConfig.setShutdownTimeout(config.getShutdownTimeout()); |
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 setDefaultResponseTimeout(int responseTimeout) |
89 | |
{ |
90 | 0 | config.setDefaultResponseTimeout(responseTimeout); |
91 | 0 | } |
92 | |
|
93 | |
|
94 | |
public void setDefaultTransactionTimeout(int defaultTransactionTimeout) |
95 | |
{ |
96 | 0 | config.setDefaultTransactionTimeout(defaultTransactionTimeout); |
97 | 0 | } |
98 | |
|
99 | |
public void setShutdownTimeout(int shutdownTimeout) |
100 | |
{ |
101 | 0 | config.setShutdownTimeout(shutdownTimeout); |
102 | 0 | } |
103 | |
|
104 | |
} |