blob: c74eaae0e0cf64f9f0e7eda8ecaeac6f41d5128d (
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
75
76
77
78
79
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc;
import com.yahoo.jdisc.application.OsgiFramework;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import java.util.Collection;
import java.util.List;
/**
* @author Tony Vaagenes
*/
public final class DisableOsgiFramework implements OsgiFramework {
private final RestrictedBundleContext restrictedBundleContext;
public DisableOsgiFramework() {
this.restrictedBundleContext = null;
}
public DisableOsgiFramework(RestrictedBundleContext restrictedBundleContext) {
this.restrictedBundleContext = restrictedBundleContext;
}
@Override
public List<Bundle> installBundle(String bundleLocation) throws BundleException {
throw newException();
}
@Override
public void startBundles(List<Bundle> bundles, boolean privileged) throws BundleException {
throw newException();
}
@Override
public void refreshPackages() {
throw newException();
}
@Override
public BundleContext bundleContext() {
if (restrictedBundleContext == null) {
throw newException();
}
return restrictedBundleContext;
}
@Override
public List<Bundle> bundles() {
throw newException();
}
@Override
public List<Bundle> getBundles(Bundle requestingBundle) {
throw newException();
}
@Override
public void allowDuplicateBundles(Collection<Bundle> bundles) {
throw newException();
}
@Override
public void start() throws BundleException {
throw newException();
}
@Override
public void stop() throws BundleException {
throw newException();
}
private RuntimeException newException() {
return new UnsupportedOperationException("The OSGi framework is not available to components.");
}
}
|