BaseBundleCheck.java
2.31 KB
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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.osgi.framework.Bundle
* org.osgi.framework.BundleContext
* org.osgi.framework.InvalidSyntaxException
* org.osgi.service.cm.Configuration
* org.osgi.service.cm.ConfigurationAdmin
*/
package com.adobe.granite.bundles.hc.impl;
import java.io.IOException;
import java.util.Dictionary;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
public class BaseBundleCheck {
protected String bundleName = "";
protected String serviceName = "";
protected BaseBundleCheck(String bundleName, String serviceName) {
this.bundleName = bundleName;
this.serviceName = serviceName;
}
protected boolean isConfigurationUnbound(Configuration[] config) {
return config == null || config.length == 1 && config[0].getBundleLocation() == null;
}
protected boolean isLazyActivation(Bundle b) {
return "lazy".equals(b.getHeaders().get("Bundle-ActivationPolicy"));
}
protected boolean isBundleActive(BundleContext bundleContext) {
boolean bundleFound = false;
if (this.bundleName != null) {
Bundle[] bundles;
for (Bundle bundle : bundles = bundleContext.getBundles()) {
String symbolicName;
Dictionary headers = bundle.getHeaders();
if (headers == null || (symbolicName = (String)headers.get("Bundle-SymbolicName")) == null || !this.bundleName.equals(symbolicName)) continue;
if (bundle.getState() != 32 && (bundle.getState() != 8 || !this.isLazyActivation(bundle))) break;
bundleFound = true;
break;
}
}
return bundleFound;
}
protected Configuration[] getServletConfigs(ConfigurationAdmin configurationAdmin) {
Configuration[] servletCfgs = null;
String filter = "(service.pid=" + this.serviceName + ")";
try {
servletCfgs = configurationAdmin.listConfigurations(filter);
}
catch (IOException var4_4) {
}
catch (InvalidSyntaxException var4_5) {
// empty catch block
}
return servletCfgs;
}
}