Coverage Report - org.mule.util.concurrent.ThreadNameHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
ThreadNameHelper
0%
0/11
0%
0/2
1
 
 1  
 /*
 2  
  * $Id: ThreadNameHelper.java 20570 2010-12-09 20:04:42Z aperepel $
 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.util.concurrent;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.util.StringUtils;
 15  
 
 16  
 /**
 17  
  * Encapsulates thread naming logic for Mule standalone and embedded scenarios.
 18  
  */
 19  
 public class ThreadNameHelper
 20  
 {
 21  
 
 22  
     private ThreadNameHelper()
 23  0
     {
 24  
         // do not instantiate
 25  0
     }
 26  
 
 27  
     public static String receiver(MuleContext muleContext, String connectorName)
 28  
     {
 29  0
         return String.format("%s%s.receiver", getPrefix(muleContext), connectorName);
 30  
     }
 31  
 
 32  
     public static String dispatcher(MuleContext muleContext, String connectorName)
 33  
     {
 34  0
         return String.format("%s%s.dispatcher", getPrefix(muleContext), connectorName);
 35  
     }
 36  
 
 37  
     public static String requester(MuleContext muleContext, String connectorName)
 38  
     {
 39  0
         return String.format("%s%s.requester", getPrefix(muleContext), connectorName);
 40  
     }
 41  
 
 42  
     public static String asyncProcessor(MuleContext muleContext, String mpName)
 43  
     {
 44  0
         return String.format("%s%s.processor.async", getPrefix(muleContext), mpName);
 45  
     }
 46  
 
 47  
     public static String sedaService(MuleContext muleContext, String name)
 48  
     {
 49  0
         return String.format("%sseda.%s", getPrefix(muleContext), name);
 50  
     }
 51  
 
 52  
     public static String flow(MuleContext muleContext, String name)
 53  
     {
 54  0
         return String.format("%sflow.%s", getPrefix(muleContext), name);
 55  
 
 56  
     }
 57  
 
 58  
     /**
 59  
      * Generate a generic thread name prefix for this context.
 60  
      * @param muleContext context to generate the name prefix for
 61  
      * @return "[appName]." if Mule is running as a container, otherwise "Mule."
 62  
      */
 63  
     public static String getPrefix(MuleContext muleContext)
 64  
     {
 65  0
         final boolean containerMode = muleContext.getConfiguration().isContainerMode();
 66  0
         final String id = muleContext.getConfiguration().getId();
 67  
 
 68  0
         return containerMode ? String.format("[%s].", id) : StringUtils.EMPTY;
 69  
     }
 70  
 }