Coverage Report - org.mule.routing.response.AbstractResponseRouter
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractResponseRouter
0%
0/21
N/A
1.222
 
 1  
 /*
 2  
  * $Id: AbstractResponseRouter.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  
  * <code>AbstractResponseRouter</code> is a base class for all Response Routers
 27  
  */
 28  
 
 29  0
 public abstract class AbstractResponseRouter extends AbstractRouter implements UMOResponseRouter
 30  
 {
 31  0
     protected final Log logger = LogFactory.getLog(getClass());
 32  
 
 33  0
     private int timeout = MuleConfiguration.DEFAULT_TIMEOUT;
 34  
 
 35  0
     private boolean failOnTimeout = true;
 36  
 
 37  0
     protected PropertyExtractor correlationExtractor = new CorrelationPropertiesExtractor();
 38  
 
 39  
     public PropertyExtractor getCorrelationExtractor()
 40  
     {
 41  0
         return correlationExtractor;
 42  
     }
 43  
 
 44  
     public void setCorrelationExtractor(PropertyExtractor correlationExtractor)
 45  
     {
 46  0
         this.correlationExtractor = correlationExtractor;
 47  0
     }
 48  
 
 49  
     /**
 50  
      * A digester callback to configure a custom correlation extractor.
 51  
      * 
 52  
      * @param className correlation extractor fully qualified class name
 53  
      */
 54  
     public void setPropertyExtractorAsString(String className)
 55  
     {
 56  
         try
 57  
         {
 58  0
             this.correlationExtractor = (PropertyExtractor) ClassUtils.instanciateClass(className, null,
 59  
                 getClass());
 60  
         }
 61  0
         catch (Exception ex)
 62  
         {
 63  0
             throw (IllegalArgumentException) new IllegalArgumentException(
 64  
                 "Couldn't instanciate property extractor class " + className
 65  
                 ).initCause(ex);
 66  0
         }
 67  0
     }
 68  
 
 69  
     public int getTimeout()
 70  
     {
 71  0
         return timeout;
 72  
     }
 73  
 
 74  
     public void setTimeout(int timeout)
 75  
     {
 76  0
         this.timeout = timeout;
 77  0
     }
 78  
 
 79  
     /**
 80  
      * Extracts a 'Correlation Id' from a reply message. The correlation Id does not
 81  
      * have to be the Message Correlation Id. It can be extracted from the message
 82  
      * payload if desired.
 83  
      * 
 84  
      * @param message a received reply message
 85  
      * @return the correlation Id for this message
 86  
      */
 87  
     protected Object getReplyAggregateIdentifier(UMOMessage message)
 88  
     {
 89  0
         return correlationExtractor.getProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY, message);
 90  
     }
 91  
 
 92  
     /**
 93  
      * Extracts a Group identifier from the current event. When an event is received
 94  
      * with a group identifier not registered with this router, a new group is
 95  
      * created. The id returned here can be a correlationId or some custom
 96  
      * aggregation Id. This implementation uses the Unique Message Id of the
 97  
      * UMOMessage being returned a
 98  
      * 
 99  
      * @param message A response messages received on the response router endpoint
 100  
      * @return an aggregation Id for this event
 101  
      */
 102  
     protected Object getCallResponseAggregateIdentifier(UMOMessage message)
 103  
     {
 104  0
         return correlationExtractor.getProperty(MuleProperties.MULE_MESSAGE_ID_PROPERTY, message);
 105  
     }
 106  
 
 107  
 
 108  
     public boolean isFailOnTimeout()
 109  
     {
 110  0
         return failOnTimeout;
 111  
     }
 112  
 
 113  
     public void setFailOnTimeout(boolean failOnTimeout)
 114  
     {
 115  0
         this.failOnTimeout = failOnTimeout;
 116  0
     }
 117  
 }