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