Package: SslServiceListeners

SslServiceListeners

nameinstructionbranchcomplexitylinemethod
SslServiceListeners(ServiceTracker)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
close()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
onConfigurationUpdated()
M: 5 C: 32
86%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 1 C: 7
88%
M: 0 C: 1
100%
openOnce()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011, 2016 Eurotech and/or its affiliates
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
11: *******************************************************************************/
12: package org.eclipse.kura.core.ssl;
13:
14: import org.eclipse.kura.ssl.SslServiceListener;
15: import org.osgi.util.tracker.ServiceTracker;
16: import org.slf4j.Logger;
17: import org.slf4j.LoggerFactory;
18:
19: class SslServiceListeners implements SslServiceListener {
20:
21: private static final Logger s_logger = LoggerFactory.getLogger(SslServiceListeners.class);
22:
23: private final ServiceTracker<SslServiceListener, SslServiceListener> m_listenersTracker;
24:
25: public SslServiceListeners(ServiceTracker<SslServiceListener, SslServiceListener> listenersTracker) {
26: super();
27: this.m_listenersTracker = listenersTracker;
28: }
29:
30: @Override
31: public void onConfigurationUpdated() {
32: openOnce();
33:
34: Object[] listeners = this.m_listenersTracker.getServices();
35:• if (listeners != null && listeners.length != 0) {
36:• for (Object listener : listeners) {
37: try {
38: ((SslServiceListener) listener).onConfigurationUpdated();
39: } catch (Throwable t) {
40: s_logger.error("Unexpected Throwable", t);
41: }
42: }
43: }
44: }
45:
46: public synchronized void close() {
47:• if (this.m_listenersTracker.getTrackingCount() != -1) {
48: this.m_listenersTracker.close();
49: }
50: }
51:
52: private synchronized void openOnce() {
53:• if (this.m_listenersTracker.getTrackingCount() == -1) {
54: this.m_listenersTracker.open();
55: }
56: }
57:
58: }