Skip to content

Package: AbstractListener

AbstractListener

nameinstructionbranchcomplexitylinemethod
AbstractListener(String)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
AbstractListener(String, String)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
registerCounter(String[])
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
registerTimer(String[])
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.broker.core.listener;
14:
15: import com.codahale.metrics.Counter;
16: import com.codahale.metrics.Timer;
17: import org.eclipse.kapua.commons.metric.MetricServiceFactory;
18: import org.eclipse.kapua.commons.metric.MetricsService;
19:
20: /**
21: * Default camel pojo endpoint listener.
22: *
23: * @since 1.0
24: */
25: public abstract class AbstractListener {
26:
27: // metrics
28: private String metricComponentName = "listener";
29: private static final MetricsService METRICS_SERVICE = MetricServiceFactory.getInstance();
30:
31: protected String name;
32:
33: /**
34: * Create a listener with the specific name.<BR>
35: * The "listener" constant will be used as metricComponentName.
36: *
37: * @param name First level name to categorize the metrics inside the listener
38: */
39: protected AbstractListener(String name) {
40: this.name = name;
41: }
42:
43: /**
44: * Create a listener with the specific metricComponentName and name
45: *
46: * @param metricComponentName Root name to categorize the metrics inside the listener
47: * @param name First level name to categorize the metrics inside the listener
48: */
49: protected AbstractListener(String metricComponentName, String name) {
50: this(name);
51: this.metricComponentName = metricComponentName;
52: }
53:
54: /**
55: * Register a Counter with the specified names as suffix.<BR>
56: * The prefix is described by a combination of constructor parameters name and metricComponentName depending on which constructor will be used.
57: *
58: * @param names
59: * @return
60: */
61: protected Counter registerCounter(String... names) {
62: return METRICS_SERVICE.getCounter(metricComponentName, name, names);
63: }
64:
65: /**
66: * Register a Timer with the specified names as suffix.<BR>
67: * The prefix is described by a combination of constructor parameters name and metricComponentName depending on which constructor will be used.
68: *
69: * @param names
70: * @return
71: */
72: protected Timer registerTimer(String... names) {
73: return METRICS_SERVICE.getTimer(metricComponentName, name, names);
74: }
75:
76: }