Package: AbstractOsgiFramework

AbstractOsgiFramework

nameinstructionbranchcomplexitylinemethod
AbstractOsgiFramework(BundleContext, PackageAdmin)
M: 12 C: 17
59%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
getBundleContext()
M: 6 C: 3
33%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getClassBundle(Class)
M: 8 C: 8
50%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 2
67%
M: 0 C: 1
100%
getPackageAdmin()
M: 6 C: 3
33%
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) 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.kernel.osgi.framework.support;
13:
14: import org.eclipse.virgo.kernel.osgi.framework.OsgiFramework;
15: import org.osgi.framework.Bundle;
16: import org.osgi.framework.BundleContext;
17: import org.osgi.service.packageadmin.PackageAdmin;
18: import org.slf4j.Logger;
19: import org.slf4j.LoggerFactory;
20:
21:
22: /**
23: * Base implementation of {@link OsgiFramework}.
24: * <p/>
25: *
26: * Core start and stop logic is handled by this base implementation. In particular, the requirement to self publish as
27: * services in the service registration under <code>BundleInstaller</code> and <code>OsgiFramework</code> is handled.
28: * <p/>
29: *
30: * <strong>Concurrent Semantics</strong><br/>
31: *
32: * Implementation is thread safe.
33: *
34: */
35: @SuppressWarnings("deprecation")
36: public abstract class AbstractOsgiFramework implements OsgiFramework {
37:
38: public static final String DIRECTIVE_SEPARATOR = ";";
39:
40: public static final boolean DIRECTIVE_PUBLISH_CONTEXT_DEFAULT = true;
41:
42: protected final Logger logger = LoggerFactory.getLogger(this.getClass());
43:
44: private final PackageAdmin packageAdmin;
45:
46: private final BundleContext bundleContext;
47:
48:
49: protected AbstractOsgiFramework(BundleContext context, PackageAdmin packageAdmin) {
50: this.bundleContext = context;
51: this.packageAdmin = packageAdmin;
52: }
53:
54: public Bundle getClassBundle(Class<?> cls) {
55:• if (this.packageAdmin != null) {
56: return this.packageAdmin.getBundle(cls);
57: } else {
58: return null;
59: }
60: }
61:
62: /**
63: * Gets the {@link PackageAdmin} service.
64: *
65: * @return the <code>PackageAdmin</code> service.
66: */
67: protected final PackageAdmin getPackageAdmin() {
68: return this.packageAdmin;
69: }
70:
71: /**
72: * {@inheritDoc}
73: */
74: public BundleContext getBundleContext() {
75: return this.bundleContext;
76: }
77: }