Package: ResolutionDumpContributor

ResolutionDumpContributor

nameinstructionbranchcomplexitylinemethod
ResolutionDumpContributor(BundleContext)
M: 0 C: 24
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
contribute(Dump)
M: 24 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getName()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 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.serviceability.dump.internal;
13:
14: import java.io.File;
15:
16: import org.eclipse.osgi.service.resolver.PlatformAdmin;
17: import org.eclipse.osgi.service.resolver.State;
18: import org.osgi.framework.BundleContext;
19:
20: import org.eclipse.virgo.medic.dump.Dump;
21: import org.eclipse.virgo.medic.dump.DumpContributionFailedException;
22: import org.eclipse.virgo.medic.dump.DumpContributor;
23:
24: /**
25: * An implementation of {@link DumpContributor} that generates a resolution state dump.
26: * <p />
27: *
28: * <strong>Concurrent Semantics</strong><br />
29: *
30: * Thread-safe
31: *
32: */
33: public class ResolutionDumpContributor implements DumpContributor {
34:
35: // The following literal must match DependencyCalculator.RESOLUTION_STATE_KEY in the kernel userregion bundle.
36: public final static String RESOLUTION_STATE_KEY = "resolution.state";
37:
38: private final ResolutionStateDumper resolutionStateDumper;
39:
40: public ResolutionDumpContributor(BundleContext bundleContext) {
41: PlatformAdmin platformAdmin = bundleContext.getService(bundleContext.getServiceReference(PlatformAdmin.class));
42: //OsgiFrameworkUtils.getService(bundleContext, PlatformAdmin.class).getService();
43: this.resolutionStateDumper = new ResolutionStateDumper(new StandardSystemStateAccessor(platformAdmin), new StandardStateWriter(platformAdmin.getFactory()));
44: }
45:
46: /**
47: * {@inheritDoc}
48: */
49: public void contribute(Dump dump) throws DumpContributionFailedException {
50: File outputFile = dump.createFile("osgi.zip");
51:• if (dump.getContext().containsKey(RESOLUTION_STATE_KEY)) {
52: resolutionStateDumper.dump(outputFile, (State) dump.getContext().get(RESOLUTION_STATE_KEY));
53: } else {
54: resolutionStateDumper.dump(outputFile);
55: }
56: }
57:
58: /**
59: * {@inheritDoc}
60: */
61: public String getName() {
62: return "resolution";
63: }
64:
65: }