Coverage Report - org.mule.module.jca.DelegateWorkManager
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegateWorkManager
14%
3/21
N/A
1.143
DelegateWorkManager$RunnableWorkAdapter
0%
0/6
N/A
1.143
 
 1  
 /*
 2  
  * $Id: DelegateWorkManager.java 11517 2008-03-31 21:34:19Z 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.module.jca;
 12  
 
 13  
 import org.mule.api.MuleException;
 14  
 
 15  
 import javax.resource.spi.work.ExecutionContext;
 16  
 import javax.resource.spi.work.Work;
 17  
 import javax.resource.spi.work.WorkException;
 18  
 import javax.resource.spi.work.WorkListener;
 19  
 
 20  
 import edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionException;
 21  
 
 22  
 /**
 23  
  * <code>DelegateWorkManager</code> is a wrapper around a WorkManager provided by a
 24  
  * JCA container.
 25  
  */
 26  
 public class DelegateWorkManager implements org.mule.api.context.WorkManager
 27  
 {
 28  
     private final javax.resource.spi.work.WorkManager workManager;
 29  
 
 30  
     public DelegateWorkManager(javax.resource.spi.work.WorkManager workManager2)
 31  10
     {
 32  10
         this.workManager = workManager2;
 33  10
     }
 34  
 
 35  
     public void doWork(Work work) throws WorkException
 36  
     {
 37  0
         workManager.doWork(work);
 38  0
     }
 39  
 
 40  
     public void doWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener)
 41  
         throws WorkException
 42  
     {
 43  0
         workManager.doWork(work, l, executionContext, workListener);
 44  0
     }
 45  
 
 46  
     public long startWork(Work work) throws WorkException
 47  
     {
 48  0
         return workManager.startWork(work);
 49  
     }
 50  
 
 51  
     public long startWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener)
 52  
         throws WorkException
 53  
     {
 54  0
         return workManager.startWork(work, l, executionContext, workListener);
 55  
     }
 56  
 
 57  
     public void scheduleWork(Work work) throws WorkException
 58  
     {
 59  0
         workManager.scheduleWork(work);
 60  0
     }
 61  
 
 62  
     public void scheduleWork(Work work, long l, ExecutionContext executionContext, WorkListener workListener)
 63  
         throws WorkException
 64  
     {
 65  0
         workManager.scheduleWork(work, l, executionContext, workListener);
 66  0
     }
 67  
 
 68  
     public void execute(Runnable command)
 69  
     {
 70  
         try
 71  
         {
 72  0
             this.scheduleWork(new RunnableWorkAdapter(command));
 73  
         }
 74  0
         catch (WorkException wex)
 75  
         {
 76  
             // unfortunately RejectedExecutionException is the closest thing we have
 77  
             // as proper RuntimeException
 78  0
             throw new RejectedExecutionException(wex);
 79  0
         }
 80  0
     }
 81  
 
 82  
     public void start() throws MuleException
 83  
     {
 84  
         // nothing to do
 85  0
     }
 86  
 
 87  
     public void stop() throws MuleException
 88  
     {
 89  
         // nothing to do
 90  0
     }
 91  
 
 92  
     public void dispose()
 93  
     {
 94  
         // nothing to do
 95  0
     }
 96  
 
 97  
     protected static class RunnableWorkAdapter implements Work
 98  
     {
 99  
         private final Runnable command;
 100  
 
 101  
         public RunnableWorkAdapter(Runnable command)
 102  
         {
 103  0
             super();
 104  0
             this.command = command;
 105  0
         }
 106  
 
 107  
         public void release()
 108  
         {
 109  
             // nothing to do
 110  0
         }
 111  
 
 112  
         public void run()
 113  
         {
 114  0
             command.run();
 115  0
         }
 116  
     }
 117  
 
 118  
 }