Package: StandardBundleStarter

StandardBundleStarter

nameinstructionbranchcomplexitylinemethod
StandardBundleStarter(BundleStartTracker)
M: 12 C: 9
43%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
bundleNeedsStarting(Bundle)
M: 23 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
start(Bundle, AbortableSignal)
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
start(Bundle, int, AbortableSignal)
M: 27 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
trackStart(Bundle, AbortableSignal)
M: 22 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
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: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.nano.core.internal;
13:
14: import org.eclipse.virgo.nano.core.AbortableSignal;
15: import org.eclipse.virgo.nano.core.BundleStarter;
16: import org.eclipse.virgo.nano.core.BundleUtils;
17: import org.osgi.framework.Bundle;
18: import org.osgi.framework.BundleException;
19:
20:
21: /**
22: * Standard implementation of {@link BundleStarter} that starts the bundle and delegates to a {@link BundleStartTracker}
23: * to track any asynchronous portion of the bundle's startup.
24: * <p/>
25: *
26: * <strong>Concurrent Semantics</strong><br />
27: *
28: * Thread-safe.
29: *
30: */
31: final class StandardBundleStarter implements BundleStarter {
32:
33: private final BundleStartTracker bundleStartTracker;
34:
35: private static final int DEFAULT_START_OPTIONS = 0;
36:
37: public StandardBundleStarter(BundleStartTracker bundleStartTracker) {
38: this.bundleStartTracker = bundleStartTracker;
39: }
40:
41: /**
42: * {@inheritDoc}
43: */
44: public void start(Bundle bundle, AbortableSignal signal) throws BundleException {
45: start(bundle, DEFAULT_START_OPTIONS, signal);
46: }
47:
48: /**
49: * {@inheritDoc}
50: */
51: public void start(Bundle bundle, int options, AbortableSignal signal) throws BundleException {
52:
53: trackStart(bundle, signal);
54:
55:• if (bundleNeedsStarting(bundle)) {
56: try {
57: bundle.start(options);
58: } catch (BundleException be) {
59: this.bundleStartTracker.cleanup(bundle, false, be);
60: throw be;
61: }
62: }
63: }
64:
65: /**
66: * {@inheritDoc}
67: */
68: public void trackStart(Bundle bundle, AbortableSignal signal) {
69:• if (BundleUtils.isFragmentBundle(bundle)) {
70: throw new IllegalArgumentException("A fragment bundle cannot be started and so start cannot be tracked");
71: }
72:
73:• if (signal != null) {
74: this.bundleStartTracker.trackStart(bundle, signal);
75: }
76: }
77:
78: private static boolean bundleNeedsStarting(Bundle bundle) {
79:• if (bundle != null) {
80: int bundleState = bundle.getState();
81:• return (bundleState != Bundle.STARTING && bundleState != Bundle.ACTIVE);
82: }
83: return false;
84: }
85:
86: }