1
2
3
4
5
6
7
8
9
10
11 package org.mule.routing.response;
12
13 import org.mule.config.MuleConfiguration;
14 import org.mule.config.MuleProperties;
15 import org.mule.routing.AbstractRouter;
16 import org.mule.routing.CorrelationPropertiesExtractor;
17 import org.mule.umo.UMOMessage;
18 import org.mule.umo.routing.UMOResponseRouter;
19 import org.mule.util.ClassUtils;
20 import org.mule.util.properties.PropertyExtractor;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25
26
27
28
29 public abstract class AbstractResponseRouter extends AbstractRouter implements UMOResponseRouter
30 {
31 protected final Log logger = LogFactory.getLog(getClass());
32
33 private int timeout = MuleConfiguration.DEFAULT_TIMEOUT;
34
35 private boolean failOnTimeout = true;
36
37 protected PropertyExtractor correlationExtractor = new CorrelationPropertiesExtractor();
38
39 public PropertyExtractor getCorrelationExtractor()
40 {
41 return correlationExtractor;
42 }
43
44 public void setCorrelationExtractor(PropertyExtractor correlationExtractor)
45 {
46 this.correlationExtractor = correlationExtractor;
47 }
48
49
50
51
52
53
54 public void setPropertyExtractorAsString(String className)
55 {
56 try
57 {
58 this.correlationExtractor = (PropertyExtractor) ClassUtils.instanciateClass(className, null,
59 getClass());
60 }
61 catch (Exception ex)
62 {
63 throw (IllegalArgumentException) new IllegalArgumentException(
64 "Couldn't instanciate property extractor class " + className
65 ).initCause(ex);
66 }
67 }
68
69 public int getTimeout()
70 {
71 return timeout;
72 }
73
74 public void setTimeout(int timeout)
75 {
76 this.timeout = timeout;
77 }
78
79
80
81
82
83
84
85
86
87 protected Object getReplyAggregateIdentifier(UMOMessage message)
88 {
89 return correlationExtractor.getProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY, message);
90 }
91
92
93
94
95
96
97
98
99
100
101
102 protected Object getCallResponseAggregateIdentifier(UMOMessage message)
103 {
104 return correlationExtractor.getProperty(MuleProperties.MULE_MESSAGE_ID_PROPERTY, message);
105 }
106
107
108 public boolean isFailOnTimeout()
109 {
110 return failOnTimeout;
111 }
112
113 public void setFailOnTimeout(boolean failOnTimeout)
114 {
115 this.failOnTimeout = failOnTimeout;
116 }
117 }