Package: ServerReadinessTracker

ServerReadinessTracker

nameinstructionbranchcomplexitylinemethod
ServerReadinessTracker()
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
activate(BundleContext)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
bindEventLogger(EventLogger)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
deactivate(BundleContext)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
handleEvent(Event)
M: 29 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
unbindEventLogger(EventLogger)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2012 SAP AG
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * SAP AG - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.nano.core.internal;
13:
14: import org.eclipse.virgo.nano.diagnostics.KernelLogEvents;
15: import org.osgi.service.event.Event;
16: import org.osgi.service.event.EventHandler;
17: import org.eclipse.virgo.medic.eventlog.EventLogger;
18: import org.osgi.framework.BundleContext;
19:
20: public class ServerReadinessTracker implements EventHandler {
21:
22: private static final String TOPIC_RECOVERY_COMPLETED = "org/eclipse/virgo/kernel/deployer/recovery/COMPLETED";
23: private EventLogger eventLogger;
24: private BundleContext bundleContext;
25:
26: /**
27: * {@inheritDoc}
28: */
29: public void handleEvent(Event event) {
30:• if (TOPIC_RECOVERY_COMPLETED.equals(event.getTopic())) {
31: Thread readinessPrinter = new Thread(new ServerReadinessPrinter(this.bundleContext, this.eventLogger));
32: readinessPrinter.setName("startup-readiness");
33: readinessPrinter.start();
34: }
35: }
36:
37: private class ServerReadinessPrinter implements Runnable {
38:
39: private BundleContext bundleContext;
40: private EventLogger eventLogger;
41:
42: ServerReadinessPrinter(BundleContext bundleContext, EventLogger logger) {
43: this.bundleContext = bundleContext;
44: this.eventLogger = logger;
45: }
46:
47: @Override
48: public void run() {
49: String frameworkStartTimeString = this.bundleContext.getProperty("eclipse.startTime");
50: if (frameworkStartTimeString != null) {
51: Long frameworkStartTime = Long.valueOf(frameworkStartTimeString);
52: long sinceStart = System.currentTimeMillis() - frameworkStartTime;
53: this.eventLogger.log(KernelLogEvents.VIRGO_STARTED, String.valueOf(sinceStart/1000) + "." + String.valueOf(sinceStart%1000));
54: } else {
55: this.eventLogger.log(KernelLogEvents.VIRGO_STARTED_NOTIME);
56: }
57: }
58: }
59:
60: public void activate(BundleContext context) {
61: this.bundleContext = context;
62: }
63:
64: public void deactivate(BundleContext context) {
65: this.bundleContext = null;
66: }
67:
68: public void bindEventLogger(EventLogger logger) {
69: this.eventLogger = logger;
70: }
71:
72: public void unbindEventLogger(EventLogger logger) {
73: this.eventLogger = null;
74: }
75:
76: }