Coverage Report - org.mule.routing.inbound.AbstractEventAggregator
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractEventAggregator
58%
11/19
75%
3/4
2
 
 1  
 /*
 2  
  * $Id: AbstractEventAggregator.java 11567 2008-04-11 13:08:05Z 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.inbound;
 12  
 
 13  
 import org.mule.DefaultMuleEvent;
 14  
 import org.mule.api.MessagingException;
 15  
 import org.mule.api.MuleEvent;
 16  
 import org.mule.api.MuleMessage;
 17  
 import org.mule.api.lifecycle.InitialisationException;
 18  
 import org.mule.routing.EventCorrelator;
 19  
 import org.mule.routing.EventCorrelatorCallback;
 20  
 
 21  
 import javax.resource.spi.work.WorkException;
 22  
 
 23  
 /**
 24  
  * <code>AbstractEventAggregator</code> will aggregate a set of messages into a
 25  
  * single message.
 26  
  */
 27  
 
 28  2
 public abstract class AbstractEventAggregator extends SelectiveConsumer
 29  
 {
 30  
     private EventCorrelator eventCorrelator;
 31  
 
 32  2
     private int timeout = 0;
 33  
 
 34  
     //@Override
 35  
     public void initialise() throws InitialisationException
 36  
     {
 37  2
         eventCorrelator = new EventCorrelator(getCorrelatorCallback(), getMessageInfoMapping(), muleContext);
 38  2
         if(timeout != 0)
 39  
         {
 40  0
             eventCorrelator.setTimeout(timeout);
 41  
             try
 42  
             {
 43  0
                 eventCorrelator.enableTimeoutMonitor();
 44  
             }
 45  0
             catch (WorkException e)
 46  
             {
 47  0
                 throw new InitialisationException(e, this);
 48  0
             }
 49  
         }
 50  2
         super.initialise();
 51  2
     }
 52  
 
 53  
     protected abstract EventCorrelatorCallback getCorrelatorCallback();
 54  
 
 55  
 
 56  
     //@Override
 57  
     public MuleEvent[] process(MuleEvent event) throws MessagingException
 58  
     {
 59  6
         MuleMessage msg = eventCorrelator.process(event);
 60  6
         if(msg==null)
 61  
         {
 62  4
             return null;
 63  
         }
 64  2
         MuleEvent[] result = new MuleEvent[]{new DefaultMuleEvent(msg, event)};
 65  2
         return result;
 66  
     }
 67  
     
 68  
     public int getTimeout()
 69  
     {
 70  0
         return timeout;
 71  
     }
 72  
 
 73  
     public void setTimeout(int timeout)
 74  
     {
 75  0
         this.timeout = timeout;
 76  0
     }
 77  
 }