Coverage Report - org.mule.transport.PollingReceiverWorker
 
Classes in this File Line Coverage Branch Coverage Complexity
PollingReceiverWorker
0%
0/23
0%
0/2
1.667
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport;
 8  
 
 9  
 import org.mule.RequestContext;
 10  
 import org.mule.api.MuleException;
 11  
 
 12  
 import javax.resource.spi.work.Work;
 13  
 
 14  
 public class PollingReceiverWorker implements Work
 15  
 {
 16  
     protected final AbstractPollingMessageReceiver receiver;
 17  0
     protected volatile boolean running = false;
 18  
 
 19  
     public PollingReceiverWorker(AbstractPollingMessageReceiver pollingMessageReceiver)
 20  
     {
 21  0
         super();
 22  0
         receiver = pollingMessageReceiver;
 23  0
     }
 24  
 
 25  
     public AbstractPollingMessageReceiver getReceiver()
 26  
     {
 27  0
         return receiver;
 28  
     }
 29  
     
 30  
     public boolean isRunning()
 31  
     {
 32  0
         return running;
 33  
     }
 34  
 
 35  
     // the run() method will exit after each poll() since it will be invoked again
 36  
     // by the scheduler
 37  
     public void run()
 38  
     {
 39  
         // Make sure we start with a clean slate.
 40  0
         RequestContext.clear();
 41  0
         if (receiver.isStarted())
 42  
         {
 43  0
             running = true;
 44  
             try
 45  
             {
 46  0
                 poll();
 47  
             }
 48  0
             catch (InterruptedException e)
 49  
             {
 50  
                // stop polling
 51  
                 try
 52  
                 {
 53  0
                     receiver.stop();
 54  
                 }
 55  0
                 catch (MuleException e1)
 56  
                 {
 57  0
                     receiver.getConnector().getMuleContext().getExceptionListener().handleException(e1);
 58  0
                 }
 59  
             }
 60  0
             catch (Exception e)
 61  
             {
 62  0
                 receiver.getConnector().getMuleContext().getExceptionListener().handleException(e);
 63  
             }
 64  
             finally
 65  
             {
 66  0
                 running = false;
 67  0
             }
 68  
         }
 69  0
     }
 70  
 
 71  
     protected void poll() throws Exception
 72  
     {
 73  0
         receiver.poll();
 74  0
     }
 75  
 
 76  
     public void release()
 77  
     {
 78  
         // nop
 79  0
     }
 80  
 
 81  
 }