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