Coverage Report - org.mule.routing.correlation.CorrelationPropertiesExpressionEvaluator
 
Classes in this File Line Coverage Branch Coverage Complexity
CorrelationPropertiesExpressionEvaluator
0%
0/17
0%
0/10
0
 
 1  
 /*
 2  
  * $Id: CorrelationPropertiesExpressionEvaluator.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.correlation;
 12  
 
 13  
 import org.mule.api.MuleMessage;
 14  
 import org.mule.api.config.MuleProperties;
 15  
 import org.mule.expression.MessageHeaderExpressionEvaluator;
 16  
 
 17  
 /**
 18  
  * <code>CorrelationPropertiesExpressionEvaluator</code> is a default implementation used for
 19  
  * getting the Correlation information from a message. This object is only used when
 20  
  * getting a specific property to be set on the message. When reading the property
 21  
  * the getProperty(...) or the direct property accessor will be used i.e.
 22  
  * message.getCorrelationId() or
 23  
  * message.getProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY)
 24  
  */
 25  0
 public class CorrelationPropertiesExpressionEvaluator extends MessageHeaderExpressionEvaluator
 26  
 {
 27  
     @Override
 28  
     public final Object evaluate(String name, MuleMessage message)
 29  
     {
 30  0
         Object result = null;
 31  0
         if (message != null)
 32  
         {
 33  0
             if (MuleProperties.MULE_CORRELATION_ID_PROPERTY.equals(name))
 34  
             {
 35  0
                 result = getCorrelationId(message);
 36  
             }
 37  0
             else if (MuleProperties.MULE_MESSAGE_ID_PROPERTY.equals(name))
 38  
             {
 39  0
                 result = getMessageId(message);
 40  
             }
 41  
             else
 42  
             {
 43  0
                 throw new IllegalArgumentException("Property name: " + name
 44  
                                                    + " not recognised by the Correlation Property Extractor");
 45  
             }
 46  0
             if (result == null)
 47  
             {
 48  0
                 throw new IllegalArgumentException(
 49  
                     "Property Extractor cannot return a null value. Extractor is: " + getClass().getName());
 50  
             }
 51  
         }
 52  
         else
 53  
         {
 54  0
             return super.evaluate(name, message);
 55  
         }
 56  0
         return result;
 57  
     }
 58  
 
 59  
     public String getMessageId(MuleMessage message)
 60  
     {
 61  0
         return message.getUniqueId();
 62  
     }
 63  
 
 64  
     public String getCorrelationId(MuleMessage message)
 65  
     {
 66  0
         String id = message.getCorrelationId();
 67  0
         if (id == null)
 68  
         {
 69  0
             id = message.getUniqueId();
 70  
         }
 71  0
         return id;
 72  
     }
 73  
 }