Skip to content

Package: Activator

Activator

nameinstructionbranchcomplexitylinemethod
Activator()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getInstance()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getReportService()
M: 8 C: 25
76%
M: 4 C: 6
60%
M: 4 C: 2
33%
M: 4 C: 9
69%
M: 0 C: 1
100%
start(BundleContext)
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%
stop(BundleContext)
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH 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 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.internal.view.model.provider.xmi;
15:
16: import org.eclipse.core.runtime.Plugin;
17: import org.eclipse.emfforms.spi.common.report.ReportService;
18: import org.osgi.framework.Bundle;
19: import org.osgi.framework.BundleContext;
20: import org.osgi.framework.ServiceReference;
21:
22: /**
23: * Activator of the bundle.
24: *
25: * @author Jonas
26: *
27: */
28: public class Activator extends Plugin {
29:
30:         /**
31:          * The plug-in ID.
32:          */
33:         public static final String PLUGIN_ID = "org.eclipse.emf.ecp.view.model.provider.xmi"; //$NON-NLS-1$
34:
35:         private static Activator activator;
36:
37:         private static ServiceReference<ReportService> reportServiceReference;
38:
39:         /**
40:          *
41:          * {@inheritDoc}
42:          *
43:          * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
44:          */
45:         @Override
46:         public void start(BundleContext bundleContext) throws Exception {
47:                 super.start(bundleContext);
48:                 activator = this;
49:         }
50:
51:         /*
52:          * (non-Javadoc)
53:          * @see
54:          * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
55:          */
56:         @Override
57:         public void stop(BundleContext bundleContext) throws Exception {
58:                 super.stop(bundleContext);
59:                 activator = null;
60:         }
61:
62:         /**
63:          * Returns the {@link ReportService}.
64:          *
65:          * @return the {@link ReportService}
66:          */
67:         public static ReportService getReportService() {
68:•                if (activator == null) {
69:                         return null;
70:                 }
71:                 final Bundle bundle = activator.getBundle();
72:•                if (bundle == null) {
73:                         return null;
74:                 }
75:                 final BundleContext bundleContext = bundle.getBundleContext();
76:•                if (bundleContext == null) {
77:                         return null;
78:                 }
79:•                if (reportServiceReference == null) {
80:                         reportServiceReference = bundleContext.getServiceReference(ReportService.class);
81:                 }
82:•                if (reportServiceReference == null) {
83:                         return null;
84:                 }
85:                 return bundleContext.getService(reportServiceReference);
86:         }
87:
88:         /**
89:          * Returns the instance of this Activator.
90:          *
91:          * @return the saved instance
92:          */
93:         public static Activator getInstance() {
94:                 return activator;
95:         }
96: }