1 10 11 package org.mule.routing.response; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.mule.config.MuleConfiguration; 16 import org.mule.config.MuleProperties; 17 import org.mule.util.properties.PropertyExtractor; 18 import org.mule.management.stats.RouterStatistics; 19 import org.mule.routing.CorrelationPropertiesExtractor; 20 import org.mule.umo.UMOMessage; 21 import org.mule.umo.routing.UMOResponseRouter; 22 import org.mule.util.ClassUtils; 23 24 27 28 public abstract class AbstractResponseRouter implements UMOResponseRouter 29 { 30 protected transient final Log logger = LogFactory.getLog(getClass()); 31 32 private RouterStatistics routerStatistics; 33 34 private int timeout = MuleConfiguration.DEFAULT_TIMEOUT; 35 36 protected PropertyExtractor correlationExtractor = new CorrelationPropertiesExtractor(); 37 38 public RouterStatistics getRouterStatistics() 39 { 40 return routerStatistics; 41 } 42 43 public void setRouterStatistics(RouterStatistics routerStatistics) 44 { 45 this.routerStatistics = routerStatistics; 46 } 47 48 public PropertyExtractor getCorrelationExtractor() 49 { 50 return correlationExtractor; 51 } 52 53 public void setCorrelationExtractor(PropertyExtractor correlationExtractor) 54 { 55 this.correlationExtractor = correlationExtractor; 56 } 57 58 63 public void setPropertyExtractorAsString(String className) 64 { 65 try 66 { 67 this.correlationExtractor = (PropertyExtractor)ClassUtils.instanciateClass(className, null, 68 getClass()); 69 } 70 catch (Exception ex) 71 { 72 throw new IllegalArgumentException ("Couldn't instanciate property extractor class " + className); 73 } 74 } 75 76 public int getTimeout() 77 { 78 return timeout; 79 } 80 81 public void setTimeout(int timeout) 82 { 83 this.timeout = timeout; 84 } 85 86 94 protected Object getReplyAggregateIdentifier(UMOMessage message) 95 { 96 return correlationExtractor.getProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY, message); 97 } 98 99 109 protected Object getCallResponseAggregateIdentifier(UMOMessage message) 110 { 111 return correlationExtractor.getProperty(MuleProperties.MULE_MESSAGE_ID_PROPERTY, message); 112 } 113 114 } 115 | Popular Tags |