Coverage Report - org.mule.lifecycle.processor.ProcessIfStartedWaitIfPausedMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ProcessIfStartedWaitIfPausedMessageProcessor
0%
0/13
0%
0/10
0
 
 1  
 /*
 2  
  * $Id: ProcessIfStartedWaitIfPausedMessageProcessor.java 20320 2010-11-24 15:03:31Z dfeist $
 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.lifecycle.processor;
 12  
 
 13  
 import org.mule.api.MessagingException;
 14  
 import org.mule.api.MuleEvent;
 15  
 import org.mule.api.MuleException;
 16  
 import org.mule.api.lifecycle.LifecycleState;
 17  
 import org.mule.api.lifecycle.Startable;
 18  
 import org.mule.config.i18n.CoreMessages;
 19  
 import org.mule.service.Pausable;
 20  
 
 21  
 public class ProcessIfStartedWaitIfPausedMessageProcessor extends ProcessIfStartedMessageProcessor
 22  
 {
 23  
 
 24  
     public ProcessIfStartedWaitIfPausedMessageProcessor(Startable startable, LifecycleState lifecycleState)
 25  
     {
 26  0
         super(startable, lifecycleState);
 27  0
     }
 28  
 
 29  
     @Override
 30  
     protected MuleEvent processNext(MuleEvent event) throws MuleException
 31  
     {
 32  0
         if (isPaused())
 33  
         {
 34  
             try
 35  
             {
 36  0
                 if (logger.isDebugEnabled())
 37  
                 {
 38  0
                     logger.debug(startable.getClass().getName() + " " + getStartableName(startable)
 39  
                                  + " is paused. Blocking call until resumd");
 40  
                 }
 41  0
                 while (isPaused())
 42  
                 {
 43  0
                     Thread.sleep(500);
 44  
                 }
 45  
             }
 46  0
             catch (InterruptedException e)
 47  
             {
 48  0
                 throw new MessagingException(
 49  
                     CoreMessages.interruptedWaitingForPaused(getStartableName(startable)),
 50  
                     event, e);
 51  0
             }
 52  
         }
 53  0
         return super.processNext(event);
 54  
     }
 55  
 
 56  
     @Override
 57  
     protected boolean accept(MuleEvent event)
 58  
     {
 59  0
         return lifecycleState.isStarted() || isPaused();
 60  
     }
 61  
 
 62  
     protected boolean isPaused()
 63  
     {
 64  0
         return lifecycleState.isPhaseComplete(Pausable.PHASE_NAME);
 65  
     }
 66  
 
 67  
 }