| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
package org.apache.camel.util; |
| 19 |
|
|
| 20 |
|
import org.apache.camel.Service; |
| 21 |
|
import org.apache.commons.logging.Log; |
| 22 |
|
import org.apache.commons.logging.LogFactory; |
| 23 |
|
|
| 24 |
|
import java.util.Collection; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
0 |
public class ServiceHelper { |
| 32 |
1 |
private static final transient Log log = LogFactory.getLog(ServiceHelper.class); |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public static void startServices(Object... services) throws Exception { |
| 39 |
650 |
for (Object value : services) { |
| 40 |
360 |
startService(value); |
| 41 |
|
} |
| 42 |
290 |
} |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
public static void startServices(Collection services) throws Exception { |
| 48 |
51 |
for (Object value : services) { |
| 49 |
101 |
if (value instanceof Service) { |
| 50 |
101 |
Service service = (Service) value; |
| 51 |
101 |
service.start(); |
| 52 |
|
} |
| 53 |
101 |
} |
| 54 |
51 |
} |
| 55 |
|
|
| 56 |
|
public static void startService(Object value) throws Exception { |
| 57 |
360 |
if (value instanceof Service) { |
| 58 |
215 |
Service service = (Service) value; |
| 59 |
215 |
service.start(); |
| 60 |
215 |
} |
| 61 |
145 |
else if (value instanceof Collection) { |
| 62 |
0 |
startServices((Collection) value); |
| 63 |
|
} |
| 64 |
360 |
} |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
public static void stopServices(Object... services) throws Exception { |
| 70 |
181 |
Exception firstException = null; |
| 71 |
430 |
for (Object value : services) { |
| 72 |
249 |
if (value instanceof Service) { |
| 73 |
208 |
Service service = (Service) value; |
| 74 |
|
try { |
| 75 |
208 |
service.stop(); |
| 76 |
|
} |
| 77 |
0 |
catch (Exception e) { |
| 78 |
0 |
log.debug("Caught exception shutting down: " + e, e); |
| 79 |
0 |
if (firstException == null) { |
| 80 |
0 |
firstException = e; |
| 81 |
|
} |
| 82 |
208 |
} |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
181 |
if (firstException != null) { |
| 86 |
0 |
throw firstException; |
| 87 |
|
} |
| 88 |
181 |
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
public static void stopServices(Collection services) throws Exception { |
| 93 |
125 |
Exception firstException = null; |
| 94 |
125 |
for (Object value : services) { |
| 95 |
127 |
if (value instanceof Service) { |
| 96 |
127 |
Service service = (Service) value; |
| 97 |
|
try { |
| 98 |
127 |
service.stop(); |
| 99 |
|
} |
| 100 |
0 |
catch (Exception e) { |
| 101 |
0 |
log.debug("Caught exception shutting down: " + e, e); |
| 102 |
0 |
if (firstException == null) { |
| 103 |
0 |
firstException = e; |
| 104 |
|
} |
| 105 |
127 |
} |
| 106 |
|
} |
| 107 |
127 |
} |
| 108 |
125 |
if (firstException != null) { |
| 109 |
0 |
throw firstException; |
| 110 |
|
} |
| 111 |
125 |
} |
| 112 |
|
} |