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