1
2
3
4
5
6
7
8
9
10
11 package org.mule.util.concurrent;
12
13 import org.mule.api.MuleContext;
14 import org.mule.util.StringUtils;
15
16
17
18
19 public class ThreadNameHelper
20 {
21
22 private ThreadNameHelper()
23 {
24
25 }
26
27 public static String receiver(MuleContext muleContext, String connectorName)
28 {
29 return String.format("%s%s.receiver", getPrefix(muleContext), connectorName);
30 }
31
32 public static String dispatcher(MuleContext muleContext, String connectorName)
33 {
34 return String.format("%s%s.dispatcher", getPrefix(muleContext), connectorName);
35 }
36
37 public static String requester(MuleContext muleContext, String connectorName)
38 {
39 return String.format("%s%s.requester", getPrefix(muleContext), connectorName);
40 }
41
42 public static String async(MuleContext muleContext, String name, int sequenceNumber )
43 {
44 return String.format("%s%s.async%s", getPrefix(muleContext), name, sequenceNumber);
45 }
46
47 public static String sedaService(MuleContext muleContext, String name)
48 {
49 return String.format("%s%s", getPrefix(muleContext), name);
50 }
51
52 public static String flow(MuleContext muleContext, String name)
53 {
54 return String.format("%s%s", getPrefix(muleContext), name);
55 }
56
57
58
59
60
61
62 public static String getPrefix(MuleContext muleContext)
63 {
64 final boolean containerMode = muleContext.getConfiguration().isContainerMode();
65 final String id = muleContext.getConfiguration().getId();
66
67 return containerMode ? String.format("[%s].", id) : StringUtils.EMPTY;
68 }
69 }