Coverage Report - org.mule.module.launcher.AppDeployerMonitorThreadFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AppDeployerMonitorThreadFactory
0%
0/12
0%
0/2
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.module.launcher;
 8  
 
 9  
 import org.mule.util.concurrent.LoggingUncaughtExceptionHandler;
 10  
 
 11  
 import java.util.concurrent.ThreadFactory;
 12  
 import java.util.concurrent.atomic.AtomicInteger;
 13  
 
 14  
 public class AppDeployerMonitorThreadFactory implements ThreadFactory
 15  
 {
 16  
 
 17  0
     static final AtomicInteger poolNumber = new AtomicInteger(1);
 18  
     final ThreadGroup group;
 19  0
     final AtomicInteger threadNumber = new AtomicInteger(1);
 20  
     final String namePrefix;
 21  
 
 22  
     public AppDeployerMonitorThreadFactory()
 23  0
     {
 24  0
         SecurityManager s = System.getSecurityManager();
 25  0
         group = (s != null) ? s.getThreadGroup() :
 26  
                 Thread.currentThread().getThreadGroup();
 27  0
         namePrefix = String.format("Mule.app.deployer.monitor.%d.thread.",  poolNumber.getAndIncrement());
 28  0
     }
 29  
 
 30  
     public Thread newThread(Runnable r)
 31  
     {
 32  0
         Thread t = new Thread(group, r,
 33  
                               namePrefix + threadNumber.getAndIncrement(),
 34  
                               0);
 35  
         // make sure it's non-daemon, allows for an 'idle' state of Mule by preventing early termination
 36  0
         t.setDaemon(false);
 37  0
         t.setPriority(Thread.MIN_PRIORITY);
 38  0
         t.setUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler());
 39  0
         return t;
 40  
     }
 41  
 
 42  
 
 43  
 }