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