Coverage Report - org.mule.config.MutableThreadingProfile
 
Classes in this File Line Coverage Branch Coverage Complexity
MutableThreadingProfile
0%
0/50
N/A
1
 
 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.config;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.config.ThreadingProfile;
 11  
 import org.mule.api.context.WorkManager;
 12  
 import org.mule.config.pool.ThreadPoolFactory;
 13  
 
 14  
 import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
 15  
 import edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionHandler;
 16  
 import edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory;
 17  
 
 18  
 /**
 19  
  * Partial mutability for a threading profile. A typical use case for this class is to
 20  
  * copy an existing immutable threading profile via a copying constructor, modify values and
 21  
  * reconfigure a thread pool (if the latter supports it).<p/>
 22  
  * <p/>The following parameters are copied locally and can be modified directly:
 23  
  * <ul>
 24  
  *  <li>{@link #maxThreadsActive}
 25  
  *  <li>{@link #maxThreadsIdle}
 26  
  *  <li>{@link #maxBufferSize}
 27  
  *  <li>{@link #threadTTL}
 28  
  *  <li>{@link #threadWaitTimeout}
 29  
  *  <li>{@link #poolExhaustedAction}
 30  
  *  <li>{@link #doThreading}
 31  
  * </ul>
 32  
  * <p/>The following parameters re-use the same object reference as the original threading
 33  
  * profile and <strong>are not deep clones</strong> of those:
 34  
  * <ul>
 35  
  *  <li>{@link #poolFactory}
 36  
  *  <li>{@link #workManagerFactory}
 37  
  *  <li>{@link #rejectedExecutionHandler}
 38  
  *  <li>{@link #threadFactory}
 39  
  * </ul>
 40  
  */
 41  
 public class MutableThreadingProfile implements ThreadingProfile
 42  
 {
 43  
 
 44  
     private int maxThreadsActive;
 45  
     private int maxThreadsIdle;
 46  
     private int maxBufferSize;
 47  
     private long threadTTL;
 48  
     private long threadWaitTimeout;
 49  
     private int poolExhaustedAction;
 50  
     private boolean doThreading;
 51  
 
 52  
     private ThreadPoolFactory poolFactory;
 53  
     private WorkManagerFactory workManagerFactory;
 54  
     private RejectedExecutionHandler rejectedExecutionHandler;
 55  
     private ThreadFactory threadFactory;
 56  
     private MuleContext muleContext;
 57  
 
 58  
     public MutableThreadingProfile(ThreadingProfile tp)
 59  0
     {
 60  0
         this.maxThreadsActive = tp.getMaxThreadsActive();
 61  0
         this.maxThreadsIdle = tp.getMaxThreadsIdle();
 62  0
         this.maxBufferSize = tp.getMaxBufferSize();
 63  0
         this.threadTTL = tp.getThreadTTL();
 64  0
         this.threadWaitTimeout = tp.getThreadWaitTimeout();
 65  0
         this.poolExhaustedAction = tp.getPoolExhaustedAction();
 66  0
         this.doThreading = tp.isDoThreading();
 67  0
         this.rejectedExecutionHandler = tp.getRejectedExecutionHandler();
 68  0
         this.threadFactory = tp.getThreadFactory();
 69  0
         this.workManagerFactory = tp.getWorkManagerFactory();
 70  0
         this.poolFactory = tp.getPoolFactory();
 71  0
     }
 72  
 
 73  
     public ExecutorService createPool()
 74  
     {
 75  0
         return createPool(null);
 76  
     }
 77  
 
 78  
     public int getMaxThreadsActive()
 79  
     {
 80  0
         return maxThreadsActive;
 81  
     }
 82  
 
 83  
     public int getMaxThreadsIdle()
 84  
     {
 85  0
         return maxThreadsIdle;
 86  
     }
 87  
 
 88  
     public long getThreadTTL()
 89  
     {
 90  0
         return threadTTL;
 91  
     }
 92  
 
 93  
     public long getThreadWaitTimeout()
 94  
     {
 95  0
         return threadWaitTimeout;
 96  
     }
 97  
 
 98  
     public int getPoolExhaustedAction()
 99  
     {
 100  0
         return poolExhaustedAction;
 101  
     }
 102  
 
 103  
     public RejectedExecutionHandler getRejectedExecutionHandler()
 104  
     {
 105  0
         return rejectedExecutionHandler;
 106  
     }
 107  
 
 108  
     public ThreadFactory getThreadFactory()
 109  
     {
 110  0
         return threadFactory;
 111  
     }
 112  
 
 113  
     public void setMaxThreadsActive(int maxThreadsActive)
 114  
     {
 115  0
         this.maxThreadsActive = maxThreadsActive;
 116  0
     }
 117  
 
 118  
     public void setMaxThreadsIdle(int maxThreadsIdle)
 119  
     {
 120  0
         this.maxThreadsIdle = maxThreadsIdle;
 121  0
     }
 122  
 
 123  
     public void setThreadTTL(long threadTTL)
 124  
     {
 125  0
         this.threadTTL = threadTTL;
 126  0
     }
 127  
 
 128  
     public void setThreadWaitTimeout(long threadWaitTimeout)
 129  
     {
 130  0
         this.threadWaitTimeout = threadWaitTimeout;
 131  0
     }
 132  
 
 133  
     public void setPoolExhaustedAction(int poolExhaustedAction)
 134  
     {
 135  0
         this.poolExhaustedAction = poolExhaustedAction;
 136  0
     }
 137  
 
 138  
     public void setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)
 139  
     {
 140  0
         this.rejectedExecutionHandler = rejectedExecutionHandler;
 141  0
     }
 142  
 
 143  
     public void setThreadFactory(ThreadFactory threadFactory)
 144  
     {
 145  0
         this.threadFactory = threadFactory;
 146  0
     }
 147  
 
 148  
     public int getMaxBufferSize()
 149  
     {
 150  0
         return maxBufferSize;
 151  
     }
 152  
 
 153  
     public void setMaxBufferSize(int maxBufferSize)
 154  
     {
 155  0
         this.maxBufferSize = maxBufferSize;
 156  0
     }
 157  
 
 158  
     public WorkManagerFactory getWorkManagerFactory()
 159  
     {
 160  0
         return workManagerFactory;
 161  
     }
 162  
 
 163  
     public void setWorkManagerFactory(WorkManagerFactory workManagerFactory)
 164  
     {
 165  0
         this.workManagerFactory = workManagerFactory;
 166  0
     }
 167  
 
 168  
     public WorkManager createWorkManager(String name, int shutdownTimeout)
 169  
     {
 170  0
         return workManagerFactory.createWorkManager(new ImmutableThreadingProfile(this), name, shutdownTimeout);
 171  
     }
 172  
 
 173  
     public ExecutorService createPool(String name)
 174  
     {
 175  0
         return poolFactory.createPool(name, new ImmutableThreadingProfile(this));
 176  
     }
 177  
 
 178  
     public boolean isDoThreading()
 179  
     {
 180  0
         return doThreading;
 181  
     }
 182  
 
 183  
     public void setDoThreading(boolean doThreading)
 184  
     {
 185  0
         this.doThreading = doThreading;
 186  0
     }
 187  
 
 188  
     public ThreadPoolFactory getPoolFactory()
 189  
     {
 190  0
         return poolFactory;
 191  
     }
 192  
 
 193  
     public void setMuleContext(MuleContext muleContext)
 194  
     {
 195  0
         this.muleContext = muleContext;
 196  0
     }
 197  
 
 198  
     public MuleContext getMuleContext()
 199  
     {
 200  0
         return muleContext;
 201  
     }
 202  
 }