Coverage Report - org.mule.routing.response.ResponseCorrelationAggregator
 
Classes in this File Line Coverage Branch Coverage Complexity
ResponseCorrelationAggregator
0%
0/10
0%
0/3
2.5
 
 1  
 /*
 2  
  * $Id: ResponseCorrelationAggregator.java 7976 2007-08-21 14:26:13Z 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.routing.inbound.EventGroup;
 14  
 import org.mule.umo.UMOEvent;
 15  
 
 16  
 /**
 17  
  * <code>ResponseCorrelationAggregator</code> Correlates one or more events on a
 18  
  * response flow using the Correlation Id to group events.
 19  
  */
 20  
 
 21  0
 public abstract class ResponseCorrelationAggregator extends AbstractResponseAggregator
 22  
 {
 23  
     /**
 24  
      * Determines if the event group is ready to be aggregated. if the group is ready
 25  
      * to be aggregated (this is entirely up to the application. it could be
 26  
      * determined by volume, last modified time or some oher criteria based on the
 27  
      * last event received)
 28  
      * 
 29  
      * @param events
 30  
      * @return true if the event group is ready of aggregation
 31  
      */
 32  
     protected boolean shouldAggregateEvents(EventGroup events)
 33  
     {
 34  0
         int expected = events.expectedSize();
 35  0
         int current = events.size();
 36  
 
 37  0
         if (expected == -1)
 38  
         {
 39  0
             logger.warn("Correlation Group Size not set, but CorrelationAggregator is being used.  Message is being forwarded");
 40  0
             return true;
 41  
         }
 42  
 
 43  0
         if (logger.isDebugEnabled())
 44  
         {
 45  0
             logger.debug("Correlation size is " + expected + ", current event group size is " + current
 46  
                          + " for correlation group " + events.getGroupId());
 47  
         }
 48  
 
 49  0
         return expected == current;
 50  
     }
 51  
 
 52  
     /**
 53  
      * Creates the event group with a specific correlation size based on the Mule
 54  
      * Correlation support
 55  
      * 
 56  
      * @param id The group id
 57  
      * @param event the current event
 58  
      * @return a new event group of a fixed size
 59  
      */
 60  
     // @Override
 61  
     protected EventGroup createEventGroup(UMOEvent event, Object id)
 62  
     {
 63  0
         return new EventGroup(id, event.getMessage().getCorrelationGroupSize());
 64  
     }
 65  
 
 66  
 }