Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dd59feeee34ceab756518822aa8b71cb7ab688d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************************************
 * Copyright (c) 2012 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.osgi.internal.framework.legacy;

import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.container.ModuleContainer;
import org.eclipse.osgi.internal.framework.EquinoxBundle;
import org.osgi.framework.Bundle;
import org.osgi.service.startlevel.StartLevel;

@SuppressWarnings("deprecation")
public class StartLevelImpl implements StartLevel {

	private final ModuleContainer container;

	public StartLevelImpl(ModuleContainer container) {
		this.container = container;
	}

	@Override
	public int getStartLevel() {
		return container.getFrameworkStartLevel().getStartLevel();
	}

	@Override
	public void setStartLevel(int startlevel) {
		container.getFrameworkStartLevel().setStartLevel(startlevel);
	}

	@Override
	public int getBundleStartLevel(Bundle bundle) {
		return getModule(bundle).getStartLevel();
	}

	@Override
	public void setBundleStartLevel(Bundle bundle, int startlevel) {
		getModule(bundle).setStartLevel(startlevel);
	}

	@Override
	public int getInitialBundleStartLevel() {
		return container.getFrameworkStartLevel().getInitialBundleStartLevel();
	}

	@Override
	public void setInitialBundleStartLevel(int startlevel) {
		container.getFrameworkStartLevel().setInitialBundleStartLevel(startlevel);
	}

	@Override
	public boolean isBundlePersistentlyStarted(Bundle bundle) {
		return getModule(bundle).isPersistentlyStarted();
	}

	@Override
	public boolean isBundleActivationPolicyUsed(Bundle bundle) {
		return getModule(bundle).isActivationPolicyUsed();
	}

	static Module getModule(Bundle bundle) {
		if (bundle instanceof EquinoxBundle) {
			return ((EquinoxBundle) bundle).getModule();
		}
		throw new IllegalArgumentException("Bundle is not from an equinox framework: " + bundle.getClass()); //$NON-NLS-1$
	}
}

Back to the top